@agentspec/adapter-claude 0.2.3 → 0.4.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 ADDED
@@ -0,0 +1,183 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submit" means any form of electronic, verbal, or
51
+ written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or designated in writing by the copyright owner as "Not a
57
+ Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and included
61
+ within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by the combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or
82
+ contributory patent infringement, then any patent licenses granted
83
+ to You under this License for that Work shall terminate as of the
84
+ date such litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or Derivative
92
+ Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, copy, modify, merge,
120
+ publish, distribute, sublicense, and/or sell copies of the
121
+ Derivative Works, as these terms may be expanded or clarified.
122
+
123
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
124
+ any Contribution intentionally submitted for inclusion in the Work
125
+ by You to the Licensor shall be under the terms and conditions of
126
+ this License, without any additional terms or conditions.
127
+ Notwithstanding the above, nothing herein shall supersede or modify
128
+ the terms of any separate license agreement you may have executed
129
+ with Licensor regarding such Contributions.
130
+
131
+ 6. Trademarks. This License does not grant permission to use the trade
132
+ names, trademarks, service marks, or product names of the Licensor,
133
+ except as required for reasonable and customary use in describing the
134
+ origin of the Work and reproducing the content of the NOTICE file.
135
+
136
+ 7. Disclaimer of Warranty. Unless required by applicable law or
137
+ agreed to in writing, Licensor provides the Work (and each
138
+ Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
140
+ implied, including, without limitation, any warranties or conditions
141
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
142
+ PARTICULAR PURPOSE. You are solely responsible for determining the
143
+ appropriateness of using or reproducing the Work and assume any
144
+ risks associated with Your exercise of permissions under this License.
145
+
146
+ 8. Limitation of Liability. In no event and under no legal theory,
147
+ whether in tort (including negligence), contract, or otherwise,
148
+ unless required by applicable law (such as deliberate and grossly
149
+ negligent acts) or agreed to in writing, shall any Contributor be
150
+ liable to You for damages, including any direct, indirect, special,
151
+ incidental, or exemplary damages of any character arising as a
152
+ result of this License or out of the use or inability to use the
153
+ Work (including but not limited to damages for loss of goodwill,
154
+ work stoppage, computer failure or malfunction, or all other
155
+ commercial damages or losses), even if such Contributor has been
156
+ advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Liability. While redistributing the Work or
159
+ Derivative Works thereof, You may choose to offer, and charge a fee
160
+ for, acceptance of support, warranty, indemnity, or other liability
161
+ obligations and/or rights consistent with this License. However, in
162
+ accepting such obligations, You may offer such conditions only on
163
+ Your own behalf and on Your sole responsibility, not on behalf of
164
+ any other Contributor, and only if You agree to indemnify, defend,
165
+ and hold each Contributor harmless for any liability incurred by,
166
+ or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ Copyright 2026 Sallah Kokaina
172
+
173
+ Licensed under the Apache License, Version 2.0 (the "License");
174
+ you may not use this file except in compliance with the License.
175
+ You may obtain a copy of the License at
176
+
177
+ http://www.apache.org/licenses/LICENSE-2.0
178
+
179
+ Unless required by applicable law or agreed to in writing, software
180
+ distributed under the License is distributed on an "AS IS" BASIS,
181
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
182
+ implied. See the License for the specific language governing
183
+ permissions and limitations under the License.
package/dist/index.d.ts CHANGED
@@ -1,68 +1,61 @@
1
1
  import { AgentSpecManifest, GeneratedAgent } from '@agentspec/sdk';
2
+ import { CodegenProvider, CodegenChunk } from '@agentspec/codegen';
3
+ export { CodegenChunk, CodegenError, CodegenOptions, CodegenProvider } from '@agentspec/codegen';
2
4
 
3
5
  /**
4
6
  * @agentspec/adapter-claude
5
7
  *
6
- * Agentic code generation using Claude API.
7
- * Claude receives the full manifest JSON + a framework-specific skill file as system prompt and
8
- * generates production-ready code covering all manifest fields.
8
+ * DEPRECATED — use @agentspec/codegen instead.
9
9
  *
10
- * Requires: ANTHROPIC_API_KEY environment variable.
10
+ * This package is a backwards-compatibility shim that re-exports from
11
+ * @agentspec/codegen. All new code should import from @agentspec/codegen directly.
11
12
  *
12
- * Usage:
13
- * import { generateWithClaude, listFrameworks } from '@agentspec/adapter-claude'
14
- * const result = await generateWithClaude(manifest, { framework: 'langgraph' })
15
- * const frameworks = listFrameworks() // ['crewai', 'langgraph', 'mastra']
13
+ * Migration guide:
14
+ * generateWithClaude(manifest, opts) → generateCode(manifest, opts)
15
+ * resolveAuth().provider → resolveProvider()
16
+ * listFrameworks() → listFrameworks() (unchanged)
17
+ * repairYaml(yaml, errors) → repairYaml(provider, yaml, errors)
16
18
  */
17
19
 
18
- /**
19
- * Returns the list of supported framework names (based on .md files in skills/).
20
- * Excludes guidelines.md which is a universal base layer, not a framework.
21
- */
22
- declare function listFrameworks(): string[];
23
- interface GenerationProgress {
24
- /** Cumulative output characters received so far during streaming. */
25
- outputChars: number;
26
- }
20
+ /** @deprecated Use CodegenOptions from @agentspec/codegen */
27
21
  interface ClaudeAdapterOptions {
28
- /** Target framework (e.g. 'langgraph', 'crewai', 'mastra'). */
29
22
  framework: string;
30
- /** Claude model ID. Defaults to claude-opus-4-6. */
31
23
  model?: string;
32
- /** Optional source files to append to the user message for richer context. */
33
- contextFiles?: string[];
34
- /**
35
- * Base directory of the manifest file. When provided, $file: references in
36
- * spec.tools[].module are automatically resolved and included as context files.
37
- */
38
24
  manifestDir?: string;
39
- /**
40
- * Called on each streamed chunk with cumulative char count.
41
- * When provided, generation uses the streaming API so the caller can show
42
- * a live progress indicator. Omit to use a single blocking request.
43
- */
44
- onProgress?: (progress: GenerationProgress) => void;
25
+ contextFiles?: string[];
26
+ provider?: CodegenProvider;
27
+ onChunk?: (chunk: CodegenChunk) => void;
28
+ /** @deprecated Use onChunk instead */
29
+ onProgress?: (progress: {
30
+ outputChars: number;
31
+ }) => void;
32
+ }
33
+ /** @deprecated Use CodegenChunk from @agentspec/codegen */
34
+ interface GenerationProgress {
35
+ outputChars: number;
36
+ }
37
+ /** @deprecated Use resolveProvider() from @agentspec/codegen directly */
38
+ interface AuthResolution {
39
+ provider: CodegenProvider;
45
40
  }
46
41
  /**
47
- * Generate agent code using Claude API.
48
- *
49
- * Throws if ANTHROPIC_API_KEY is not set (with a helpful remediation message).
50
- * Throws if the framework is not supported.
51
- * Throws if Claude does not return a parseable JSON response.
42
+ * @deprecated Use `generateCode()` from `@agentspec/codegen`
52
43
  */
53
44
  declare function generateWithClaude(manifest: AgentSpecManifest, options: ClaudeAdapterOptions): Promise<GeneratedAgent>;
54
- interface RepairOptions {
55
- /** Claude model ID. Defaults to claude-opus-4-6. */
56
- model?: string;
57
- }
58
45
  /**
59
- * Ask Claude to fix an agent.yaml string that failed schema validation.
60
- *
61
- * Reuses the scan skill as the system prompt (it carries full schema knowledge).
62
- * Returns the repaired YAML string, ready to be re-validated by the caller.
46
+ * @deprecated Use `resolveProvider()` from `@agentspec/codegen`
47
+ */
48
+ declare function resolveAuth(): AuthResolution;
49
+ /**
50
+ * @deprecated Use `listFrameworks()` from `@agentspec/codegen`
51
+ */
52
+ declare function listFrameworks(): string[];
53
+ /**
54
+ * @deprecated Use `repairYaml(provider, yaml, errors)` from `@agentspec/codegen`
63
55
  *
64
- * Throws if ANTHROPIC_API_KEY is not set or Claude does not return a parseable response.
56
+ * Note: the new API requires passing a provider as the first argument.
57
+ * This shim auto-resolves a provider for backwards compatibility.
65
58
  */
66
- declare function repairYaml(yamlStr: string, validationErrors: string, options?: RepairOptions): Promise<string>;
59
+ declare function repairYaml(yamlStr: string, validationErrors: string, _options?: Record<string, unknown>): Promise<string>;
67
60
 
68
- export { type ClaudeAdapterOptions, type GenerationProgress, type RepairOptions, generateWithClaude, listFrameworks, repairYaml };
61
+ export { type AuthResolution, type ClaudeAdapterOptions, type GenerationProgress, generateWithClaude, listFrameworks, repairYaml, resolveAuth };
package/dist/index.js CHANGED
@@ -1,206 +1,47 @@
1
1
  // src/index.ts
2
- import Anthropic from "@anthropic-ai/sdk";
3
- import { readFileSync as readFileSync2, readdirSync } from "fs";
4
- import { join as join2, dirname } from "path";
5
- import { fileURLToPath } from "url";
6
-
7
- // src/context-builder.ts
8
- import { readFileSync } from "fs";
9
- import { join } from "path";
10
- function extractFileRefs(manifest, baseDir) {
11
- const refs = [];
12
- for (const tool of manifest.spec?.tools ?? []) {
13
- const mod = tool.module;
14
- if (typeof mod === "string" && mod.startsWith("$file:")) {
15
- refs.push(join(baseDir, mod.slice(6)));
16
- }
17
- }
18
- return refs;
19
- }
20
- function buildContext(options) {
21
- const { manifest, contextFiles = [], manifestDir } = options;
22
- const resolvedRefs = manifestDir ? extractFileRefs(manifest, manifestDir) : [];
23
- const allContextFiles = [...resolvedRefs, ...contextFiles];
24
- const parts = [
25
- "## Agent Manifest (JSON)",
26
- "```json",
27
- JSON.stringify(manifest, null, 2),
28
- "```"
29
- ];
30
- for (const filePath of allContextFiles) {
31
- try {
32
- const content = readFileSync(filePath, "utf-8");
33
- const ext = filePath.split(".").pop() ?? "";
34
- parts.push(`
35
- ## Context File: ${filePath}`);
36
- parts.push(`\`\`\`${ext}`);
37
- parts.push(content);
38
- parts.push("```");
39
- } catch {
40
- }
41
- }
42
- return parts.join("\n");
43
- }
44
-
45
- // src/index.ts
46
- var __dirname = dirname(fileURLToPath(import.meta.url));
47
- var skillsDir = join2(__dirname, "skills");
48
- function listFrameworks() {
49
- return readdirSync(skillsDir).filter((f) => f.endsWith(".md") && f !== "guidelines.md").map((f) => f.slice(0, -3)).sort();
50
- }
51
- function loadSkill(framework) {
52
- const available = listFrameworks();
53
- if (!available.includes(framework)) {
54
- throw new Error(
55
- `Framework '${framework}' is not supported. Available: ${available.join(", ")}`
56
- );
57
- }
58
- const guidelinesPath = join2(skillsDir, "guidelines.md");
59
- let guidelines = "";
60
- try {
61
- guidelines = readFileSync2(guidelinesPath, "utf-8") + "\n\n---\n\n";
62
- } catch {
63
- }
64
- return guidelines + readFileSync2(join2(skillsDir, `${framework}.md`), "utf-8");
65
- }
66
- function initClaudeClient() {
67
- const apiKey = process.env["ANTHROPIC_API_KEY"];
68
- if (!apiKey) {
69
- throw new Error(
70
- "ANTHROPIC_API_KEY is not set. AgentSpec generates code using Claude.\nGet a key at https://console.anthropic.com and add it to your environment."
71
- );
72
- }
73
- const baseURL = process.env["ANTHROPIC_BASE_URL"];
74
- return new Anthropic({ apiKey, ...baseURL ? { baseURL } : {} });
2
+ import {
3
+ generateCode,
4
+ resolveProvider,
5
+ listFrameworks as _listFrameworks,
6
+ repairYaml as _repairYaml,
7
+ CodegenError
8
+ } from "@agentspec/codegen";
9
+ var warned = false;
10
+ function warnDeprecated() {
11
+ if (warned) return;
12
+ warned = true;
13
+ console.warn(
14
+ "[@agentspec/adapter-claude] DEPRECATED: this package is deprecated. Migrate to @agentspec/codegen. See https://agentspec.io/docs/concepts/adapters"
15
+ );
75
16
  }
76
- var REPAIR_SYSTEM_PROMPT = `You are an AgentSpec v1 YAML schema fixer.
77
- Fix the agent.yaml provided by the user so it complies with the AgentSpec v1 schema.
78
- Return ONLY a JSON object with this exact shape (no other text):
79
- {"files":{"agent.yaml":"<corrected YAML>"},"installCommands":[],"envVars":[]}
80
-
81
- ## AgentSpec v1 schema rules (enforce all of these):
82
- - Top-level keys: apiVersion: "agentspec.io/v1", kind: "AgentSpec"
83
- - metadata: name (slug a-z0-9-), version (semver), description
84
- - spec.model: provider, id (never "name"), apiKey: "$env:VAR"
85
- - spec.model.fallback: provider, id, apiKey, triggerOn (array of strings)
86
- - spec.tools[]: name (slug), type: "function", description
87
- - spec.memory.shortTerm.backend: "redis" | "in-memory" | "sqlite"
88
- - spec.memory.longTerm.backend: "postgres" | "sqlite" | "mongodb"
89
- - spec.guardrails.input: array of guardrail objects (not a scalar)
90
- - spec.guardrails.output: array of guardrail objects (not a scalar)
91
- - spec.requires.envVars: array of strings (key is "envVars", not "env")
92
- - spec.requires.services[]: {type, connection: "$env:VAR"}`;
93
17
  async function generateWithClaude(manifest, options) {
94
- const client = initClaudeClient();
95
- const skillMd = loadSkill(options.framework);
96
- const context = buildContext({
97
- manifest,
98
- contextFiles: options.contextFiles,
99
- manifestDir: options.manifestDir
100
- });
101
- const model = options.model ?? process.env["ANTHROPIC_MODEL"] ?? "claude-opus-4-6";
102
- const requestParams = {
103
- model,
104
- max_tokens: 32768,
105
- system: skillMd,
106
- messages: [{ role: "user", content: context }]
107
- };
108
- let text;
109
- if (options.onProgress) {
110
- let accumulated = "";
111
- for await (const event of client.messages.stream(requestParams)) {
112
- if (event.type === "content_block_delta" && event.delta.type === "text_delta") {
113
- accumulated += event.delta.text;
114
- options.onProgress({ outputChars: accumulated.length });
115
- }
18
+ warnDeprecated();
19
+ const adaptedOnChunk = options.onChunk ?? (options.onProgress ? (chunk) => {
20
+ if (chunk.type === "delta") {
21
+ options.onProgress({ outputChars: chunk.accumulated.length });
116
22
  }
117
- text = accumulated;
118
- } else {
119
- const response = await client.messages.create(requestParams);
120
- text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
121
- }
122
- return extractGeneratedAgent(text, options.framework);
23
+ } : void 0);
24
+ return generateCode(manifest, { ...options, onChunk: adaptedOnChunk });
123
25
  }
124
- async function repairYaml(yamlStr, validationErrors, options = {}) {
125
- const client = initClaudeClient();
126
- const model = options.model ?? process.env["ANTHROPIC_MODEL"] ?? "claude-opus-4-6";
127
- const userMessage = `The following agent.yaml failed AgentSpec v1 schema validation.
128
- Fix ALL the errors listed below and return the corrected file in the same JSON format.
129
-
130
- ## Current (invalid) YAML:
131
- \`\`\`yaml
132
- ${yamlStr}
133
- \`\`\`
134
-
135
- ## Validation errors:
136
- \`\`\`
137
- ${validationErrors}
138
- \`\`\`
139
-
140
- Return ONLY a JSON object (no other text):
141
- \`\`\`json
142
- {"files":{"agent.yaml":"<corrected YAML>"},"installCommands":[],"envVars":[]}
143
- \`\`\``;
144
- const response = await client.messages.create({
145
- model,
146
- max_tokens: 16384,
147
- system: REPAIR_SYSTEM_PROMPT,
148
- messages: [{ role: "user", content: userMessage }]
149
- });
150
- const text = response.content.filter((block) => block.type === "text").map((block) => block.text).join("");
151
- const result = extractGeneratedAgent(text, "scan");
152
- const fixed = result.files["agent.yaml"];
153
- if (!fixed) throw new Error("Claude did not return agent.yaml in repair response.");
154
- return fixed;
26
+ function resolveAuth() {
27
+ warnDeprecated();
28
+ const provider = resolveProvider();
29
+ return { provider };
155
30
  }
156
- function extractGeneratedAgent(text, framework) {
157
- const candidates = [];
158
- const trimmed = text.trim();
159
- if (trimmed.startsWith("{")) {
160
- candidates.push(trimmed);
161
- }
162
- const fenceOpen = text.indexOf("```json");
163
- if (fenceOpen !== -1) {
164
- const contentStart = text.indexOf("\n", fenceOpen) + 1;
165
- const fenceClose = text.lastIndexOf("\n```");
166
- if (fenceClose > contentStart) {
167
- candidates.push(text.slice(contentStart, fenceClose));
168
- }
169
- }
170
- const braceMatch = text.match(/(\{[\s\S]*\})/);
171
- if (braceMatch?.[1]) candidates.push(braceMatch[1]);
172
- let parsedAny = false;
173
- for (const candidate of candidates) {
174
- let parsed;
175
- try {
176
- parsed = JSON.parse(candidate);
177
- } catch {
178
- continue;
179
- }
180
- parsedAny = true;
181
- if (!parsed || typeof parsed !== "object" || !("files" in parsed)) continue;
182
- const result = parsed;
183
- return {
184
- framework,
185
- files: result.files,
186
- installCommands: result.installCommands ?? [],
187
- envVars: result.envVars ?? [],
188
- readme: result.files["README.md"] ?? ""
189
- };
190
- }
191
- if (parsedAny) {
192
- throw new Error('Claude response JSON is missing the required "files" field.');
193
- }
194
- throw new Error(
195
- `Claude did not return a valid JSON response.
196
-
197
- Received:
198
- ${text.slice(0, 500)}`
199
- );
31
+ function listFrameworks() {
32
+ warnDeprecated();
33
+ return _listFrameworks();
34
+ }
35
+ async function repairYaml(yamlStr, validationErrors, _options) {
36
+ warnDeprecated();
37
+ const provider = resolveProvider();
38
+ return _repairYaml(provider, yamlStr, validationErrors);
200
39
  }
201
40
  export {
41
+ CodegenError,
202
42
  generateWithClaude,
203
43
  listFrameworks,
204
- repairYaml
44
+ repairYaml,
45
+ resolveAuth
205
46
  };
206
47
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/context-builder.ts"],"sourcesContent":["/**\n * @agentspec/adapter-claude\n *\n * Agentic code generation using Claude API.\n * Claude receives the full manifest JSON + a framework-specific skill file as system prompt and\n * generates production-ready code covering all manifest fields.\n *\n * Requires: ANTHROPIC_API_KEY environment variable.\n *\n * Usage:\n * import { generateWithClaude, listFrameworks } from '@agentspec/adapter-claude'\n * const result = await generateWithClaude(manifest, { framework: 'langgraph' })\n * const frameworks = listFrameworks() // ['crewai', 'langgraph', 'mastra']\n */\n\nimport Anthropic from '@anthropic-ai/sdk'\nimport { readFileSync, readdirSync } from 'node:fs'\nimport { join, dirname } from 'node:path'\nimport { fileURLToPath } from 'node:url'\nimport type { AgentSpecManifest, GeneratedAgent } from '@agentspec/sdk'\nimport { buildContext } from './context-builder.js'\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\nconst skillsDir = join(__dirname, 'skills')\n\n/**\n * Returns the list of supported framework names (based on .md files in skills/).\n * Excludes guidelines.md which is a universal base layer, not a framework.\n */\nexport function listFrameworks(): string[] {\n return readdirSync(skillsDir)\n .filter((f) => f.endsWith('.md') && f !== 'guidelines.md')\n .map((f) => f.slice(0, -3))\n .sort()\n}\n\n/**\n * Load the skill file for a given framework, prepended with universal guidelines.\n * Throws a descriptive error if the framework is not supported.\n */\nfunction loadSkill(framework: string): string {\n const available = listFrameworks()\n if (!available.includes(framework)) {\n throw new Error(\n `Framework '${framework}' is not supported. Available: ${available.join(', ')}`,\n )\n }\n const guidelinesPath = join(skillsDir, 'guidelines.md')\n let guidelines = ''\n try {\n guidelines = readFileSync(guidelinesPath, 'utf-8') + '\\n\\n---\\n\\n'\n } catch {\n // guidelines.md is optional — skip if missing\n }\n return guidelines + readFileSync(join(skillsDir, `${framework}.md`), 'utf-8')\n}\n\n/**\n * Guard ANTHROPIC_API_KEY and return a configured Anthropic client.\n * Throws with a remediation message if the key is missing.\n */\nfunction initClaudeClient(): Anthropic {\n const apiKey = process.env['ANTHROPIC_API_KEY']\n if (!apiKey) {\n throw new Error(\n 'ANTHROPIC_API_KEY is not set. AgentSpec generates code using Claude.\\n' +\n 'Get a key at https://console.anthropic.com and add it to your environment.',\n )\n }\n const baseURL = process.env['ANTHROPIC_BASE_URL']\n return new Anthropic({ apiKey, ...(baseURL ? { baseURL } : {}) })\n}\n\n/** System prompt used exclusively by repairYaml — knows AgentSpec v1 schema rules. */\nconst REPAIR_SYSTEM_PROMPT =\n `You are an AgentSpec v1 YAML schema fixer.\\n` +\n `Fix the agent.yaml provided by the user so it complies with the AgentSpec v1 schema.\\n` +\n `Return ONLY a JSON object with this exact shape (no other text):\\n` +\n `{\"files\":{\"agent.yaml\":\"<corrected YAML>\"},\"installCommands\":[],\"envVars\":[]}\\n\\n` +\n `## AgentSpec v1 schema rules (enforce all of these):\\n` +\n `- Top-level keys: apiVersion: \"agentspec.io/v1\", kind: \"AgentSpec\"\\n` +\n `- metadata: name (slug a-z0-9-), version (semver), description\\n` +\n `- spec.model: provider, id (never \"name\"), apiKey: \"$env:VAR\"\\n` +\n `- spec.model.fallback: provider, id, apiKey, triggerOn (array of strings)\\n` +\n `- spec.tools[]: name (slug), type: \"function\", description\\n` +\n `- spec.memory.shortTerm.backend: \"redis\" | \"in-memory\" | \"sqlite\"\\n` +\n `- spec.memory.longTerm.backend: \"postgres\" | \"sqlite\" | \"mongodb\"\\n` +\n `- spec.guardrails.input: array of guardrail objects (not a scalar)\\n` +\n `- spec.guardrails.output: array of guardrail objects (not a scalar)\\n` +\n `- spec.requires.envVars: array of strings (key is \"envVars\", not \"env\")\\n` +\n `- spec.requires.services[]: {type, connection: \"$env:VAR\"}`\n\nexport interface GenerationProgress {\n /** Cumulative output characters received so far during streaming. */\n outputChars: number\n}\n\nexport interface ClaudeAdapterOptions {\n /** Target framework (e.g. 'langgraph', 'crewai', 'mastra'). */\n framework: string\n /** Claude model ID. Defaults to claude-opus-4-6. */\n model?: string\n /** Optional source files to append to the user message for richer context. */\n contextFiles?: string[]\n /**\n * Base directory of the manifest file. When provided, $file: references in\n * spec.tools[].module are automatically resolved and included as context files.\n */\n manifestDir?: string\n /**\n * Called on each streamed chunk with cumulative char count.\n * When provided, generation uses the streaming API so the caller can show\n * a live progress indicator. Omit to use a single blocking request.\n */\n onProgress?: (progress: GenerationProgress) => void\n}\n\n/**\n * Generate agent code using Claude API.\n *\n * Throws if ANTHROPIC_API_KEY is not set (with a helpful remediation message).\n * Throws if the framework is not supported.\n * Throws if Claude does not return a parseable JSON response.\n */\nexport async function generateWithClaude(\n manifest: AgentSpecManifest,\n options: ClaudeAdapterOptions,\n): Promise<GeneratedAgent> {\n const client = initClaudeClient()\n const skillMd = loadSkill(options.framework)\n\n const context = buildContext({\n manifest,\n contextFiles: options.contextFiles,\n manifestDir: options.manifestDir,\n })\n const model = options.model ?? process.env['ANTHROPIC_MODEL'] ?? 'claude-opus-4-6'\n\n const requestParams = {\n model,\n max_tokens: 32768,\n system: skillMd,\n messages: [{ role: 'user' as const, content: context }],\n }\n\n let text: string\n\n if (options.onProgress) {\n // Streaming path — yields chunks so the caller can show live progress.\n let accumulated = ''\n for await (const event of client.messages.stream(requestParams)) {\n if (event.type === 'content_block_delta' && event.delta.type === 'text_delta') {\n accumulated += event.delta.text\n options.onProgress({ outputChars: accumulated.length })\n }\n }\n text = accumulated\n } else {\n // Blocking path — single request, no progress callbacks.\n const response = await client.messages.create(requestParams)\n text = response.content\n .filter((block): block is Anthropic.TextBlock => block.type === 'text')\n .map((block) => block.text)\n .join('')\n }\n\n return extractGeneratedAgent(text, options.framework)\n}\n\n// ── YAML repair ──────────────────────────────────────────────────────────────\n\nexport interface RepairOptions {\n /** Claude model ID. Defaults to claude-opus-4-6. */\n model?: string\n}\n\n/**\n * Ask Claude to fix an agent.yaml string that failed schema validation.\n *\n * Reuses the scan skill as the system prompt (it carries full schema knowledge).\n * Returns the repaired YAML string, ready to be re-validated by the caller.\n *\n * Throws if ANTHROPIC_API_KEY is not set or Claude does not return a parseable response.\n */\nexport async function repairYaml(\n yamlStr: string,\n validationErrors: string,\n options: RepairOptions = {},\n): Promise<string> {\n const client = initClaudeClient()\n const model = options.model ?? process.env['ANTHROPIC_MODEL'] ?? 'claude-opus-4-6'\n\n const userMessage =\n `The following agent.yaml failed AgentSpec v1 schema validation.\\n` +\n `Fix ALL the errors listed below and return the corrected file in the same JSON format.\\n\\n` +\n `## Current (invalid) YAML:\\n\\`\\`\\`yaml\\n${yamlStr}\\n\\`\\`\\`\\n\\n` +\n `## Validation errors:\\n\\`\\`\\`\\n${validationErrors}\\n\\`\\`\\`\\n\\n` +\n `Return ONLY a JSON object (no other text):\\n` +\n `\\`\\`\\`json\\n{\"files\":{\"agent.yaml\":\"<corrected YAML>\"},\"installCommands\":[],\"envVars\":[]}\\n\\`\\`\\``\n\n const response = await client.messages.create({\n model,\n max_tokens: 16384,\n system: REPAIR_SYSTEM_PROMPT,\n messages: [{ role: 'user' as const, content: userMessage }],\n })\n\n const text = response.content\n .filter((block): block is Anthropic.TextBlock => block.type === 'text')\n .map(block => block.text)\n .join('')\n\n const result = extractGeneratedAgent(text, 'scan')\n const fixed = result.files['agent.yaml']\n if (!fixed) throw new Error('Claude did not return agent.yaml in repair response.')\n return fixed\n}\n\n// ── Response parsing ──────────────────────────────────────────────────────────\n\ninterface ClaudeGenerationResult {\n files: Record<string, string>\n installCommands?: string[]\n envVars?: string[]\n}\n\nfunction extractGeneratedAgent(text: string, framework: string): GeneratedAgent {\n // Build candidates in priority order and return the first one that parses\n // correctly. Multiple strategies are needed because:\n //\n // 1. Claude may return bare JSON (no fence).\n // 2. Claude may wrap in ```json … ``` but the generated code inside the\n // JSON string values can contain backtick sequences that fool a naive\n // non-greedy regex — so we use lastIndexOf('\\n```') as the close marker.\n // 3. As a last resort, pull the outermost {...} from the text.\n const candidates: string[] = []\n\n const trimmed = text.trim()\n\n // Strategy 1: bare JSON\n if (trimmed.startsWith('{')) {\n candidates.push(trimmed)\n }\n\n // Strategy 2: ```json fence — close at the last newline+``` to survive\n // backtick sequences embedded inside generated code strings.\n const fenceOpen = text.indexOf('```json')\n if (fenceOpen !== -1) {\n const contentStart = text.indexOf('\\n', fenceOpen) + 1\n const fenceClose = text.lastIndexOf('\\n```')\n if (fenceClose > contentStart) {\n candidates.push(text.slice(contentStart, fenceClose))\n }\n }\n\n // Strategy 3: greedy brace match\n const braceMatch = text.match(/(\\{[\\s\\S]*\\})/)\n if (braceMatch?.[1]) candidates.push(braceMatch[1])\n\n let parsedAny = false\n for (const candidate of candidates) {\n let parsed: unknown\n try {\n parsed = JSON.parse(candidate)\n } catch {\n continue\n }\n parsedAny = true\n if (!parsed || typeof parsed !== 'object' || !('files' in parsed)) continue\n\n const result = parsed as ClaudeGenerationResult\n return {\n framework,\n files: result.files,\n installCommands: result.installCommands ?? [],\n envVars: result.envVars ?? [],\n readme: result.files['README.md'] ?? '',\n }\n }\n\n if (parsedAny) {\n throw new Error('Claude response JSON is missing the required \"files\" field.')\n }\n\n throw new Error(\n `Claude did not return a valid JSON response.\\n\\nReceived:\\n${text.slice(0, 500)}`,\n )\n}\n","import type { AgentSpecManifest } from '@agentspec/sdk'\nimport { readFileSync } from 'node:fs'\nimport { join } from 'node:path'\n\nexport interface BuildContextOptions {\n manifest: AgentSpecManifest\n contextFiles?: string[]\n /** Base directory for resolving $file: references in spec.tools[].module */\n manifestDir?: string\n}\n\n/**\n * Scan spec.tools[].module for $file: references and return resolved absolute paths.\n * This gives Claude the actual tool implementations to reference when generating typed wrappers.\n */\nfunction extractFileRefs(manifest: AgentSpecManifest, baseDir: string): string[] {\n const refs: string[] = []\n for (const tool of manifest.spec?.tools ?? []) {\n const mod = (tool as Record<string, unknown>).module as string | undefined\n if (typeof mod === 'string' && mod.startsWith('$file:')) {\n refs.push(join(baseDir, mod.slice(6)))\n }\n }\n return refs\n}\n\n/**\n * Build the user-message context for Claude from a manifest + optional source files.\n * The manifest is serialised as JSON. Context files are appended verbatim so Claude\n * can infer tool signatures, existing patterns, etc.\n *\n * When manifestDir is provided, $file: references in spec.tools[].module are automatically\n * resolved and included as context files.\n */\nexport function buildContext(options: BuildContextOptions): string {\n const { manifest, contextFiles = [], manifestDir } = options\n\n const resolvedRefs = manifestDir ? extractFileRefs(manifest, manifestDir) : []\n const allContextFiles = [...resolvedRefs, ...contextFiles]\n\n const parts: string[] = [\n '## Agent Manifest (JSON)',\n '```json',\n JSON.stringify(manifest, null, 2),\n '```',\n ]\n\n for (const filePath of allContextFiles) {\n try {\n const content = readFileSync(filePath, 'utf-8')\n const ext = filePath.split('.').pop() ?? ''\n parts.push(`\\n## Context File: ${filePath}`)\n parts.push(`\\`\\`\\`${ext}`)\n parts.push(content)\n parts.push('```')\n } catch {\n // Silently skip unreadable context files\n }\n }\n\n return parts.join('\\n')\n}\n"],"mappings":";AAeA,OAAO,eAAe;AACtB,SAAS,gBAAAA,eAAc,mBAAmB;AAC1C,SAAS,QAAAC,OAAM,eAAe;AAC9B,SAAS,qBAAqB;;;ACjB9B,SAAS,oBAAoB;AAC7B,SAAS,YAAY;AAarB,SAAS,gBAAgB,UAA6B,SAA2B;AAC/E,QAAM,OAAiB,CAAC;AACxB,aAAW,QAAQ,SAAS,MAAM,SAAS,CAAC,GAAG;AAC7C,UAAM,MAAO,KAAiC;AAC9C,QAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,QAAQ,GAAG;AACvD,WAAK,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,CAAC,CAAC;AAAA,IACvC;AAAA,EACF;AACA,SAAO;AACT;AAUO,SAAS,aAAa,SAAsC;AACjE,QAAM,EAAE,UAAU,eAA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AK,MAAM,eAAe;AAC7C,MAAI,aAAa,CAAC,EAAG,YAAW,KAAK,WAAW,CAAC,CAAC;AAElD,MAAI,YAAY;AAChB,aAAW,aAAa,YAAY;AAClC,QAAI;AACJ,QAAI;AACF,eAAS,KAAK,MAAM,SAAS;AAAA,IAC/B,QAAQ;AACN;AAAA,IACF;AACA,gBAAY;AACZ,QAAI,CAAC,UAAU,OAAO,WAAW,YAAY,EAAE,WAAW,QAAS;AAEnE,UAAM,SAAS;AACf,WAAO;AAAA,MACL;AAAA,MACA,OAAO,OAAO;AAAA,MACd,iBAAiB,OAAO,mBAAmB,CAAC;AAAA,MAC5C,SAAS,OAAO,WAAW,CAAC;AAAA,MAC5B,QAAQ,OAAO,MAAM,WAAW,KAAK;AAAA,IACvC;AAAA,EACF;AAEA,MAAI,WAAW;AACb,UAAM,IAAI,MAAM,6DAA6D;AAAA,EAC/E;AAEA,QAAM,IAAI;AAAA,IACR;AAAA;AAAA;AAAA,EAA8D,KAAK,MAAM,GAAG,GAAG,CAAC;AAAA,EAClF;AACF;","names":["readFileSync","join","join","readFileSync"]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @agentspec/adapter-claude\n *\n * DEPRECATED — use @agentspec/codegen instead.\n *\n * This package is a backwards-compatibility shim that re-exports from\n * @agentspec/codegen. All new code should import from @agentspec/codegen directly.\n *\n * Migration guide:\n * generateWithClaude(manifest, opts) → generateCode(manifest, opts)\n * resolveAuth().provider → resolveProvider()\n * listFrameworks() → listFrameworks() (unchanged)\n * repairYaml(yaml, errors) → repairYaml(provider, yaml, errors)\n */\n\nimport type { AgentSpecManifest, GeneratedAgent } from '@agentspec/sdk'\nimport {\n generateCode,\n resolveProvider,\n listFrameworks as _listFrameworks,\n repairYaml as _repairYaml,\n CodegenError,\n type CodegenProvider,\n type CodegenChunk,\n type CodegenOptions,\n} from '@agentspec/codegen'\n\n// ── Deprecation warning (once per process) ───────────────────────────────────\n\nlet warned = false\nfunction warnDeprecated(): void {\n if (warned) return\n warned = true\n console.warn(\n '[@agentspec/adapter-claude] DEPRECATED: this package is deprecated. ' +\n 'Migrate to @agentspec/codegen. See https://agentspec.io/docs/concepts/adapters',\n )\n}\n\n// ── Re-exported types ────────────────────────────────────────────────────────\n\n/** @deprecated Use CodegenOptions from @agentspec/codegen */\nexport interface ClaudeAdapterOptions {\n framework: string\n model?: string\n manifestDir?: string\n contextFiles?: string[]\n provider?: CodegenProvider\n onChunk?: (chunk: CodegenChunk) => void\n /** @deprecated Use onChunk instead */\n onProgress?: (progress: { outputChars: number }) => void\n}\n\n/** @deprecated Use CodegenChunk from @agentspec/codegen */\nexport interface GenerationProgress {\n outputChars: number\n}\n\n/** @deprecated Use resolveProvider() from @agentspec/codegen directly */\nexport interface AuthResolution {\n provider: CodegenProvider\n}\n\n// ── Re-exported functions ────────────────────────────────────────────────────\n\n/**\n * @deprecated Use `generateCode()` from `@agentspec/codegen`\n */\nexport async function generateWithClaude(\n manifest: AgentSpecManifest,\n options: ClaudeAdapterOptions,\n): Promise<GeneratedAgent> {\n warnDeprecated()\n const adaptedOnChunk = options.onChunk ?? (options.onProgress\n ? (chunk: CodegenChunk) => {\n if (chunk.type === 'delta') {\n options.onProgress!({ outputChars: chunk.accumulated.length })\n }\n }\n : undefined)\n return generateCode(manifest, { ...options, onChunk: adaptedOnChunk })\n}\n\n/**\n * @deprecated Use `resolveProvider()` from `@agentspec/codegen`\n */\nexport function resolveAuth(): AuthResolution {\n warnDeprecated()\n const provider = resolveProvider()\n return { provider }\n}\n\n/**\n * @deprecated Use `listFrameworks()` from `@agentspec/codegen`\n */\nexport function listFrameworks(): string[] {\n warnDeprecated()\n return _listFrameworks()\n}\n\n/**\n * @deprecated Use `repairYaml(provider, yaml, errors)` from `@agentspec/codegen`\n *\n * Note: the new API requires passing a provider as the first argument.\n * This shim auto-resolves a provider for backwards compatibility.\n */\nexport async function repairYaml(\n yamlStr: string,\n validationErrors: string,\n _options?: Record<string, unknown>,\n): Promise<string> {\n warnDeprecated()\n const provider = resolveProvider()\n return _repairYaml(provider, yamlStr, validationErrors)\n}\n\n// ── Pass-through re-exports ──────────────────────────────────────────────────\n\nexport { CodegenError, type CodegenProvider, type CodegenChunk, type CodegenOptions }\n"],"mappings":";AAgBA;AAAA,EACE;AAAA,EACA;AAAA,EACA,kBAAkB;AAAA,EAClB,cAAc;AAAA,EACd;AAAA,OAIK;AAIP,IAAI,SAAS;AACb,SAAS,iBAAuB;AAC9B,MAAI,OAAQ;AACZ,WAAS;AACT,UAAQ;AAAA,IACN;AAAA,EAEF;AACF;AA+BA,eAAsB,mBACpB,UACA,SACyB;AACzB,iBAAe;AACf,QAAM,iBAAiB,QAAQ,YAAY,QAAQ,aAC/C,CAAC,UAAwB;AACvB,QAAI,MAAM,SAAS,SAAS;AAC1B,cAAQ,WAAY,EAAE,aAAa,MAAM,YAAY,OAAO,CAAC;AAAA,IAC/D;AAAA,EACF,IACA;AACJ,SAAO,aAAa,UAAU,EAAE,GAAG,SAAS,SAAS,eAAe,CAAC;AACvE;AAKO,SAAS,cAA8B;AAC5C,iBAAe;AACf,QAAM,WAAW,gBAAgB;AACjC,SAAO,EAAE,SAAS;AACpB;AAKO,SAAS,iBAA2B;AACzC,iBAAe;AACf,SAAO,gBAAgB;AACzB;AAQA,eAAsB,WACpB,SACA,kBACA,UACiB;AACjB,iBAAe;AACf,QAAM,WAAW,gBAAgB;AACjC,SAAO,YAAY,UAAU,SAAS,gBAAgB;AACxD;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agentspec/adapter-claude",
3
- "version": "0.2.3",
4
- "description": "AgentSpec agentic adapter — uses Claude API to generate complete agent code from agent.yaml",
3
+ "version": "0.4.0",
4
+ "description": "DEPRECATED — use @agentspec/codegen instead. This package re-exports from @agentspec/codegen for backwards compatibility.",
5
5
  "author": "Sallah Kokaina <sallah.kokaina@gmail.com>",
6
6
  "license": "Apache-2.0",
7
7
  "homepage": "https://agentspec.io",
@@ -10,17 +10,7 @@
10
10
  "url": "https://github.com/agents-oss/agentspec.git",
11
11
  "directory": "packages/adapter-claude"
12
12
  },
13
- "bugs": {
14
- "url": "https://github.com/agents-oss/agentspec/issues"
15
- },
16
- "keywords": [
17
- "ai-agents",
18
- "agent-manifest",
19
- "claude",
20
- "anthropic",
21
- "agentspec",
22
- "code-generation"
23
- ],
13
+ "deprecated": "Use @agentspec/codegen instead",
24
14
  "type": "module",
25
15
  "main": "./dist/index.js",
26
16
  "types": "./dist/index.d.ts",
@@ -33,23 +23,21 @@
33
23
  "files": [
34
24
  "dist"
35
25
  ],
36
- "scripts": {
37
- "build": "tsup && mkdir -p dist/skills && cp src/skills/*.md dist/skills/",
38
- "dev": "tsup --watch",
39
- "test": "vitest run",
40
- "typecheck": "tsc --noEmit",
41
- "lint": "tsc --noEmit",
42
- "clean": "rm -rf dist",
43
- "prepublishOnly": "pnpm build"
44
- },
45
26
  "dependencies": {
46
- "@agentspec/sdk": "0.2.3",
47
- "@anthropic-ai/sdk": "^0.36.0"
27
+ "@agentspec/codegen": "0.4.0",
28
+ "@agentspec/sdk": "0.4.0"
48
29
  },
49
30
  "devDependencies": {
50
31
  "@types/node": "^20.17.0",
51
32
  "tsup": "^8.3.5",
52
33
  "typescript": "^5.7.2",
53
34
  "vitest": "^2.1.8"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "typecheck": "tsc --noEmit",
39
+ "lint": "tsc --noEmit",
40
+ "test": "vitest run",
41
+ "clean": "rm -rf dist"
54
42
  }
55
43
  }