@keel_flow/adopt 0.2.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/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +103 -0
- package/dist/index.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 jglasskatz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @keel_flow/adopt
|
|
2
|
+
|
|
3
|
+
LLM-driven adoption: given a workspace knowledge base and a prompt, emits a typed `ArchitectureMap`, agent stubs, and a rationale string via `emit_architecture` structured tool_use output through the Keel `ModelProvider` abstraction.
|
|
4
|
+
|
|
5
|
+
Part of the [Keel](https://github.com/jglasskatz/keel) framework.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install @keel_flow/adopt
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { KnowledgeBase } from "@keel_flow/core";
|
|
2
|
+
import type { ArchitectureMap } from "@keel_flow/schema";
|
|
3
|
+
import type { ModelProvider } from "@keel_flow/runtime";
|
|
4
|
+
export interface AgentStub {
|
|
5
|
+
id: string;
|
|
6
|
+
description: string;
|
|
7
|
+
context: string;
|
|
8
|
+
tools: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface AdoptResult {
|
|
11
|
+
architecture: ArchitectureMap;
|
|
12
|
+
agents: AgentStub[];
|
|
13
|
+
rationale: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function adopt({ prompt, kb, provider, }: {
|
|
16
|
+
prompt: string;
|
|
17
|
+
kb: KnowledgeBase;
|
|
18
|
+
provider: ModelProvider;
|
|
19
|
+
}): Promise<AdoptResult>;
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,YAAY,EAAE,eAAe,CAAC;IAC9B,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAyDD,wBAAsB,KAAK,CAAC,EAC1B,MAAM,EACN,EAAE,EACF,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,aAAa,CAAC;IAClB,QAAQ,EAAE,aAAa,CAAC;CACzB,GAAG,OAAO,CAAC,WAAW,CAAC,CAuDvB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ArchitectureMapSchema } from "@keel_flow/schema";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
const AgentStubSchema = z.object({
|
|
4
|
+
id: z.string(),
|
|
5
|
+
description: z.string(),
|
|
6
|
+
context: z.string(),
|
|
7
|
+
tools: z.array(z.string()),
|
|
8
|
+
});
|
|
9
|
+
const AdoptOutputSchema = z.object({
|
|
10
|
+
architecture: ArchitectureMapSchema,
|
|
11
|
+
agents: z.array(AgentStubSchema),
|
|
12
|
+
rationale: z.string(),
|
|
13
|
+
});
|
|
14
|
+
const adoptToolSchema = {
|
|
15
|
+
name: "emit_architecture",
|
|
16
|
+
description: "Emit the architecture map, agent stubs, and rationale for the Keel project",
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: "object",
|
|
19
|
+
properties: {
|
|
20
|
+
architecture: {
|
|
21
|
+
type: "object",
|
|
22
|
+
description: "The ArchitectureMap matching the Keel schema",
|
|
23
|
+
properties: {
|
|
24
|
+
schemaVersion: { type: "string" },
|
|
25
|
+
layers: { type: "array", items: { type: "object" } },
|
|
26
|
+
nodes: { type: "array", items: { type: "object" } },
|
|
27
|
+
connections: { type: "array", items: { type: "object" } },
|
|
28
|
+
contexts: { type: "array", items: { type: "object" } },
|
|
29
|
+
},
|
|
30
|
+
required: ["schemaVersion", "layers", "nodes", "connections", "contexts"],
|
|
31
|
+
},
|
|
32
|
+
agents: {
|
|
33
|
+
type: "array",
|
|
34
|
+
description: "Agent stubs for the project",
|
|
35
|
+
items: {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {
|
|
38
|
+
id: { type: "string" },
|
|
39
|
+
description: { type: "string" },
|
|
40
|
+
context: { type: "string" },
|
|
41
|
+
tools: { type: "array", items: { type: "string" } },
|
|
42
|
+
},
|
|
43
|
+
required: ["id", "description", "context", "tools"],
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
rationale: {
|
|
47
|
+
type: "string",
|
|
48
|
+
description: "Why this architecture was chosen",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
required: ["architecture", "agents", "rationale"],
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
export async function adopt({ prompt, kb, provider, }) {
|
|
55
|
+
const chunks = await kb.retrieve(prompt, 10);
|
|
56
|
+
const kbContext = chunks.length > 0
|
|
57
|
+
? chunks.map((c, i) => `[${i + 1}] (source: ${c.source})\n${c.content}`).join("\n\n")
|
|
58
|
+
: "No KB documents available.";
|
|
59
|
+
const systemPrompt = `You are an expert software architect adopting the Keel framework for a new project.
|
|
60
|
+
|
|
61
|
+
Keel is an opinionated framework for integrating AI into software systems. Every Keel project has:
|
|
62
|
+
- architecture/data.ts: a typed graph of all system nodes (agents, tools, services, datastores)
|
|
63
|
+
- principles/index.ts: a registry of engineering principles checked on every PR
|
|
64
|
+
- A verify gate (keel verify) that runs on every PR as a GitHub Action
|
|
65
|
+
|
|
66
|
+
Keel architecture conventions:
|
|
67
|
+
- Layers: framework, cli, apps, principles, infra, agents, tools, data, ui
|
|
68
|
+
- Nodes: each has id, label, layer, tech, description, keyFiles, keyFunctionality, principles
|
|
69
|
+
- Connections: from/to node ids, type (uses|calls|reads|http|query|tool-call|grounds-on), label
|
|
70
|
+
- Contexts: bounded contexts grouping related nodes by domain
|
|
71
|
+
|
|
72
|
+
A real example from the Keel framework itself:
|
|
73
|
+
- Layer "framework" contains @keel_flow/core and @keel_flow/schema
|
|
74
|
+
- Layer "cli" contains @keel_flow/cli
|
|
75
|
+
- Context "framework-core" groups @keel_flow/core and @keel_flow/schema
|
|
76
|
+
- Connections wire @keel_flow/cli → @keel_flow/core via "uses"
|
|
77
|
+
|
|
78
|
+
You must emit a complete, valid ArchitectureMap using the emit_architecture tool.
|
|
79
|
+
The architecture must be appropriate to the user's domain and informed by their KB content.
|
|
80
|
+
Include at least one thin-slice agent node and at least one tool node.
|
|
81
|
+
Include a "thin-slice" bounded context with the primary agent.`;
|
|
82
|
+
const userMessage = `Project prompt: ${prompt}
|
|
83
|
+
|
|
84
|
+
KB context (top-10 chunks):
|
|
85
|
+
${kbContext}
|
|
86
|
+
|
|
87
|
+
Design a Keel architecture for this project. Emit structured output using the emit_architecture tool.`;
|
|
88
|
+
const response = await provider.generate({
|
|
89
|
+
model: provider.defaultModel,
|
|
90
|
+
system: systemPrompt,
|
|
91
|
+
messages: [{ role: "user", content: [{ type: "text", text: userMessage }] }],
|
|
92
|
+
tools: [adoptToolSchema],
|
|
93
|
+
toolChoice: "any",
|
|
94
|
+
maxTokens: 4096,
|
|
95
|
+
});
|
|
96
|
+
const toolUse = response.content.find((b) => b.type === "tool_use");
|
|
97
|
+
if (!toolUse || toolUse.type !== "tool_use") {
|
|
98
|
+
throw new Error("Model did not return structured output via tool_use");
|
|
99
|
+
}
|
|
100
|
+
const parsed = AdoptOutputSchema.parse(toolUse.input);
|
|
101
|
+
return parsed;
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,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MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,QAAQ,CAAC;QACvC,KAAK,EAAE,QAAQ,CAAC,YAAY;QAC5B,MAAM,EAAE,YAAY;QACpB,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC;QAC5E,KAAK,EAAE,CAAC,eAAe,CAAC;QACxB,UAAU,EAAE,KAAK;QACjB,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IACpE,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@keel_flow/adopt",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"zod": "^3.23.0",
|
|
23
|
+
"@keel_flow/core": "0.2.0",
|
|
24
|
+
"@keel_flow/runtime": "0.2.0",
|
|
25
|
+
"@keel_flow/schema": "0.2.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^25.9.1",
|
|
29
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
31
|
+
"eslint": "^9.0.0",
|
|
32
|
+
"typescript": "^5.5.0",
|
|
33
|
+
"vitest": "^2.0.0"
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsc",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"lint": "eslint src"
|
|
40
|
+
}
|
|
41
|
+
}
|