@kevin5251984/guild 0.2.12

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.
Files changed (70) hide show
  1. package/LICENSE +21 -0
  2. package/bin/guildd.mjs +20 -0
  3. package/cordis.yml +24 -0
  4. package/package.json +52 -0
  5. package/src/agent-file.ts +125 -0
  6. package/src/browser.ts +668 -0
  7. package/src/catalog/default-bots.ts +263 -0
  8. package/src/catalog/skills.ts +128 -0
  9. package/src/catalog/subagents.ts +70 -0
  10. package/src/chat-parts.ts +71 -0
  11. package/src/cli-args.ts +75 -0
  12. package/src/cli.ts +60 -0
  13. package/src/compact.ts +355 -0
  14. package/src/cordis.d.ts +40 -0
  15. package/src/db.ts +653 -0
  16. package/src/generate.ts +673 -0
  17. package/src/handlers.ts +1623 -0
  18. package/src/harness.ts +326 -0
  19. package/src/host-agents.ts +137 -0
  20. package/src/host-browse.ts +199 -0
  21. package/src/host-skills.ts +150 -0
  22. package/src/image-gen.ts +270 -0
  23. package/src/index.ts +12 -0
  24. package/src/llm.ts +993 -0
  25. package/src/mcp.ts +563 -0
  26. package/src/memory.ts +159 -0
  27. package/src/mention.ts +176 -0
  28. package/src/oauth.ts +1474 -0
  29. package/src/plugins/api.ts +8 -0
  30. package/src/plugins/chat.ts +31 -0
  31. package/src/plugins/harness.ts +77 -0
  32. package/src/plugins/llm.ts +50 -0
  33. package/src/plugins/mcp.ts +58 -0
  34. package/src/plugins/memory.ts +42 -0
  35. package/src/plugins/oauth.ts +47 -0
  36. package/src/plugins/server.ts +126 -0
  37. package/src/plugins/store.ts +29 -0
  38. package/src/plugins/tools.ts +79 -0
  39. package/src/public/buddy.js +432 -0
  40. package/src/public/chat.css +3045 -0
  41. package/src/public/chat.html +5834 -0
  42. package/src/public/favicon-16.png +0 -0
  43. package/src/public/favicon-16.svg +10 -0
  44. package/src/public/favicon-32.png +0 -0
  45. package/src/public/favicon.ico +0 -0
  46. package/src/public/favicon.svg +13 -0
  47. package/src/public/i18n.js +663 -0
  48. package/src/public/index.html +143 -0
  49. package/src/public/library.html +678 -0
  50. package/src/public/mcp-add.html +126 -0
  51. package/src/public/md.js +332 -0
  52. package/src/public/rpg/inn-street.jpg +0 -0
  53. package/src/public/settings.html +795 -0
  54. package/src/public/skills-add.html +212 -0
  55. package/src/public/studio.html +1181 -0
  56. package/src/public/style.css +1678 -0
  57. package/src/public/subagents-add.html +152 -0
  58. package/src/router.ts +978 -0
  59. package/src/send-budget.ts +52 -0
  60. package/src/server.ts +1 -0
  61. package/src/skill-import.ts +250 -0
  62. package/src/slash.ts +15 -0
  63. package/src/start.ts +103 -0
  64. package/src/store.ts +1208 -0
  65. package/src/subagent.ts +355 -0
  66. package/src/tools.ts +818 -0
  67. package/src/trajectory.ts +339 -0
  68. package/src/usage.ts +111 -0
  69. package/vendor/protocol/package.json +19 -0
  70. package/vendor/protocol/src/index.ts +159 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Guild contributors
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/bin/guildd.mjs ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ import { spawn } from "node:child_process";
3
+ import { createRequire } from "node:module";
4
+ import { fileURLToPath } from "node:url";
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const loader = require.resolve("tsx");
8
+ const cli = fileURLToPath(new URL("../src/cli.ts", import.meta.url));
9
+ const child = spawn(
10
+ process.execPath,
11
+ ["--import", loader, cli, ...process.argv.slice(2)],
12
+ { stdio: "inherit" },
13
+ );
14
+ child.on("exit", (code, signal) => {
15
+ if (signal) {
16
+ process.kill(process.pid, signal);
17
+ return;
18
+ }
19
+ process.exit(code ?? 1);
20
+ });
package/cordis.yml ADDED
@@ -0,0 +1,24 @@
1
+ - id: logger
2
+ name: '@cordisjs/plugin-logger-console'
3
+ - id: timer
4
+ name: '@cordisjs/plugin-timer'
5
+ - id: store
6
+ name: './src/plugins/store.ts'
7
+ - id: harness
8
+ name: './src/plugins/harness.ts'
9
+ - id: oauth
10
+ name: './src/plugins/oauth.ts'
11
+ - id: llm
12
+ name: './src/plugins/llm.ts'
13
+ - id: tools
14
+ name: './src/plugins/tools.ts'
15
+ - id: mcp
16
+ name: './src/plugins/mcp.ts'
17
+ - id: memory
18
+ name: './src/plugins/memory.ts'
19
+ - id: chat
20
+ name: './src/plugins/chat.ts'
21
+ - id: server
22
+ name: './src/plugins/server.ts'
23
+ - id: api
24
+ name: './src/plugins/api.ts'
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@kevin5251984/guild",
3
+ "version": "0.2.12",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "description": "A local guild of adventurers. npx @kevin5251984/guild web",
7
+ "engines": {
8
+ "node": ">=22.19.0"
9
+ },
10
+ "bin": {
11
+ "guild": "./bin/guildd.mjs",
12
+ "guildd": "./bin/guildd.mjs"
13
+ },
14
+ "files": [
15
+ "bin",
16
+ "src",
17
+ "cordis.yml",
18
+ "vendor"
19
+ ],
20
+ "exports": {
21
+ ".": "./src/index.ts"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "https://github.com/Jakevin/guild.git",
26
+ "directory": "packages/daemon"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "dependencies": {
32
+ "@cordisjs/plugin-include": "1.0.4",
33
+ "@cordisjs/plugin-loader": "1.0.0-rc.5",
34
+ "@cordisjs/plugin-logger-console": "1.0.0",
35
+ "@cordisjs/plugin-timer": "1.1.2",
36
+ "@earendil-works/pi-ai": "^0.84.2",
37
+ "@guild/protocol": "file:./vendor/protocol",
38
+ "cordis": "4.0.0-rc.8",
39
+ "schemastery": "^3.18.0",
40
+ "tsx": "4.20.5"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "22.19.19",
44
+ "typescript": "5.9.3"
45
+ },
46
+ "scripts": {
47
+ "dev": "tsx src/cli.ts",
48
+ "start": "node ./bin/guildd.mjs",
49
+ "build": "tsc -p tsconfig.json",
50
+ "test": "tsx --test test/*.test.ts"
51
+ }
52
+ }
@@ -0,0 +1,125 @@
1
+ import { parseSkillMarkdown } from "./skill-import.ts";
2
+
3
+ export type ParsedAgent = {
4
+ name: string;
5
+ description: string;
6
+ instructions: string;
7
+ model?: string;
8
+ reasoning?: string;
9
+ sandboxMode?: string;
10
+ permissionMode?: string;
11
+ readOnly: boolean;
12
+ };
13
+
14
+ const READ_ONLY_NAMES = new Set([
15
+ "explorer",
16
+ "explore",
17
+ "plan",
18
+ "librarian",
19
+ "reviewer",
20
+ "researcher",
21
+ ]);
22
+
23
+ export function parseAgentFile(text: string, fallbackName = "agent"): ParsedAgent {
24
+ const trimmed = String(text || "")
25
+ .replace(/^\uFEFF/, "")
26
+ .trim();
27
+ const parsed = trimmed.startsWith("---")
28
+ ? parseMarkdownAgent(trimmed, fallbackName)
29
+ : parseTomlAgent(trimmed, fallbackName);
30
+ return { ...parsed, readOnly: inferReadOnly(parsed) };
31
+ }
32
+
33
+ export function renderAgentToml(input: {
34
+ name: string;
35
+ description: string;
36
+ instructions: string;
37
+ readOnly?: boolean;
38
+ }): string {
39
+ const name = input.name.trim() || "agent";
40
+ const description = input.description.replace(/\n/g, " ").trim();
41
+ const sandbox = input.readOnly ? 'sandbox_mode = "read-only"\n' : "";
42
+ return (
43
+ `name = "${escapeToml(name)}"\n` +
44
+ `description = "${escapeToml(description)}"\n` +
45
+ sandbox +
46
+ `developer_instructions = """\n${input.instructions.trim()}\n"""\n`
47
+ );
48
+ }
49
+
50
+ function parseMarkdownAgent(text: string, fallbackName: string): Omit<ParsedAgent, "readOnly"> {
51
+ const parsed = parseSkillMarkdown(text, fallbackName);
52
+ const fence = text.replace(/^\uFEFF/, "").match(
53
+ /^---\r?\n([\s\S]*?)\r?\n---/,
54
+ );
55
+ const front = fence ? fence[1] : "";
56
+ return {
57
+ name: parsed.name || fallbackName,
58
+ description: parsed.description || "",
59
+ instructions: parsed.body.trim(),
60
+ permissionMode: yamlBare(front, "permission_mode") || undefined,
61
+ model: yamlBare(front, "model") || undefined,
62
+ reasoning: yamlBare(front, "reasoning_effort") || undefined,
63
+ };
64
+ }
65
+
66
+ function parseTomlAgent(text: string, fallbackName: string): Omit<ParsedAgent, "readOnly"> {
67
+ const instructions =
68
+ tomlString(text, "developer_instructions") ||
69
+ tomlString(text, "instructions");
70
+ return {
71
+ name: tomlString(text, "name") || fallbackName,
72
+ description: tomlString(text, "description"),
73
+ instructions: instructions.trim(),
74
+ model: tomlString(text, "model") || undefined,
75
+ reasoning:
76
+ tomlString(text, "model_reasoning_effort") ||
77
+ tomlString(text, "reasoning_effort") ||
78
+ undefined,
79
+ sandboxMode: tomlString(text, "sandbox_mode") || undefined,
80
+ permissionMode: tomlString(text, "permission_mode") || undefined,
81
+ };
82
+ }
83
+
84
+ export function inferReadOnly(parsed: Omit<ParsedAgent, "readOnly">): boolean {
85
+ const sandbox = (parsed.sandboxMode || "").toLowerCase();
86
+ if (/\bread[-_ ]?only\b/.test(sandbox)) return true;
87
+ if ((parsed.permissionMode || "").toLowerCase() === "plan") return true;
88
+ const name = (parsed.name || "").toLowerCase();
89
+ return READ_ONLY_NAMES.has(name);
90
+ }
91
+
92
+ function yamlBare(front: string, key: string): string {
93
+ const line = front.match(new RegExp(`^${key}:\\s*(.+)$`, "m"));
94
+ if (!line) return "";
95
+ return line[1].trim().replace(/^["']|["']$/g, "");
96
+ }
97
+
98
+ function tomlString(source: string, key: string): string {
99
+ const match = source.match(new RegExp(`(?:^|\\n)${key}\\s*=\\s*`));
100
+ if (!match || match.index === undefined) return "";
101
+ const rest = source.slice(match.index + match[0].length);
102
+ if (rest.startsWith('"""')) {
103
+ const end = rest.indexOf('"""', 3);
104
+ if (end < 0) return rest.slice(3).trim();
105
+ return rest.slice(3, end).replace(/^\n/, "").replace(/\s+$/, "");
106
+ }
107
+ if (rest.startsWith('"')) {
108
+ const quoted = rest.match(/^"((?:\\.|[^"\\])*)"/);
109
+ return quoted ? unquoteToml(quoted[1]) : "";
110
+ }
111
+ if (rest.startsWith("'")) {
112
+ const quoted = rest.match(/^'([^']*)'/);
113
+ return quoted ? quoted[1] : "";
114
+ }
115
+ const bare = rest.match(/^([^\s#\n]+)/);
116
+ return bare ? bare[1] : "";
117
+ }
118
+
119
+ function unquoteToml(value: string): string {
120
+ return value.replace(/\\n/g, "\n").replace(/\\"/g, '"').replace(/\\\\/g, "\\");
121
+ }
122
+
123
+ function escapeToml(value: string): string {
124
+ return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
125
+ }