@kb-labs/scaffold 2.29.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/dist/commands/doctor.d.ts +15 -0
- package/dist/commands/doctor.js +63 -0
- package/dist/commands/doctor.js.map +1 -0
- package/dist/commands/scaffold.d.ts +18 -0
- package/dist/commands/scaffold.js +196 -0
- package/dist/commands/scaffold.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/manifest.d.ts +75 -0
- package/dist/manifest.js +114 -0
- package/dist/manifest.js.map +1 -0
- package/package.json +55 -0
- package/templates/adapter/blocks/base/block.yaml +4 -0
- package/templates/adapter/blocks/base/files/README.md.eta +28 -0
- package/templates/adapter/blocks/base/files/package.json.eta +37 -0
- package/templates/adapter/blocks/base/files/src/manifest.ts.eta +24 -0
- package/templates/adapter/blocks/base/files/tsconfig.json +8 -0
- package/templates/adapter/blocks/base/files/tsup.config.ts +10 -0
- package/templates/adapter/blocks/base/files/vitest.config.ts +12 -0
- package/templates/adapter/blocks/provider-example/block.yaml +6 -0
- package/templates/adapter/blocks/provider-example/files/src/index.ts.eta +6 -0
- package/templates/adapter/blocks/provider-example/files/src/llm.ts.eta +46 -0
- package/templates/adapter/entity.yaml +37 -0
- package/templates/plugin/blocks/base/block.yaml +5 -0
- package/templates/plugin/blocks/base/files/README.md.eta +54 -0
- package/templates/plugin/blocks/base/files/package.json.eta +14 -0
- package/templates/plugin/blocks/base/files/packages/__name__-contracts/package.json.eta +29 -0
- package/templates/plugin/blocks/base/files/packages/__name__-contracts/src/index.ts.eta +14 -0
- package/templates/plugin/blocks/base/files/packages/__name__-contracts/tsconfig.json +8 -0
- package/templates/plugin/blocks/base/files/packages/__name__-contracts/tsup.config.ts +10 -0
- package/templates/plugin/blocks/base/files/packages/__name__-contracts/vitest.config.ts +12 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/package.json.eta +33 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/src/hello.ts.eta +59 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/src/index.ts.eta +1 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/tests/hello.test.ts.eta +16 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/tsconfig.json +8 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/tsup.config.ts +10 -0
- package/templates/plugin/blocks/base/files/packages/__name__-core/vitest.config.ts +12 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/eslint.config.js +3 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/package.json.eta +41 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/src/commands/hello.ts.eta +39 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/src/index.ts.eta +4 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/tsconfig.json +8 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/tsup.config.ts +10 -0
- package/templates/plugin/blocks/base/files/packages/__name__-entry/vitest.config.ts +12 -0
- package/templates/plugin/blocks/base/files/pnpm-workspace.yaml.eta +3 -0
- package/templates/plugin/blocks/base/files/tsconfig.base.json +3 -0
- package/templates/plugin/blocks/base/manifest.patch.yaml +28 -0
- package/templates/plugin/blocks/base/manifest.snippets.yaml +4 -0
- package/templates/plugin/blocks/cli/block.yaml +5 -0
- package/templates/plugin/blocks/cli/files/packages/__name__-entry/src/commands/ping.ts.eta +25 -0
- package/templates/plugin/blocks/cli/manifest.patch.yaml +14 -0
- package/templates/plugin/blocks/contracts/block.yaml +5 -0
- package/templates/plugin/blocks/contracts/files/packages/__name__-contracts/src/events.ts.eta +13 -0
- package/templates/plugin/blocks/rest/block.yaml +6 -0
- package/templates/plugin/blocks/rest/files/packages/__name__-entry/src/rest/hello.ts.eta +22 -0
- package/templates/plugin/blocks/rest/manifest.patch.yaml +9 -0
- package/templates/plugin/entity.yaml +39 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "<%= it.scope ? it.scope + '/' : '' %><%= it.name %>-entry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "V3 manifest + CLI handlers for <%= it.name %>",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./plugin-manifest": {
|
|
14
|
+
"import": "./dist/manifest.js",
|
|
15
|
+
"types": "./dist/manifest.d.ts"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"kb": {
|
|
19
|
+
"manifest": "./dist/manifest.js"
|
|
20
|
+
},
|
|
21
|
+
"files": ["dist"],
|
|
22
|
+
"sideEffects": false,
|
|
23
|
+
"scripts": {
|
|
24
|
+
"clean": "rimraf dist",
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"type-check": "tsc --noEmit",
|
|
27
|
+
"test": "vitest run --passWithNoTests"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"<%= it.scope ? it.scope + '/' : '' %><%= it.name %>-core": "<%= it.mode === 'in-workspace' ? 'workspace:*' : '^0.1.0' %>",
|
|
31
|
+
"<%= it.scope ? it.scope + '/' : '' %><%= it.name %>-contracts": "<%= it.mode === 'in-workspace' ? 'workspace:*' : '^0.1.0' %>",
|
|
32
|
+
"@kb-labs/sdk": "<%= it.mode === 'in-workspace' ? 'workspace:*' : '^' + it.versions.sdk %>"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@kb-labs/devkit": "<%= it.mode === 'in-workspace' ? 'workspace:*' : '^' + it.versions.devkit %>",
|
|
36
|
+
"rimraf": "^6.0.1",
|
|
37
|
+
"tsup": "^8.5.0",
|
|
38
|
+
"typescript": "^5.6.3",
|
|
39
|
+
"vitest": "^3.2.4"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineCommand, type PluginContextV3 } from '@kb-labs/sdk';
|
|
2
|
+
import { hello } from '<%= it.scope ? it.scope + '/' : '' %><%= it.name %>-core';
|
|
3
|
+
|
|
4
|
+
type HelloFlags = {
|
|
5
|
+
who?: string;
|
|
6
|
+
json?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type HelloResult = {
|
|
10
|
+
exitCode: number;
|
|
11
|
+
result?: { greeting: string };
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* `kb <%= it.name %> hello` — prints a friendly greeting.
|
|
16
|
+
*
|
|
17
|
+
* This handler demonstrates the bare minimum: receive flags, call into
|
|
18
|
+
* `-core`, write output via `ctx.ui`. As you grow, reach for the patterns
|
|
19
|
+
* sketched inside `<%= it.name %>-core/src/hello.ts` — LLM calls, caching,
|
|
20
|
+
* structured logging — ALL through `@kb-labs/sdk`.
|
|
21
|
+
*/
|
|
22
|
+
export default defineCommand({
|
|
23
|
+
id: '<%= it.name %>:hello',
|
|
24
|
+
description: 'Say hello from <%= it.name %>',
|
|
25
|
+
|
|
26
|
+
handler: {
|
|
27
|
+
async execute(ctx: PluginContextV3, input: HelloFlags): Promise<HelloResult> {
|
|
28
|
+
const { greeting } = hello({ who: input.who ?? 'World' });
|
|
29
|
+
|
|
30
|
+
if (input.json) {
|
|
31
|
+
ctx.ui?.json?.({ greeting });
|
|
32
|
+
} else {
|
|
33
|
+
ctx.ui?.info?.(greeting);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { exitCode: 0, result: { greeting } };
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Re-export the manifest as a side-channel for tooling that imports the
|
|
2
|
+
// package directly (e.g. the marketplace linker). The primary entry point
|
|
3
|
+
// is the "kb.manifest" field in package.json pointing at ./dist/manifest.js.
|
|
4
|
+
export { default as manifest } from './manifest.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineConfig } from 'tsup';
|
|
2
|
+
import nodePreset from '@kb-labs/devkit/tsup/node';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
...nodePreset,
|
|
6
|
+
entry: ['src/index.ts', 'src/manifest.ts', 'src/commands/*.ts'],
|
|
7
|
+
dts: { resolve: true, skipLibCheck: true },
|
|
8
|
+
clean: true,
|
|
9
|
+
sourcemap: true,
|
|
10
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import baseConfig from '@kb-labs/devkit/vitest/node';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
...baseConfig,
|
|
6
|
+
test: {
|
|
7
|
+
...baseConfig.test,
|
|
8
|
+
globals: true,
|
|
9
|
+
include: ['tests/**/*.test.ts', 'src/**/*.test.ts'],
|
|
10
|
+
environment: 'node',
|
|
11
|
+
},
|
|
12
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
schema: kb.plugin/3
|
|
2
|
+
id: "<%= it.scope ? it.scope + '/' : '' %><%= it.name %>"
|
|
3
|
+
version: "0.1.0"
|
|
4
|
+
display:
|
|
5
|
+
name: "<%= it.name %>"
|
|
6
|
+
description: "<%= it.vars.description %>"
|
|
7
|
+
cli:
|
|
8
|
+
groupMeta:
|
|
9
|
+
- name: "<%= it.name %>"
|
|
10
|
+
description: "<%= it.vars.description %>"
|
|
11
|
+
commands:
|
|
12
|
+
- id: hello
|
|
13
|
+
group: "<%= it.name %>"
|
|
14
|
+
describe: "Say hello from <%= it.name %>"
|
|
15
|
+
handler: "./commands/hello.js#default"
|
|
16
|
+
handlerPath: "./commands/hello.js"
|
|
17
|
+
flags:
|
|
18
|
+
- name: who
|
|
19
|
+
type: string
|
|
20
|
+
description: "Who to greet"
|
|
21
|
+
default: World
|
|
22
|
+
- name: json
|
|
23
|
+
type: boolean
|
|
24
|
+
description: "Emit JSON instead of text"
|
|
25
|
+
examples:
|
|
26
|
+
- "kb <%= it.name %> hello"
|
|
27
|
+
- "kb <%= it.name %> hello --who=Developer"
|
|
28
|
+
- "kb <%= it.name %> hello --json"
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { defineCommand, type PluginContextV3 } from '@kb-labs/sdk';
|
|
2
|
+
|
|
3
|
+
type PingFlags = { json?: boolean };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `kb <%= it.name %> ping` — a second command to show how to add more.
|
|
7
|
+
* Duplicate this file, add an entry in `manifest.ts` under `cli.commands[]`,
|
|
8
|
+
* and you have a new command.
|
|
9
|
+
*/
|
|
10
|
+
export default defineCommand({
|
|
11
|
+
id: '<%= it.name %>:ping',
|
|
12
|
+
description: 'Health ping for <%= it.name %>',
|
|
13
|
+
|
|
14
|
+
handler: {
|
|
15
|
+
async execute(ctx: PluginContextV3, input: PingFlags) {
|
|
16
|
+
const payload = { ok: true, at: new Date().toISOString() };
|
|
17
|
+
if (input.json) {
|
|
18
|
+
ctx.ui?.json?.(payload);
|
|
19
|
+
} else {
|
|
20
|
+
ctx.ui?.info?.(`pong @ ${payload.at}`);
|
|
21
|
+
}
|
|
22
|
+
return { exitCode: 0, result: payload };
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
cli:
|
|
2
|
+
commands:
|
|
3
|
+
- id: ping
|
|
4
|
+
group: "<%= it.name %>"
|
|
5
|
+
describe: "Health ping for <%= it.name %>"
|
|
6
|
+
handler: "./commands/ping.js#default"
|
|
7
|
+
handlerPath: "./commands/ping.js"
|
|
8
|
+
flags:
|
|
9
|
+
- name: json
|
|
10
|
+
type: boolean
|
|
11
|
+
description: "Emit JSON instead of text"
|
|
12
|
+
examples:
|
|
13
|
+
- "kb <%= it.name %> ping"
|
|
14
|
+
- "kb <%= it.name %> ping --json"
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Example event shapes — expand as the plugin grows.
|
|
3
|
+
*
|
|
4
|
+
* Contracts are deliberately small: put ONLY the types that both `-core`
|
|
5
|
+
* and `-entry` need to agree on here. Internal types belong in their
|
|
6
|
+
* respective packages.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface GreetingEmitted {
|
|
10
|
+
kind: '<%= it.name %>.greeting.emitted';
|
|
11
|
+
who: string;
|
|
12
|
+
at: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineRoute, type PluginContextV3 } from '@kb-labs/sdk';
|
|
2
|
+
import { hello } from '<%= it.scope ? it.scope + '/' : '' %><%= it.name %>-core';
|
|
3
|
+
|
|
4
|
+
type HelloQuery = { who?: string };
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `GET /<%= it.name %>/hello?who=World` — the REST twin of the CLI command.
|
|
8
|
+
*
|
|
9
|
+
* Route handlers receive the parsed query/body through the second argument.
|
|
10
|
+
* Keep them thin: call into `-core`, return the response shape.
|
|
11
|
+
*/
|
|
12
|
+
export default defineRoute({
|
|
13
|
+
id: '<%= it.name %>:rest:hello',
|
|
14
|
+
description: 'Say hello over HTTP',
|
|
15
|
+
|
|
16
|
+
handler: {
|
|
17
|
+
async execute(_ctx: PluginContextV3, input: HelloQuery) {
|
|
18
|
+
const { greeting } = hello({ who: input.who ?? 'World' });
|
|
19
|
+
return { status: 200, body: { greeting } };
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
id: plugin
|
|
2
|
+
displayName: KB Labs Plugin
|
|
3
|
+
description: |
|
|
4
|
+
A KB Labs plugin: three workspace packages (entry, core, contracts) that
|
|
5
|
+
register CLI commands, REST routes, Studio pages, or daemons via a V3
|
|
6
|
+
manifest. Everything extends @kb-labs/devkit configs and talks to the
|
|
7
|
+
platform exclusively through @kb-labs/sdk.
|
|
8
|
+
|
|
9
|
+
output: .kb/plugins/<%= it.name %>
|
|
10
|
+
manifestTarget: packages/<%= it.name %>-entry/src/manifest.ts
|
|
11
|
+
|
|
12
|
+
variables:
|
|
13
|
+
- name: scope
|
|
14
|
+
type: string
|
|
15
|
+
describe: npm scope (e.g. @kb-labs, @acme). Leave blank for unscoped.
|
|
16
|
+
default: "@kb-labs"
|
|
17
|
+
validate: npmScope
|
|
18
|
+
- name: description
|
|
19
|
+
type: string
|
|
20
|
+
describe: Short description of the plugin
|
|
21
|
+
default: A KB Labs plugin
|
|
22
|
+
- name: license
|
|
23
|
+
type: string
|
|
24
|
+
describe: License identifier
|
|
25
|
+
default: MIT
|
|
26
|
+
- name: mode
|
|
27
|
+
type: select
|
|
28
|
+
describe: Where will this plugin live?
|
|
29
|
+
default: in-workspace
|
|
30
|
+
choices:
|
|
31
|
+
- value: in-workspace
|
|
32
|
+
label: Inside an existing KB Labs workspace (use workspace:* deps)
|
|
33
|
+
- value: standalone
|
|
34
|
+
label: Standalone repo (semver-pinned deps, own pnpm-workspace.yaml)
|
|
35
|
+
|
|
36
|
+
defaults:
|
|
37
|
+
blocks:
|
|
38
|
+
- base
|
|
39
|
+
- cli
|