@riebeckite/ai 0.0.0-stage → 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.
Files changed (38) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +8 -2
  3. package/README_ja.md +9 -0
  4. package/assets/skills/assets/riebeckite-component.md +16 -0
  5. package/assets/skills/assets/riebeckite-configuration.md +13 -0
  6. package/assets/skills/assets/riebeckite-content-migration.md +15 -0
  7. package/assets/skills/assets/riebeckite-deployment.md +15 -0
  8. package/assets/skills/assets/riebeckite-plugin-catalog.md +14 -0
  9. package/assets/skills/assets/riebeckite-plugin.md +16 -0
  10. package/assets/skills/assets/riebeckite-site.md +14 -0
  11. package/assets/skills/assets/riebeckite-theme.md +15 -0
  12. package/assets/skills/assets/riebeckite-troubleshooting.md +15 -0
  13. package/assets/skills/assets/riebeckite-upgrade.md +16 -0
  14. package/assets/skills/references/riebeckite-component.md +124 -0
  15. package/assets/skills/references/riebeckite-configuration.md +96 -0
  16. package/assets/skills/references/riebeckite-content-migration.md +89 -0
  17. package/assets/skills/references/riebeckite-deployment.md +101 -0
  18. package/assets/skills/references/riebeckite-plugin-catalog.md +77 -0
  19. package/assets/skills/references/riebeckite-plugin.md +132 -0
  20. package/assets/skills/references/riebeckite-site.md +111 -0
  21. package/assets/skills/references/riebeckite-theme.md +145 -0
  22. package/assets/skills/references/riebeckite-troubleshooting.md +53 -0
  23. package/assets/skills/references/riebeckite-upgrade.md +71 -0
  24. package/assets/skills/riebeckite-component.md +20 -0
  25. package/assets/skills/riebeckite-configuration.md +19 -0
  26. package/assets/skills/riebeckite-content-migration.md +20 -0
  27. package/assets/skills/riebeckite-deployment.md +20 -0
  28. package/assets/skills/riebeckite-plugin-catalog.md +20 -0
  29. package/assets/skills/riebeckite-plugin.md +21 -0
  30. package/assets/skills/riebeckite-site-external.md +23 -0
  31. package/assets/skills/riebeckite-site.md +22 -0
  32. package/assets/skills/riebeckite-theme.md +19 -0
  33. package/assets/skills/riebeckite-troubleshooting.md +20 -0
  34. package/assets/skills/riebeckite-upgrade.md +20 -0
  35. package/dist/clients.d.ts +17 -0
  36. package/dist/index.d.ts +48 -0
  37. package/dist/index.js +260 -0
  38. package/package.json +52 -3
