@kybernesis/create 0.13.2 → 0.13.3
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/add.d.ts +17 -0
- package/dist/add.js +110 -0
- package/dist/cli.js +7 -0
- package/dist/templates.js +21 -4
- package/package.json +1 -1
package/dist/add.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `kyb add channel <kind>` — put another surface on an agent that already exists.
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* The scaffold has told people to run this command since the day it shipped,
|
|
6
|
+
* in its own closing summary and in the host-specific steps, and it did not
|
|
7
|
+
* exist. Anyone following those instructions got "no such command" and a
|
|
8
|
+
* suggestion to upgrade, which is a particularly bad failure: the advice is
|
|
9
|
+
* wrong, the fix it proposes does nothing, and the person concludes their
|
|
10
|
+
* install is broken.
|
|
11
|
+
*
|
|
12
|
+
* Everything it needs was already here. `channelPlan` describes each surface —
|
|
13
|
+
* its file, dependencies, registry items, env and human steps — and `init` has
|
|
14
|
+
* always applied that plan. This applies the same plan to a directory that is
|
|
15
|
+
* already an agent, which is all "add" ever meant.
|
|
16
|
+
*/
|
|
17
|
+
export declare function add(what: string | undefined, rest: string[]): Promise<void>;
|
package/dist/add.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, resolve } from "node:path";
|
|
3
|
+
import { bold, dim, green, red, run, yellow } from "./util.js";
|
|
4
|
+
import { CHANNEL_KINDS, channelPlan } from "./templates.js";
|
|
5
|
+
/**
|
|
6
|
+
* `kyb add channel <kind>` — put another surface on an agent that already exists.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* The scaffold has told people to run this command since the day it shipped,
|
|
10
|
+
* in its own closing summary and in the host-specific steps, and it did not
|
|
11
|
+
* exist. Anyone following those instructions got "no such command" and a
|
|
12
|
+
* suggestion to upgrade, which is a particularly bad failure: the advice is
|
|
13
|
+
* wrong, the fix it proposes does nothing, and the person concludes their
|
|
14
|
+
* install is broken.
|
|
15
|
+
*
|
|
16
|
+
* Everything it needs was already here. `channelPlan` describes each surface —
|
|
17
|
+
* its file, dependencies, registry items, env and human steps — and `init` has
|
|
18
|
+
* always applied that plan. This applies the same plan to a directory that is
|
|
19
|
+
* already an agent, which is all "add" ever meant.
|
|
20
|
+
*/
|
|
21
|
+
export async function add(what, rest) {
|
|
22
|
+
if (what !== "channel") {
|
|
23
|
+
console.error(red(`kyb add: don't know how to add "${what ?? ""}".`));
|
|
24
|
+
console.log(dim(` kyb add channel <${CHANNEL_KINDS.filter((k) => k !== "none").join("|")}>`));
|
|
25
|
+
process.exitCode = 1;
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const kind = rest.find((a) => !a.startsWith("-"));
|
|
29
|
+
if (!kind || !CHANNEL_KINDS.includes(kind) || kind === "none") {
|
|
30
|
+
console.error(red(`kyb add channel: pick one of ${CHANNEL_KINDS.filter((k) => k !== "none").join(", ")}.`));
|
|
31
|
+
process.exitCode = 1;
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const dir = resolve(process.cwd());
|
|
35
|
+
if (!existsSync(join(dir, "package.json")) || !existsSync(join(dir, "agent"))) {
|
|
36
|
+
console.error(red("kyb add channel: run this inside an agent directory."));
|
|
37
|
+
process.exitCode = 1;
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const name = agentNameOf(dir);
|
|
41
|
+
const host = existsSync(join(dir, "scripts/eve-server.sh")) ? "exe" : "vercel";
|
|
42
|
+
const plan = channelPlan(kind, name, host);
|
|
43
|
+
console.log(bold(`kyb add channel ${kind}`));
|
|
44
|
+
console.log(dim(` agent: ${name}\n host: ${host}`));
|
|
45
|
+
if (!plan.file) {
|
|
46
|
+
console.error(red(` ${kind} has no channel file to add.`));
|
|
47
|
+
process.exitCode = 1;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const target = join(dir, "agent/channels", plan.file);
|
|
51
|
+
// Refuse rather than overwrite. A channel file is somewhere people put real
|
|
52
|
+
// logic — routing, filters, a greeting — and silently replacing it with the
|
|
53
|
+
// template is not something an "add" command should ever do.
|
|
54
|
+
if (existsSync(target)) {
|
|
55
|
+
console.log(yellow(` agent/channels/${plan.file} already exists — leaving it alone.`));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
mkdirSync(join(dir, "agent/channels"), { recursive: true });
|
|
59
|
+
writeFileSync(target, plan.content);
|
|
60
|
+
console.log(green(` + agent/channels/${plan.file}`));
|
|
61
|
+
}
|
|
62
|
+
if (plan.deps.length) {
|
|
63
|
+
console.log(bold(`\n Installing ${plan.deps.join(", ")} …`));
|
|
64
|
+
run("npm", ["install", ...plan.deps, "--no-audit", "--no-fund"], { cwd: dir, allowFail: true });
|
|
65
|
+
}
|
|
66
|
+
for (const item of plan.registryItems) {
|
|
67
|
+
run("npx", ["eve", "add", item, "--overwrite"], { cwd: dir, allowFail: true });
|
|
68
|
+
}
|
|
69
|
+
// Report what was actually written, not what the plan contained. Run twice,
|
|
70
|
+
// the second run adds nothing and saying otherwise sends someone looking in
|
|
71
|
+
// .env.example for variables that were already there.
|
|
72
|
+
const added = appendEnvExample(dir, kind, plan.env);
|
|
73
|
+
if (added)
|
|
74
|
+
console.log(green(` + ${added} line(s) in .env.example`));
|
|
75
|
+
console.log(bold("\n Still to do:"));
|
|
76
|
+
for (const step of plan.steps)
|
|
77
|
+
console.log(` · ${step}`);
|
|
78
|
+
console.log(dim(`\n Then fill the new values into .env.local and restart:\n` +
|
|
79
|
+
` ${host === "exe" ? "bash scripts/eve-server.sh" : "kyb deploy"}`));
|
|
80
|
+
}
|
|
81
|
+
/** The agent's own name, as the rest of the toolchain reads it. */
|
|
82
|
+
function agentNameOf(dir) {
|
|
83
|
+
const env = join(dir, ".env.local");
|
|
84
|
+
if (existsSync(env)) {
|
|
85
|
+
const hit = readFileSync(env, "utf8").match(/^KYBERNESIS_AGENT\s*=\s*"?([^"\n]+)"?/m);
|
|
86
|
+
if (hit?.[1])
|
|
87
|
+
return hit[1].trim();
|
|
88
|
+
}
|
|
89
|
+
return basename(dir);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Append the channel's variables, once.
|
|
93
|
+
*
|
|
94
|
+
* @remarks
|
|
95
|
+
* Appended rather than rewritten so a hand-edited example file survives, and
|
|
96
|
+
* skipped when the key is already present so running the command twice does not
|
|
97
|
+
* leave two copies of every variable for someone to reconcile later.
|
|
98
|
+
*/
|
|
99
|
+
function appendEnvExample(dir, kind, lines) {
|
|
100
|
+
const path = join(dir, ".env.example");
|
|
101
|
+
const existing = existsSync(path) ? readFileSync(path, "utf8") : "";
|
|
102
|
+
const fresh = lines.filter((line) => {
|
|
103
|
+
const key = line.split("=")[0]?.trim();
|
|
104
|
+
return key ? !new RegExp(`^${key}\\s*=`, "m").test(existing) : true;
|
|
105
|
+
});
|
|
106
|
+
if (!fresh.length)
|
|
107
|
+
return 0;
|
|
108
|
+
writeFileSync(path, `${existing.replace(/\n*$/, "\n")}\n# ${kind}\n${fresh.join("\n")}\n`);
|
|
109
|
+
return fresh.length;
|
|
110
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import { existsSync, readFileSync } from "node:fs";
|
|
|
16
16
|
import { basename, dirname, join } from "node:path";
|
|
17
17
|
import { fileURLToPath } from "node:url";
|
|
18
18
|
import { bold, dim, red } from "./util.js";
|
|
19
|
+
import { add } from "./add.js";
|
|
19
20
|
import { init } from "./init.js";
|
|
20
21
|
import { doctor } from "./doctor.js";
|
|
21
22
|
import { upgrade } from "./upgrade.js";
|
|
@@ -65,6 +66,7 @@ function initOptions(rest) {
|
|
|
65
66
|
/** What each command is for, in one line, as a person would ask for it. */
|
|
66
67
|
const COMMANDS = {
|
|
67
68
|
init: "Scaffold a new agent: governed, remembering, multiplayer, self-testing.",
|
|
69
|
+
add: "Add a chat surface to an agent that already exists.",
|
|
68
70
|
doctor: "Check this machine and this project before an engagement.",
|
|
69
71
|
arcana: "Set the memory workspaces and keys this agent uses.",
|
|
70
72
|
skills: "Install the FDE skill suite (--global for every project).",
|
|
@@ -111,6 +113,9 @@ switch (command) {
|
|
|
111
113
|
case "init":
|
|
112
114
|
await init(rest.find((a) => !a.startsWith("-")), initOptions(rest));
|
|
113
115
|
break;
|
|
116
|
+
case "add":
|
|
117
|
+
await add(rest.find((a) => !a.startsWith("-")), rest.slice(1));
|
|
118
|
+
break;
|
|
114
119
|
case "doctor":
|
|
115
120
|
await doctor();
|
|
116
121
|
break;
|
|
@@ -187,6 +192,8 @@ ${dim(" npm i -g @kybernesis/create@latest")}
|
|
|
187
192
|
--engineer ${dim("add the engineer layer: workshop sandbox + vision dev loop")}
|
|
188
193
|
--studio ${dim("wire for KYBER Studio: local execution + management routes")}
|
|
189
194
|
--yes ${dim("no prompts; take flags and defaults")}
|
|
195
|
+
${bold("kyb add channel <kind>")}
|
|
196
|
+
${dim("slack|imessage|telegram|discord|web — writes the channel, deps and env")}
|
|
190
197
|
${bold("kyb doctor")} preflight checks (keys, issuer, envs, discovery)
|
|
191
198
|
${bold("kyb skills")} install/refresh the FDE skill suite for Claude Code
|
|
192
199
|
--global ${dim("install to ~/.claude/skills instead of this repo")}
|
package/dist/templates.js
CHANGED
|
@@ -85,10 +85,20 @@ export default defineMcpClientConnection({
|
|
|
85
85
|
"The ${dept} team's long-term memory (Arcana): remember, recall, search, timeline, and brain notes.",
|
|
86
86
|
auth: {
|
|
87
87
|
getToken: async () => {
|
|
88
|
+
// The eval brain is a DIFFERENT workspace, so it needs its own key —
|
|
89
|
+
// Arcana keys answer 403 outside the workspace they were minted for.
|
|
90
|
+
// Recognised by name rather than by suffix: an eval workspace does not
|
|
91
|
+
// have to be called "<agent>-eval", and matching on the suffix sends a
|
|
92
|
+
// custom one through the company key, where every memory eval fails with
|
|
93
|
+
// a 403 that reads as the agent's memory being broken.
|
|
94
|
+
// Falls back to the old suffix rule when nothing names the eval brain, so
|
|
95
|
+
// an agent written before this variable existed keeps working untouched.
|
|
96
|
+
const evalWorkspace = process.env.ARCANA_EVAL_WORKSPACE;
|
|
97
|
+
const isEval = evalWorkspace
|
|
98
|
+
? workspace === evalWorkspace
|
|
99
|
+
: workspace.endsWith("-eval");
|
|
88
100
|
const token =
|
|
89
|
-
(
|
|
90
|
-
? process.env.ARCANA_EVAL_API_KEY
|
|
91
|
-
: undefined) ??
|
|
101
|
+
(isEval ? process.env.ARCANA_EVAL_API_KEY : undefined) ??
|
|
92
102
|
process.env.ARCANA_${upper}_API_KEY ??
|
|
93
103
|
process.env.ARCANA_API_KEY;
|
|
94
104
|
if (!token) throw new Error("ARCANA_${upper}_API_KEY is not set.");
|
|
@@ -117,9 +127,16 @@ if (!COMPANY) {
|
|
|
117
127
|
}
|
|
118
128
|
const DM = process.env.ARCANA_DM_WORKSPACE ?? COMPANY;
|
|
119
129
|
|
|
130
|
+
// Same rule as the department connections: the eval brain is named, not
|
|
131
|
+
// guessed from a suffix.
|
|
132
|
+
// Falls back to the old suffix rule when nothing names the eval brain, so an
|
|
133
|
+
// agent written before this variable existed keeps working untouched.
|
|
134
|
+
const EVAL = process.env.ARCANA_EVAL_WORKSPACE;
|
|
135
|
+
const IS_EVAL = EVAL ? COMPANY === EVAL : COMPANY.endsWith("-eval");
|
|
136
|
+
|
|
120
137
|
export default arcana({
|
|
121
138
|
apiKey:
|
|
122
|
-
(
|
|
139
|
+
(IS_EVAL ? process.env.ARCANA_EVAL_API_KEY : undefined) ??
|
|
123
140
|
process.env.ARCANA_API_KEY!,
|
|
124
141
|
workspace: COMPANY,
|
|
125
142
|
// DM sessions carry surface:"dm" via @kybernesis/multiplayer.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/create",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.3",
|
|
4
4
|
"description": "The Kybernesis agent scaffolder and FDE toolkit: one command to a governed, remembering, multiplayer, self-testing eve agent — plus doctor and upgrade.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|