@apifuse/provider-sdk 2.2.0-beta.5 → 2.2.0-beta.8
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/AUTHORING.md +53 -0
- package/CHANGELOG.md +12 -0
- package/README.md +5 -1
- package/SUBMISSION.md +1 -1
- package/bin/apifuse-check.ts +26 -1
- package/bin/apifuse-pack-check.ts +14 -0
- package/bin/apifuse-submit-check.ts +193 -2
- package/bin/apifuse-sync-assets.ts +117 -0
- package/dist/auth-turn/index.d.ts +2 -2
- package/dist/cli/commands.d.ts +1 -1
- package/dist/cli/commands.js +8 -0
- package/dist/cli/create.d.ts +3 -0
- package/dist/cli/create.js +34 -35
- package/dist/cli/prompt-assets.d.ts +80 -0
- package/dist/cli/prompt-assets.js +743 -0
- package/dist/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/dist/config/loader.d.ts +79 -6
- package/dist/config/loader.js +272 -48
- package/dist/define.js +27 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/runtime/executor.js +7 -0
- package/dist/runtime/http.js +3 -0
- package/dist/runtime/proxy-errors.js +6 -2
- package/dist/runtime/proxy-nodemaven.d.ts +34 -0
- package/dist/runtime/proxy-nodemaven.js +128 -0
- package/dist/runtime/proxy-telemetry.d.ts +2 -1
- package/dist/runtime/proxy-telemetry.js +39 -4
- package/dist/runtime/secrets.d.ts +27 -0
- package/dist/runtime/secrets.js +51 -0
- package/dist/runtime/stealth.js +20 -9
- package/dist/server/serve.d.ts +5 -0
- package/dist/server/serve.js +39 -0
- package/dist/server/types.d.ts +9 -9
- package/dist/types.d.ts +30 -1
- package/package.json +4 -3
- package/src/cli/commands.ts +10 -0
- package/src/cli/create.ts +42 -35
- package/src/cli/prompt-assets.ts +865 -0
- package/src/cli/templates/provider/AGENTS.md.tpl +17 -8
- package/src/config/loader.ts +405 -61
- package/src/define.ts +35 -3
- package/src/index.ts +5 -0
- package/src/runtime/executor.ts +8 -0
- package/src/runtime/http.ts +3 -0
- package/src/runtime/proxy-errors.ts +12 -4
- package/src/runtime/proxy-nodemaven.ts +178 -0
- package/src/runtime/proxy-telemetry.ts +56 -5
- package/src/runtime/secrets.ts +64 -0
- package/src/runtime/stealth.ts +26 -10
- package/src/server/serve.ts +53 -0
- package/src/types.ts +30 -1
- package/dist/cli/templates/provider/CLAUDE.md.tpl +0 -1
- package/src/cli/templates/provider/CLAUDE.md.tpl +0 -1
- /package/dist/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/dist/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/fixtures-and-recording/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/health-checks-and-fail-closed/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/normalization-standards/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/pagination-and-counts/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-contract-verification/SKILL.md.tpl +0 -0
- /package/src/cli/templates/provider/{skills → .agents/skills}/upstream-notes/README.md.tpl +0 -0
package/src/cli/create.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import { mkdir, readFile, rm, symlink, writeFile } from "node:fs/promises";
|
|
4
4
|
import { dirname, relative, resolve } from "node:path";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
|
|
@@ -8,6 +8,11 @@ import { cancel, intro, isCancel, note, outro, select, text } from "@clack/promp
|
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
|
|
10
10
|
import packageJson from "../../package.json";
|
|
11
|
+
import {
|
|
12
|
+
buildPromptAssetManifest,
|
|
13
|
+
buildPromptAssetPlanEntries,
|
|
14
|
+
PROMPT_ASSET_MANIFEST_PATH,
|
|
15
|
+
} from "./prompt-assets.js";
|
|
11
16
|
|
|
12
17
|
export const PROVIDER_NAME_REGEX = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
|
|
13
18
|
export const CATEGORY_OPTIONS = [
|
|
@@ -64,7 +69,10 @@ export type CreateResolvedOptions = {
|
|
|
64
69
|
|
|
65
70
|
export type ProviderPlanFile = {
|
|
66
71
|
path: string;
|
|
72
|
+
/** File content, or the symlink target (relative path) for kind "symlink". */
|
|
67
73
|
content: string;
|
|
74
|
+
/** Absent kind means "file" (backward compatible with older consumers). */
|
|
75
|
+
kind?: "file" | "symlink";
|
|
68
76
|
};
|
|
69
77
|
|
|
70
78
|
export type ProviderCreatePlan = {
|
|
@@ -410,11 +418,16 @@ export async function buildProviderCreatePlan(
|
|
|
410
418
|
);
|
|
411
419
|
}
|
|
412
420
|
|
|
421
|
+
// Exact pin, not a caret range: the prompt-asset freshness gate requires
|
|
422
|
+
// manifest.sdkVersion === installed SDK version, and the manifest records
|
|
423
|
+
// this CLI's own version. A caret range would let `bun install` resolve a
|
|
424
|
+
// newer SDK than the create binary, making a fresh scaffold fail its own
|
|
425
|
+
// gate. `sync-assets` after an explicit SDK upgrade re-records the version.
|
|
413
426
|
const sdkSpecifier =
|
|
414
427
|
options.sdkSpecifier ??
|
|
415
428
|
(options.preset === "monorepo" && resolvedWorkspaceRoot
|
|
416
429
|
? "workspace:*"
|
|
417
|
-
:
|
|
430
|
+
: packageJson.version);
|
|
418
431
|
const relativeProviderRoot = relative(cwd, providerRoot) || options.name;
|
|
419
432
|
const nextDevCommand = `cd ${relativeProviderRoot} && bun run dev`;
|
|
420
433
|
const packageName =
|
|
@@ -538,40 +551,23 @@ export async function buildProviderCreatePlan(
|
|
|
538
551
|
PROVIDER_ID: options.name,
|
|
539
552
|
}),
|
|
540
553
|
},
|
|
541
|
-
{
|
|
542
|
-
path: resolve(providerRoot, "AGENTS.md"),
|
|
543
|
-
content: await renderTemplate("AGENTS.md.tpl", {}),
|
|
544
|
-
},
|
|
545
|
-
{
|
|
546
|
-
path: resolve(providerRoot, "CLAUDE.md"),
|
|
547
|
-
content: await renderTemplate("CLAUDE.md.tpl", {}),
|
|
548
|
-
},
|
|
549
|
-
{
|
|
550
|
-
path: resolve(providerRoot, "skills", "normalization-standards", "SKILL.md"),
|
|
551
|
-
content: await renderTemplate("skills/normalization-standards/SKILL.md.tpl", {}),
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
path: resolve(providerRoot, "skills", "upstream-contract-verification", "SKILL.md"),
|
|
555
|
-
content: await renderTemplate("skills/upstream-contract-verification/SKILL.md.tpl", {}),
|
|
556
|
-
},
|
|
557
|
-
{
|
|
558
|
-
path: resolve(providerRoot, "skills", "fixtures-and-recording", "SKILL.md"),
|
|
559
|
-
content: await renderTemplate("skills/fixtures-and-recording/SKILL.md.tpl", {}),
|
|
560
|
-
},
|
|
561
|
-
{
|
|
562
|
-
path: resolve(providerRoot, "skills", "pagination-and-counts", "SKILL.md"),
|
|
563
|
-
content: await renderTemplate("skills/pagination-and-counts/SKILL.md.tpl", {}),
|
|
564
|
-
},
|
|
565
|
-
{
|
|
566
|
-
path: resolve(providerRoot, "skills", "health-checks-and-fail-closed", "SKILL.md"),
|
|
567
|
-
content: await renderTemplate("skills/health-checks-and-fail-closed/SKILL.md.tpl", {}),
|
|
568
|
-
},
|
|
569
|
-
{
|
|
570
|
-
path: resolve(providerRoot, "skills", "upstream-notes", "README.md"),
|
|
571
|
-
content: await renderTemplate("skills/upstream-notes/README.md.tpl", {}),
|
|
572
|
-
},
|
|
573
554
|
];
|
|
574
555
|
|
|
556
|
+
const promptAssetEntries = await buildPromptAssetPlanEntries(renderTemplate);
|
|
557
|
+
for (const entry of promptAssetEntries) {
|
|
558
|
+
files.push({
|
|
559
|
+
path: resolve(providerRoot, entry.path),
|
|
560
|
+
content: entry.content,
|
|
561
|
+
...(entry.kind === "symlink" ? { kind: "symlink" as const } : {}),
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
// Manifest last: writePlan writes in order, so a crash mid-scaffold never
|
|
565
|
+
// leaves a manifest that claims assets which were not written.
|
|
566
|
+
files.push({
|
|
567
|
+
path: resolve(providerRoot, PROMPT_ASSET_MANIFEST_PATH),
|
|
568
|
+
content: buildPromptAssetManifest(promptAssetEntries, packageJson.version),
|
|
569
|
+
});
|
|
570
|
+
|
|
575
571
|
return {
|
|
576
572
|
displayName: options.displayName,
|
|
577
573
|
files,
|
|
@@ -614,6 +610,7 @@ function renderPackageJson(input: { packageName: string; sdkSpecifier: string })
|
|
|
614
610
|
check: "apifuse check . && bun run type-check",
|
|
615
611
|
"type-check": "tsc --noEmit",
|
|
616
612
|
"submit-check": "apifuse submit-check . --markdown submission-report.md",
|
|
613
|
+
"sync-assets": "apifuse sync-assets .",
|
|
617
614
|
test: "apifuse test .",
|
|
618
615
|
record: "apifuse record .",
|
|
619
616
|
start: "bun start.ts",
|
|
@@ -869,6 +866,13 @@ function isApifuseInternalWorkspaceRoot(workspaceRoot: string): boolean {
|
|
|
869
866
|
async function writePlan(plan: ProviderCreatePlan): Promise<void> {
|
|
870
867
|
for (const file of plan.files) {
|
|
871
868
|
await mkdir(dirname(file.path), { recursive: true });
|
|
869
|
+
if (file.kind === "symlink") {
|
|
870
|
+
// rm operates on the link itself (lstat semantics) and tolerates
|
|
871
|
+
// directories, so whatever occupies the path is replaced by the link.
|
|
872
|
+
await rm(file.path, { recursive: true, force: true });
|
|
873
|
+
await symlink(file.content, file.path);
|
|
874
|
+
continue;
|
|
875
|
+
}
|
|
872
876
|
await writeFile(file.path, file.content);
|
|
873
877
|
}
|
|
874
878
|
}
|
|
@@ -940,7 +944,10 @@ function printResult(plan: ProviderCreatePlan, jsonMode: boolean, dryRun: boolea
|
|
|
940
944
|
},
|
|
941
945
|
validationCommands: plan.validationCommands,
|
|
942
946
|
nextDevCommand: plan.nextDevCommand,
|
|
943
|
-
files: plan.files.map((file) =>
|
|
947
|
+
files: plan.files.map((file) => {
|
|
948
|
+
const relativePath = relative(plan.providerRoot, file.path) || file.path;
|
|
949
|
+
return file.kind === "symlink" ? `${relativePath} -> ${file.content} (symlink)` : relativePath;
|
|
950
|
+
}),
|
|
944
951
|
};
|
|
945
952
|
|
|
946
953
|
if (jsonMode) {
|