@netnodeag/kraftwerk 0.10.2 → 0.12.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/README.md +21 -0
- package/dist/cli/init.js +16 -0
- package/dist/config.d.ts +3 -0
- package/dist/config.js +3 -2
- package/dist/inspector/chat/sessions.js +25 -7
- package/dist/inspector/server.js +9 -3
- package/dist/inspector/skills.d.ts +22 -8
- package/dist/inspector/skills.js +40 -4
- package/inspector/dist/assets/index-BIoC3aBd.js +80 -0
- package/inspector/dist/assets/{index-_Ppo4YH9.css → index-BMT3xv2t.css} +1 -1
- package/inspector/dist/index.html +2 -2
- package/package.json +1 -1
- package/schema/kraftwerk.schema.json +4 -0
- package/inspector/dist/assets/index-ClBNh2Ks.js +0 -80
package/README.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# kraftwerk
|
|
2
2
|
|
|
3
|
+
**Agentic workspace.** Kraftwerk is an open-source agentic workspace for
|
|
4
|
+
teams. It is where people and AI agents get work done together.
|
|
5
|
+
|
|
6
|
+
**Why it exists.** AI work often lives in individual silos: personal prompts,
|
|
7
|
+
Claude Code sessions, scripts, and one-off automations. Kraftwerk turns that
|
|
8
|
+
into shared, repeatable ways of working across a team or organisation.
|
|
9
|
+
|
|
10
|
+
**How it works.** Kraftwerk brings together:
|
|
11
|
+
|
|
12
|
+
- **Agents** — Claude Code, Codex, Pi, and others
|
|
13
|
+
- **Skills** — reusable capabilities and ways of working
|
|
14
|
+
- **Knowledge** — shared organisational and project context
|
|
15
|
+
- **Workflows** — repeatable multi-step processes
|
|
16
|
+
- **Verification** — deterministic gates that check the work
|
|
17
|
+
|
|
18
|
+
**The shift.** From everyone using AI individually → to the organisation
|
|
19
|
+
working agentically. Kraftwerk is the shared place where that work lives,
|
|
20
|
+
runs, and improves over time.
|
|
21
|
+
|
|
22
|
+
## Under the hood
|
|
23
|
+
|
|
3
24
|
Deterministic workflow-as-code over headless agent harnesses, in the spirit of
|
|
4
25
|
[super-simple-software-factory](https://github.com/disler/super-simple-software-factory):
|
|
5
26
|
**code owns the control flow, agents work inside bounded phases.**
|
package/dist/cli/init.js
CHANGED
|
@@ -21,6 +21,7 @@ workflows: ${DATA_DIR}/workflows # where workflows live
|
|
|
21
21
|
output: ${DATA_DIR}/output # where run artifacts land (git-ignored)
|
|
22
22
|
knowledge: ${DATA_DIR}/knowledge # OKF knowledge bundles
|
|
23
23
|
agents: ${DATA_DIR}/agents # team agent definitions
|
|
24
|
+
skills: ${DATA_DIR}/skills # workspace skills (shared instruction packages)
|
|
24
25
|
`;
|
|
25
26
|
const WORKFLOW_TEMPLATE = `# yaml-language-server: $schema=${SCHEMA_URL}
|
|
26
27
|
name: hello
|
|
@@ -62,6 +63,19 @@ const AGENT_SYSTEM_TEMPLATE = `You are Max, this project's workflow runner. You
|
|
|
62
63
|
project's kraftwerk workflows, and you consult the knowledge bundles you
|
|
63
64
|
have access to before answering questions they cover.
|
|
64
65
|
`;
|
|
66
|
+
const SKILL_TEMPLATE = `---
|
|
67
|
+
name: daily-summary
|
|
68
|
+
description: Summarize what happened in this workspace today (runs, knowledge updates)
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
# Daily summary
|
|
72
|
+
|
|
73
|
+
When invoked, produce a short summary of today's activity in this workspace:
|
|
74
|
+
|
|
75
|
+
1. List today's workflow runs and their status.
|
|
76
|
+
2. Mention knowledge concepts updated today, if any.
|
|
77
|
+
3. Keep it under 10 lines, plain markdown.
|
|
78
|
+
`;
|
|
65
79
|
const DEMO_BUNDLE = "demo-customer-support";
|
|
66
80
|
const DEMO_CONCEPT = `---
|
|
67
81
|
type: Playbook
|
|
@@ -96,6 +110,8 @@ export async function runInit(cwd) {
|
|
|
96
110
|
// Team agent "max".
|
|
97
111
|
await put(`${DATA_DIR}/agents/max/agent.yml`, AGENT_YML_TEMPLATE);
|
|
98
112
|
await put(`${DATA_DIR}/agents/max/system.md`, AGENT_SYSTEM_TEMPLATE);
|
|
113
|
+
// Example workspace skill.
|
|
114
|
+
await put(`${DATA_DIR}/skills/daily-summary/SKILL.md`, SKILL_TEMPLATE);
|
|
99
115
|
// Demo knowledge bundle, through the canonical OKF write path so
|
|
100
116
|
// index.md and log.md come out consistent.
|
|
101
117
|
const knowledgeRoot = path.join(cwd, DATA_DIR, "knowledge");
|
package/dist/config.d.ts
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* output: output # run-artifact directory, relative to the file
|
|
17
17
|
* knowledge: knowledge # OKF knowledge-bundle root, relative to the file
|
|
18
18
|
* agents: agents # team agent-definition root, relative to the file
|
|
19
|
+
* skills: skills # workspace skill root, relative to the file
|
|
19
20
|
*/
|
|
20
21
|
/** Stable, versionless URL of the workflow JSON schema (editor validation). */
|
|
21
22
|
export declare const SCHEMA_URL = "https://raw.githubusercontent.com/NETNODEAG/kraftwerk/main/kraftwerk/schema/workflow.schema.json";
|
|
@@ -37,6 +38,8 @@ export interface ProjectConfig {
|
|
|
37
38
|
knowledge?: string;
|
|
38
39
|
/** Team agent-definition root relative to the project root. Default: agents */
|
|
39
40
|
agents?: string;
|
|
41
|
+
/** Workspace skill root relative to the project root. Default: skills */
|
|
42
|
+
skills?: string;
|
|
40
43
|
}
|
|
41
44
|
export interface Project {
|
|
42
45
|
/** Absolute project root the CLI operates on. */
|
package/dist/config.js
CHANGED
|
@@ -19,6 +19,7 @@ import { parse } from "yaml";
|
|
|
19
19
|
* output: output # run-artifact directory, relative to the file
|
|
20
20
|
* knowledge: knowledge # OKF knowledge-bundle root, relative to the file
|
|
21
21
|
* agents: agents # team agent-definition root, relative to the file
|
|
22
|
+
* skills: skills # workspace skill root, relative to the file
|
|
22
23
|
*/
|
|
23
24
|
/** Stable, versionless URL of the workflow JSON schema (editor validation). */
|
|
24
25
|
export const SCHEMA_URL = "https://raw.githubusercontent.com/NETNODEAG/kraftwerk/main/kraftwerk/schema/workflow.schema.json";
|
|
@@ -88,10 +89,10 @@ async function loadConfig(configPath) {
|
|
|
88
89
|
if (raw === null || raw === undefined)
|
|
89
90
|
return {};
|
|
90
91
|
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
91
|
-
throw new Error(`${path.basename(configPath)}: expected a mapping (name, icon, port, workflows, output, knowledge, agents)`);
|
|
92
|
+
throw new Error(`${path.basename(configPath)}: expected a mapping (name, icon, port, workflows, output, knowledge, agents, skills)`);
|
|
92
93
|
}
|
|
93
94
|
const config = raw;
|
|
94
|
-
const known = ["name", "icon", "port", "workflows", "output", "knowledge", "agents"];
|
|
95
|
+
const known = ["name", "icon", "port", "workflows", "output", "knowledge", "agents", "skills"];
|
|
95
96
|
for (const key of Object.keys(config)) {
|
|
96
97
|
if (!known.includes(key)) {
|
|
97
98
|
throw new Error(`${path.basename(configPath)}: unknown key "${key}" (allowed: ${known.join(", ")})`);
|
|
@@ -25,6 +25,7 @@ async function loadState(id) {
|
|
|
25
25
|
busy: false,
|
|
26
26
|
pendingPermissions: new Map(),
|
|
27
27
|
writeChain: Promise.resolve(),
|
|
28
|
+
needsContext: true,
|
|
28
29
|
};
|
|
29
30
|
// Two racing loads: keep whichever registered first.
|
|
30
31
|
return states.get(id) ?? (states.set(id, state), state);
|
|
@@ -46,8 +47,8 @@ function emit(state, ev) {
|
|
|
46
47
|
}
|
|
47
48
|
/* ---------- skills ---------- */
|
|
48
49
|
/**
|
|
49
|
-
* Skills visible to a chat: every discovered skill (
|
|
50
|
-
* .claude/skills), narrowed by the team member's allowlist when the chat
|
|
50
|
+
* Skills visible to a chat: every discovered skill (workspace skills root
|
|
51
|
+
* + .claude/skills roots), narrowed by the team member's allowlist when the chat
|
|
51
52
|
* is a team session (absent allowlist = all, empty = none).
|
|
52
53
|
*/
|
|
53
54
|
async function availableSkills(scope) {
|
|
@@ -211,15 +212,25 @@ async function baseScopeContext(scope, agent) {
|
|
|
211
212
|
}
|
|
212
213
|
return "";
|
|
213
214
|
}
|
|
215
|
+
/**
|
|
216
|
+
* Every chat renders in the inspector UI, so agents should know two things:
|
|
217
|
+
* replies are markdown, and run artifacts are addressable over the
|
|
218
|
+
* inspector's own file endpoint (relative URLs keep working wherever the
|
|
219
|
+
* inspector is reachable — localhost, LAN, tunnel).
|
|
220
|
+
*/
|
|
221
|
+
const RENDERING_BLOCK = `## Chat rendering\n` +
|
|
222
|
+
`Your replies render as markdown in the inspector chat: headings, lists, tables, code blocks, ` +
|
|
223
|
+
`links and images all work. Files inside a workflow run's output folder are served by the ` +
|
|
224
|
+
`inspector itself at /api/runs/<run-id>/file?name=<relative-path>&raw=1 — embed an image inline ` +
|
|
225
|
+
`with , or link any artifact the same way. ` +
|
|
226
|
+
`Prefer these relative /api/... URLs over file paths when showing results: they render directly ` +
|
|
227
|
+
`in this chat and keep working wherever the inspector is reachable.`;
|
|
214
228
|
async function scopeContext(scope, agent) {
|
|
215
229
|
const [base, skills] = await Promise.all([
|
|
216
230
|
baseScopeContext(scope, agent),
|
|
217
231
|
availableSkills(scope),
|
|
218
232
|
]);
|
|
219
|
-
|
|
220
|
-
if (!block)
|
|
221
|
-
return base;
|
|
222
|
-
return base ? `${base}\n\n${block}` : block;
|
|
233
|
+
return [base, RENDERING_BLOCK, skillsBlock(skills)].filter(Boolean).join("\n\n");
|
|
223
234
|
}
|
|
224
235
|
/* ---------- backend lifecycle ---------- */
|
|
225
236
|
/** Team chats carry the member's model/effort; resolved live so edits apply to new backends. */
|
|
@@ -280,6 +291,9 @@ async function ensureBackend(state) {
|
|
|
280
291
|
agent === "pi"
|
|
281
292
|
? startPiBackend(cwd, hooks, tuning)
|
|
282
293
|
: await startAcpBackend(agent, cwd, hooks, tuning);
|
|
294
|
+
// Fresh process = fresh context window: re-send scope context with the
|
|
295
|
+
// next prompt (matters for chats resumed after an inspector restart).
|
|
296
|
+
state.needsContext = true;
|
|
283
297
|
return state.backend;
|
|
284
298
|
}
|
|
285
299
|
/* ---------- public API (used by server.ts) ---------- */
|
|
@@ -304,6 +318,7 @@ export async function createChat(opts) {
|
|
|
304
318
|
busy: false,
|
|
305
319
|
pendingPermissions: new Map(),
|
|
306
320
|
writeChain: Promise.resolve(),
|
|
321
|
+
needsContext: true,
|
|
307
322
|
});
|
|
308
323
|
return meta;
|
|
309
324
|
}
|
|
@@ -338,7 +353,10 @@ export async function postMessage(id, text) {
|
|
|
338
353
|
void (async () => {
|
|
339
354
|
try {
|
|
340
355
|
const backend = await ensureBackend(state);
|
|
341
|
-
const context =
|
|
356
|
+
const context = state.needsContext
|
|
357
|
+
? await scopeContext(state.meta.scope, state.meta.agent)
|
|
358
|
+
: "";
|
|
359
|
+
state.needsContext = false;
|
|
342
360
|
// "/<skill> args" expands to the skill's instructions for the agent;
|
|
343
361
|
// the thread keeps the short form the user typed.
|
|
344
362
|
const body = await expandSkillInvocation(state.meta.scope, text);
|
package/dist/inspector/server.js
CHANGED
|
@@ -9,7 +9,7 @@ import { dockerStatus, triggerRun, stopRun } from "./runner.js";
|
|
|
9
9
|
import { cancelChat, createChat, deleteChat, getChat, listChats, postMessage, resolvePermission, subscribeChat, } from "./chat/sessions.js";
|
|
10
10
|
import { bundleDetail, conceptDetail, createBundle, knowledgeIndex, putConcept, verifyFromUi, } from "./knowledge.js";
|
|
11
11
|
import { deleteMember, getMember, listMembers, saveMember, teamRoot, } from "./team.js";
|
|
12
|
-
import { listSkills } from "./skills.js";
|
|
12
|
+
import { getSkill, listSkills, skillsRoot } from "./skills.js";
|
|
13
13
|
import { deleteRoutine, routineStatuses, runRoutineNow, saveRoutine, startRoutineScheduler, } from "./routines.js";
|
|
14
14
|
/**
|
|
15
15
|
* The inspector server: a plain node:http server with no dependencies.
|
|
@@ -249,9 +249,15 @@ async function handleApi(req, res, url) {
|
|
|
249
249
|
return json(res, { error: err.message }, 400);
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
// GET /api/skills — discovered skills (
|
|
252
|
+
// GET /api/skills — discovered skills (workspace root + .claude/skills + ~/.claude/skills)
|
|
253
253
|
if (seg.length === 2 && seg[1] === "skills" && method === "GET") {
|
|
254
|
-
|
|
254
|
+
const [root, skills] = await Promise.all([skillsRoot(), listSkills()]);
|
|
255
|
+
return json(res, { root, skills });
|
|
256
|
+
}
|
|
257
|
+
// GET /api/skills/:name — one skill with SKILL.md content + bundled files
|
|
258
|
+
if (seg.length === 3 && seg[1] === "skills" && method === "GET") {
|
|
259
|
+
const skill = await getSkill(decodeURIComponent(seg[2]));
|
|
260
|
+
return skill ? json(res, skill) : json(res, { error: "not found" }, 404);
|
|
255
261
|
}
|
|
256
262
|
// GET/POST /api/team — member list / create a member
|
|
257
263
|
if (seg.length === 2 && seg[1] === "team") {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Skills: reusable instruction packages for chats, discovered from the
|
|
3
3
|
* Claude-style skill layout — one folder per skill holding a SKILL.md with
|
|
4
|
-
* YAML frontmatter (name, description).
|
|
4
|
+
* YAML frontmatter (name, description). Three roots are scanned:
|
|
5
5
|
*
|
|
6
|
-
* <projectRoot
|
|
7
|
-
*
|
|
6
|
+
* <projectRoot>/<skills root>/<name>/SKILL.md (workspace, git-tracked;
|
|
7
|
+
* kraftwerk.yml `skills`, default skills/)
|
|
8
|
+
* <projectRoot>/.claude/skills/<name>/SKILL.md (project .claude, git-tracked)
|
|
9
|
+
* ~/.claude/skills/<name>/SKILL.md (global, this machine only)
|
|
8
10
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* Workspace skills are the shared, first-class ones; a workspace skill
|
|
12
|
+
* shadows a same-named project skill, which shadows a same-named global
|
|
13
|
+
* skill. Skills are surfaced to every chat as context (and expanded on
|
|
14
|
+
* /<name> invocation), so they work identically on claude, codex, and pi.
|
|
12
15
|
*/
|
|
13
16
|
export interface SkillInfo {
|
|
14
17
|
/** Frontmatter `name`, falling back to the folder name. */
|
|
@@ -18,9 +21,20 @@ export interface SkillInfo {
|
|
|
18
21
|
path: string;
|
|
19
22
|
/** Absolute path to the skill folder (for harnesses that take a dir). */
|
|
20
23
|
dir: string;
|
|
21
|
-
|
|
24
|
+
/** workspace = kraftwerk skills root; project = .claude/skills; user = ~/.claude/skills. */
|
|
25
|
+
source: "workspace" | "project" | "user";
|
|
22
26
|
}
|
|
23
|
-
|
|
27
|
+
export interface SkillDetail extends SkillInfo {
|
|
28
|
+
/** Full SKILL.md contents. */
|
|
29
|
+
content: string;
|
|
30
|
+
/** Non-SKILL.md files bundled in the skill folder (relative paths). */
|
|
31
|
+
files: string[];
|
|
32
|
+
}
|
|
33
|
+
/** Absolute workspace skills root (kraftwerk.yml `skills`, default skills/). */
|
|
34
|
+
export declare function skillsRoot(): Promise<string>;
|
|
35
|
+
/** All discovered skills; workspace shadows project shadows user (global). */
|
|
24
36
|
export declare function listSkills(): Promise<SkillInfo[]>;
|
|
25
37
|
/** Read a skill's SKILL.md contents (empty string when unreadable). */
|
|
26
38
|
export declare function readSkill(skill: SkillInfo): Promise<string>;
|
|
39
|
+
/** One skill by name (post-shadowing), with SKILL.md content + bundled files. */
|
|
40
|
+
export declare function getSkill(name: string): Promise<SkillDetail | null>;
|
package/dist/inspector/skills.js
CHANGED
|
@@ -2,6 +2,7 @@ import { promises as fs } from "node:fs";
|
|
|
2
2
|
import os from "node:os";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { parse } from "yaml";
|
|
5
|
+
import { resolveProject } from "../config.js";
|
|
5
6
|
import { getProjectRoot } from "./context.js";
|
|
6
7
|
const NAME_RE = /^[a-z0-9][a-z0-9_-]{0,63}$/i;
|
|
7
8
|
function frontmatter(md) {
|
|
@@ -16,6 +17,12 @@ function frontmatter(md) {
|
|
|
16
17
|
return {};
|
|
17
18
|
}
|
|
18
19
|
}
|
|
20
|
+
/** Absolute workspace skills root (kraftwerk.yml `skills`, default skills/). */
|
|
21
|
+
export async function skillsRoot() {
|
|
22
|
+
const project = await resolveProject(getProjectRoot()).catch(() => null);
|
|
23
|
+
const root = project?.root ?? getProjectRoot();
|
|
24
|
+
return path.resolve(root, project?.config.skills ?? "skills");
|
|
25
|
+
}
|
|
19
26
|
async function scanRoot(root, source) {
|
|
20
27
|
let entries;
|
|
21
28
|
try {
|
|
@@ -50,16 +57,45 @@ async function scanRoot(root, source) {
|
|
|
50
57
|
}));
|
|
51
58
|
return skills.filter(Boolean).sort((a, b) => a.name.localeCompare(b.name));
|
|
52
59
|
}
|
|
53
|
-
/** All discovered skills;
|
|
60
|
+
/** All discovered skills; workspace shadows project shadows user (global). */
|
|
54
61
|
export async function listSkills() {
|
|
55
|
-
const [project, user] = await Promise.all([
|
|
62
|
+
const [workspace, project, user] = await Promise.all([
|
|
63
|
+
skillsRoot().then((root) => scanRoot(root, "workspace")),
|
|
56
64
|
scanRoot(path.join(getProjectRoot(), ".claude", "skills"), "project"),
|
|
57
65
|
scanRoot(path.join(os.homedir(), ".claude", "skills"), "user"),
|
|
58
66
|
]);
|
|
59
|
-
const
|
|
60
|
-
|
|
67
|
+
const out = [...workspace];
|
|
68
|
+
const seen = new Set(out.map((s) => s.name.toLowerCase()));
|
|
69
|
+
for (const s of [...project, ...user]) {
|
|
70
|
+
if (seen.has(s.name.toLowerCase()))
|
|
71
|
+
continue;
|
|
72
|
+
seen.add(s.name.toLowerCase());
|
|
73
|
+
out.push(s);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
61
76
|
}
|
|
62
77
|
/** Read a skill's SKILL.md contents (empty string when unreadable). */
|
|
63
78
|
export function readSkill(skill) {
|
|
64
79
|
return fs.readFile(skill.path, "utf8").catch(() => "");
|
|
65
80
|
}
|
|
81
|
+
/** One skill by name (post-shadowing), with SKILL.md content + bundled files. */
|
|
82
|
+
export async function getSkill(name) {
|
|
83
|
+
const skill = (await listSkills()).find((s) => s.name.toLowerCase() === name.toLowerCase());
|
|
84
|
+
if (!skill)
|
|
85
|
+
return null;
|
|
86
|
+
const content = await readSkill(skill);
|
|
87
|
+
const files = [];
|
|
88
|
+
const walk = async (dir, rel) => {
|
|
89
|
+
const entries = await fs.readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
90
|
+
for (const e of entries) {
|
|
91
|
+
if (e.name.startsWith("."))
|
|
92
|
+
continue;
|
|
93
|
+
if (e.isDirectory())
|
|
94
|
+
await walk(path.join(dir, e.name), `${rel}${e.name}/`);
|
|
95
|
+
else if (`${rel}${e.name}` !== "SKILL.md")
|
|
96
|
+
files.push(`${rel}${e.name}`);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
await walk(skill.dir, "");
|
|
100
|
+
return { ...skill, content, files: files.sort() };
|
|
101
|
+
}
|