package/dist/index.js ADDED
@@ -0,0 +1,260 @@
1
+ // index.ts
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import {
4
+ ConfigValidationError
5
+ } from "@riebeckite/core";
6
+
7
+ // clients.ts
8
+ var AI_CLIENTS = ["claude", "cursor", "vscode", "opencode"];
9
+ function aiClientConfigPath(client) {
10
+ switch (client) {
11
+ case "claude":
12
+ return ".mcp.json";
13
+ case "cursor":
14
+ return ".cursor/mcp.json";
15
+ case "vscode":
16
+ return ".vscode/mcp.json";
17
+ case "opencode":
18
+ return "opencode.json";
19
+ }
20
+ }
21
+ function mergeAiClientConfig(client, existing, packageManager = "npm") {
22
+ const path = aiClientConfigPath(client);
23
+ let root = {};
24
+ if (existing !== void 0 && existing.trim() !== "") {
25
+ try {
26
+ const parsed = JSON.parse(existing);
27
+ if (!isRecord(parsed)) {
28
+ return { status: "invalid", path, message: "Expected a JSON object." };
29
+ }
30
+ root = parsed;
31
+ } catch {
32
+ return {
33
+ status: "invalid",
34
+ path,
35
+ message: "Could not parse the existing JSON."
36
+ };
37
+ }
38
+ }
39
+ const key = client === "vscode" ? "servers" : client === "opencode" ? "mcp" : "mcpServers";
40
+ const current = root[key];
41
+ if (current !== void 0 && !isRecord(current)) {
42
+ return {
43
+ status: "invalid",
44
+ path,
45
+ message: `Expected "${key}" to be an object.`
46
+ };
47
+ }
48
+ const servers = isRecord(current) ? current : {};
49
+ if (servers.riebeckite !== void 0) return { status: "unchanged", path };
50
+ root[key] = { ...servers, riebeckite: serverConfig(client, packageManager) };
51
+ return {
52
+ status: "write",
53
+ path,
54
+ content: `${JSON.stringify(root, null, 2)}
55
+ `
56
+ };
57
+ }
58
+ function serverConfig(client, packageManager) {
59
+ const { command, args } = packageManager === "pnpm" ? { command: "pnpm", args: ["exec", "riebeckite", "ai", "mcp"] } : { command: "npm", args: ["exec", "--", "riebeckite", "ai", "mcp"] };
60
+ if (client === "vscode") return { type: "stdio", command, args };
61
+ if (client === "opencode") {
62
+ return { type: "local", command: [command, ...args], enabled: true };
63
+ }
64
+ return { command, args };
65
+ }
66
+ function isRecord(value) {
67
+ return typeof value === "object" && value !== null && !Array.isArray(value);
68
+ }
69
+
70
+ // index.ts
71
+ function defineAiIntegration(config) {
72
+ return config;
73
+ }
74
+ function getAiSetupFiles(context, options = {}, version = "0.0.0") {
75
+ return [
76
+ ...options.rules ? aiRuleFiles(context, options, version) : [],
77
+ ...options.skills ? aiSkillFiles(context, options, version) : []
78
+ ];
79
+ }
80
+ function aiRuleFiles(context, options = {}, version = "0.0.0") {
81
+ const contentDirectory = options.contentDirectory ?? "content";
82
+ const packageManager = options.packageManager ?? "npm";
83
+ const check = `${packageManager} run ${options.lint ? "content:lint" : "check"}`;
84
+ const build = `${packageManager} run build`;
85
+ const guidance = `Content lives under \`${contentDirectory}/\`; run \`${check}\` after content changes and \`${build}\` before publishing.`;
86
+ return [
87
+ {
88
+ path: "RIEBECKITE_AI.md",
89
+ content: `---
90
+ riebeckiteVersion: "${version}"
91
+ ---
92
+ # Riebeckite AI guide
93
+
94
+ ## Scope
95
+
96
+ - Write content only under \`${contentDirectory}/\`.
97
+ - Keep generated output and dependencies unchanged.
98
+ - Use root-relative Markdown links and preserve existing frontmatter keys.
99
+
100
+ ## Validation
101
+
102
+ - Run \`${check}\` after changing content.
103
+ - Run \`${build}\` before publishing.
104
+
105
+ ## Site
106
+
107
+ - Title: ${context.title}
108
+ - Default locale: ${context.locale}
109
+ `
110
+ },
111
+ {
112
+ path: "AGENTS.md",
113
+ content: `# Riebeckite project instructions
114
+
115
+ Read \`RIEBECKITE_AI.md\` before editing. ${guidance}
116
+ `
117
+ },
118
+ {
119
+ path: "CLAUDE.md",
120
+ content: `# Riebeckite project instructions
121
+
122
+ Read \`AGENTS.md\` and \`RIEBECKITE_AI.md\` before editing. ${guidance}
123
+ `
124
+ },
125
+ {
126
+ path: ".github/copilot-instructions.md",
127
+ content: `# Riebeckite project instructions
128
+
129
+ Read \`AGENTS.md\` and \`RIEBECKITE_AI.md\` before editing. ${guidance}
130
+ `
131
+ }
132
+ ];
133
+ }
134
+ var skillNames = [
135
+ "riebeckite-site",
136
+ "riebeckite-plugin-catalog",
137
+ "riebeckite-plugin",
138
+ "riebeckite-component",
139
+ "riebeckite-content-migration",
140
+ "riebeckite-deployment",
141
+ "riebeckite-theme",
142
+ "riebeckite-configuration",
143
+ "riebeckite-troubleshooting",
144
+ "riebeckite-upgrade"
145
+ ];
146
+ var assetRoot = existsSync(new URL("./assets/", import.meta.url)) ? new URL("./assets/", import.meta.url) : new URL("../assets/", import.meta.url);
147
+ function aiSkillFiles(context, options = {}, version = "0.0.0") {
148
+ const contentDirectory = options.contentDirectory ?? "content";
149
+ const render = (asset) => readFileSync(new URL(`skills/${asset}`, assetRoot), "utf8").replaceAll("{{content-directory}}", contentDirectory).replaceAll("{{riebeckite-version}}", version);
150
+ return skillNames.flatMap((name) => [
151
+ {
152
+ path: `.agents/skills/${name}/SKILL.md`,
153
+ content: render(
154
+ `${name}${name === "riebeckite-site" && context.externalContent ? "-external" : ""}.md`
155
+ )
156
+ },
157
+ {
158
+ path: `.agents/skills/${name}/references/guide.md`,
159
+ content: render(`references/${name}.md`)
160
+ },
161
+ {
162
+ path: `.agents/skills/${name}/assets/checklist.md`,
163
+ content: render(`assets/${name}.md`)
164
+ }
165
+ ]);
166
+ }
167
+ function resolveAiIntegration(value) {
168
+ const issues = validateAiIntegration(value);
169
+ if (issues.length > 0) throw new ConfigValidationError(issues);
170
+ const config = value;
171
+ return {
172
+ mutationPolicy: {
173
+ writable: config?.mutationPolicy?.writable ?? ["**"],
174
+ protected: config?.mutationPolicy?.protected ?? []
175
+ }
176
+ };
177
+ }
178
+ function createMutationPathPolicy(policy) {
179
+ return (path) => {
180
+ const normalized = path.replace(/\\/g, "/");
181
+ return !policy.protected.some((pattern) => globMatches(pattern, normalized)) && policy.writable.some((pattern) => globMatches(pattern, normalized));
182
+ };
183
+ }
184
+ function validateAiIntegration(value) {
185
+ const issues = [];
186
+ if (value === void 0) return issues;
187
+ if (!isRecord2(value)) {
188
+ issues.push({
189
+ path: "integrations.ai",
190
+ message: "Expected an object."
191
+ });
192
+ return issues;
193
+ }
194
+ if (value.mutationPolicy === void 0) return issues;
195
+ if (!isRecord2(value.mutationPolicy)) {
196
+ issues.push({
197
+ path: "integrations.ai.mutationPolicy",
198
+ message: "Expected an object."
199
+ });
200
+ return issues;
201
+ }
202
+ validateStringArray(
203
+ value.mutationPolicy.writable,
204
+ "integrations.ai.mutationPolicy.writable",
205
+ issues
206
+ );
207
+ validateStringArray(
208
+ value.mutationPolicy.protected,
209
+ "integrations.ai.mutationPolicy.protected",
210
+ issues
211
+ );
212
+ return issues;
213
+ }
214
+ function validateStringArray(value, path, issues) {
215
+ if (value === void 0) return;
216
+ if (!Array.isArray(value)) {
217
+ issues.push({ path, message: "Expected an array." });
218
+ return;
219
+ }
220
+ for (const [index, item] of value.entries()) {
221
+ if (typeof item !== "string" || !item.trim()) {
222
+ issues.push({
223
+ path: `${path}[${index}]`,
224
+ message: "Expected a non-empty string."
225
+ });
226
+ }
227
+ }
228
+ }
229
+ function globMatches(pattern, value) {
230
+ let expression = "";
231
+ for (let index = 0; index < pattern.length; index++) {
232
+ const character = pattern[index];
233
+ if (character === "*") {
234
+ if (pattern[index + 1] === "*") {
235
+ index++;
236
+ if (pattern[index + 1] === "/") {
237
+ index++;
238
+ expression += "(?:[^/]+/)*";
239
+ } else expression += ".*";
240
+ } else expression += "[^/]*";
241
+ } else if (character === "?") expression += "[^/]";
242
+ else expression += character.replace(/[.+^${}()|[\]\\]/g, "\\$&");
243
+ }
244
+ return new RegExp(`^${expression}$`).test(value);
245
+ }
246
+ function isRecord2(value) {
247
+ return typeof value === "object" && value !== null && !Array.isArray(value);
248
+ }
249
+ export {
250
+ AI_CLIENTS,
251
+ aiClientConfigPath,
252
+ aiRuleFiles,
253
+ aiSkillFiles,
254
+ createMutationPathPolicy,
255
+ defineAiIntegration,
256
+ getAiSetupFiles,
257
+ mergeAiClientConfig,
258
+ resolveAiIntegration,
259
+ validateAiIntegration
260
+ };
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
2
  "name": "@riebeckite/ai",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "license": "Apache-2.0",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "source": "./index.ts",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "LICENSE",
18
+ "README.md",
19
+ "README_ja.md",
20
+ "assets",
21
+ "dist"
22
+ ],
23
+ "dependencies": {
24
+ "@riebeckite/core": "0.2.0"
25
+ },
26
+ "devDependencies": {
27
+ "tsx": "^4.22.4"
28
+ },
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "https://github.com/Rerurate514/riebeckite.git",
35
+ "directory": "packages/ai"
36
+ },
37
+ "homepage": "https://github.com/Rerurate514/riebeckite#readme",
38
+ "bugs": {
39
+ "url": "https://github.com/Rerurate514/riebeckite/issues"
40
+ },
41
+ "description": "AI integration configuration and mutation policy for Riebeckite.",
42
+ "keywords": [
43
+ "riebeckite",
44
+ "ai",
45
+ "mcp"
46
+ ],
47
+ "sideEffects": false,
48
+ "engines": {
49
+ "node": "^20.19.0 || >=22.12.0"
50
+ },
51
+ "scripts": {
52
+ "build": "node ../../scripts/build_package.mjs",
53
+ "test": "node --import tsx --test \"test/*.test.ts\""
54
+ }
6
55
  }