@lssm/bundle.contractspec-workspace 0.0.0-canary-20251217060834 → 0.0.0-canary-20251217072406
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/dist/_virtual/rolldown_runtime.js +22 -1
- package/dist/adapters/ai.js +82 -1
- package/dist/adapters/factory.js +36 -1
- package/dist/adapters/fs.js +118 -1
- package/dist/adapters/git.js +54 -1
- package/dist/adapters/index.js +7 -1
- package/dist/adapters/logger.js +80 -1
- package/dist/adapters/watcher.js +69 -1
- package/dist/adapters/workspace.js +190 -2
- package/dist/ai/agents/claude-code-agent.js +146 -9
- package/dist/ai/agents/cursor-agent.js +286 -17
- package/dist/ai/agents/index.js +5 -1
- package/dist/ai/agents/openai-codex-agent.js +140 -8
- package/dist/ai/agents/orchestrator.js +142 -1
- package/dist/ai/agents/simple-agent.js +80 -4
- package/dist/ai/client.js +162 -1
- package/dist/ai/index.js +27 -1
- package/dist/ai/prompts/code-generation.js +55 -13
- package/dist/ai/prompts/index.js +12 -1
- package/dist/ai/prompts/spec-creation.js +61 -20
- package/dist/ai/providers.js +40 -1
- package/dist/formatters/index.js +18 -1
- package/dist/formatters/json.js +71 -1
- package/dist/formatters/sarif.js +163 -1
- package/dist/formatters/text.js +208 -2
- package/dist/index.d.ts +0 -3
- package/dist/index.js +81 -1
- package/dist/libs/ai-providers/dist/factory.js +154 -0
- package/dist/libs/ai-providers/dist/index.js +4 -0
- package/dist/libs/ai-providers/dist/legacy.js +72 -0
- package/dist/libs/ai-providers/dist/models.js +287 -0
- package/dist/libs/ai-providers/dist/validation.js +1 -0
- package/dist/libs/contracts/dist/capabilities/openbanking.js +88 -0
- package/dist/libs/contracts/dist/client/index.js +5 -0
- package/dist/libs/contracts/dist/client/react/feature-render.js +2 -0
- package/dist/libs/contracts/dist/client/react/form-render.js +4 -0
- package/dist/libs/contracts/dist/client/react/index.js +4 -0
- package/dist/libs/contracts/dist/contract-registry/index.js +1 -0
- package/dist/libs/contracts/dist/contract-registry/schemas.js +60 -0
- package/dist/libs/contracts/dist/docs/PUBLISHING.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/accessibility_wcag_compliance_specs.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/index.js +29 -0
- package/dist/libs/contracts/dist/docs/presentations.js +71 -0
- package/dist/libs/contracts/dist/docs/registry.js +44 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_1_QUICKSTART.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_2_AI_NATIVE_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_3_AUTO_EVOLUTION.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_4_PERSONALIZATION_ENGINE.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/PHASE_5_ZERO_TOUCH_OPERATIONS.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/auth/better-auth-nextjs.docblock.js +80 -0
- package/dist/libs/contracts/dist/docs/tech/contracts/openapi-export.docblock.js +57 -0
- package/dist/libs/contracts/dist/docs/tech/lifecycle-stage-system.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/llm/llm-integration.docblock.js +357 -0
- package/dist/libs/contracts/dist/docs/tech/mcp-endpoints.docblock.js +37 -0
- package/dist/libs/contracts/dist/docs/tech/presentation-runtime.docblock.js +16 -0
- package/dist/libs/contracts/dist/docs/tech/schema/README.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-events.docblock.js +48 -0
- package/dist/libs/contracts/dist/docs/tech/studio/learning-journeys.docblock.js +79 -0
- package/dist/libs/contracts/dist/docs/tech/studio/platform-admin-panel.docblock.js +84 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-access-teams.docblock.js +45 -0
- package/dist/libs/contracts/dist/docs/tech/studio/project-routing.docblock.js +67 -0
- package/dist/libs/contracts/dist/docs/tech/studio/sandbox-unlogged.docblock.js +40 -0
- package/dist/libs/contracts/dist/docs/tech/studio/team-invitations.docblock.js +69 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspace-ops.docblock.js +47 -0
- package/dist/libs/contracts/dist/docs/tech/studio/workspaces.docblock.js +62 -0
- package/dist/libs/contracts/dist/docs/tech/telemetry-ingest.docblock.js +155 -0
- package/dist/libs/contracts/dist/docs/tech/templates/runtime.docblock.js +20 -0
- package/dist/libs/contracts/dist/docs/tech/vscode-extension.docblock.js +101 -0
- package/dist/libs/contracts/dist/docs/tech/workflows/overview.docblock.js +20 -0
- package/dist/libs/contracts/dist/events.js +8 -0
- package/dist/libs/contracts/dist/experiments/evaluator.js +1 -0
- package/dist/libs/contracts/dist/index.js +72 -0
- package/dist/libs/contracts/dist/install.js +2 -0
- package/dist/libs/contracts/dist/integrations/contracts.js +377 -0
- package/dist/libs/contracts/dist/integrations/index.js +18 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/accounts.js +228 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/balances.js +159 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/index.js +3 -0
- package/dist/libs/contracts/dist/integrations/openbanking/contracts/transactions.js +210 -0
- package/dist/libs/contracts/dist/integrations/openbanking/models.js +242 -0
- package/dist/libs/contracts/dist/integrations/openbanking/telemetry.js +13 -0
- package/dist/libs/contracts/dist/integrations/providers/elevenlabs.js +52 -0
- package/dist/libs/contracts/dist/integrations/providers/gcs-storage.js +75 -0
- package/dist/libs/contracts/dist/integrations/providers/gmail.js +87 -0
- package/dist/libs/contracts/dist/integrations/providers/google-calendar.js +66 -0
- package/dist/libs/contracts/dist/integrations/providers/index.js +11 -0
- package/dist/libs/contracts/dist/integrations/providers/mistral.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/postmark.js +68 -0
- package/dist/libs/contracts/dist/integrations/providers/powens.js +116 -0
- package/dist/libs/contracts/dist/integrations/providers/qdrant.js +73 -0
- package/dist/libs/contracts/dist/integrations/providers/registry.js +10 -0
- package/dist/libs/contracts/dist/integrations/providers/stripe.js +83 -0
- package/dist/libs/contracts/dist/integrations/providers/twilio-sms.js +61 -0
- package/dist/libs/contracts/dist/jsonschema.js +24 -0
- package/dist/libs/contracts/dist/knowledge/contracts.js +306 -0
- package/dist/libs/contracts/dist/knowledge/index.js +7 -0
- package/dist/libs/contracts/dist/knowledge/spaces/email-threads.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-docs.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/financial-overview.js +38 -0
- package/dist/libs/contracts/dist/knowledge/spaces/index.js +6 -0
- package/dist/libs/contracts/dist/knowledge/spaces/product-canon.js +34 -0
- package/dist/libs/contracts/dist/knowledge/spaces/support-faq.js +37 -0
- package/dist/libs/contracts/dist/knowledge/spaces/uploaded-docs.js +34 -0
- package/dist/libs/contracts/dist/llm/exporters.js +352 -0
- package/dist/libs/contracts/dist/llm/index.js +2 -0
- package/dist/libs/contracts/dist/llm/prompts.js +211 -0
- package/dist/libs/contracts/dist/onboarding-base.js +196 -0
- package/dist/libs/contracts/dist/openapi.js +75 -0
- package/dist/libs/contracts/dist/ownership.js +21 -0
- package/dist/libs/contracts/dist/presentations.js +1 -0
- package/dist/libs/contracts/dist/presentations.v2.js +11 -0
- package/dist/libs/contracts/dist/prompt.js +1 -0
- package/dist/libs/contracts/dist/promptRegistry.js +1 -0
- package/dist/libs/contracts/dist/regenerator/index.js +2 -0
- package/dist/libs/contracts/dist/regenerator/service.js +92 -0
- package/dist/libs/contracts/dist/regenerator/utils.js +51 -0
- package/dist/libs/contracts/dist/registry.js +208 -0
- package/dist/libs/contracts/dist/resources.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/EnumType.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/FieldType.js +49 -0
- package/dist/libs/contracts/dist/schema/dist/ScalarTypeEnum.js +236 -0
- package/dist/libs/contracts/dist/schema/dist/SchemaModel.js +34 -0
- package/dist/libs/contracts/dist/schema/dist/entity/defineEntity.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/entity/index.js +2 -0
- package/dist/libs/contracts/dist/schema/dist/entity/types.js +1 -0
- package/dist/libs/contracts/dist/schema/dist/index.js +6 -0
- package/dist/libs/contracts/dist/server/graphql-pothos.js +6 -0
- package/dist/libs/contracts/dist/server/index.js +8 -0
- package/dist/libs/contracts/dist/server/mcp/createMcpServer.js +4 -0
- package/dist/libs/contracts/dist/server/mcp/registerPresentations.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerPrompts.js +1 -0
- package/dist/libs/contracts/dist/server/mcp/registerResources.js +2 -0
- package/dist/libs/contracts/dist/server/mcp/registerTools.js +1 -0
- package/dist/libs/contracts/dist/server/provider-mcp.js +1 -0
- package/dist/libs/contracts/dist/server/rest-elysia.js +1 -0
- package/dist/libs/contracts/dist/server/rest-express.js +1 -0
- package/dist/libs/contracts/dist/server/rest-generic.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-app.js +1 -0
- package/dist/libs/contracts/dist/server/rest-next-pages.js +1 -0
- package/dist/libs/contracts/dist/spec.js +35 -0
- package/dist/libs/contracts/dist/telemetry/index.js +1 -0
- package/dist/libs/contracts/dist/telemetry/tracker.js +1 -0
- package/dist/libs/contracts/dist/tests/index.js +1 -0
- package/dist/libs/contracts/dist/tests/runner.js +150 -0
- package/dist/libs/contracts/dist/workflow/index.js +1 -0
- package/dist/libs/contracts/dist/workflow/runner.js +1 -0
- package/dist/libs/contracts-transformers/dist/common/utils.js +47 -0
- package/dist/libs/contracts-transformers/dist/openapi/exporter.js +1 -0
- package/dist/libs/contracts-transformers/dist/openapi/importer.js +255 -0
- package/dist/libs/contracts-transformers/dist/openapi/index.js +4 -0
- package/dist/libs/contracts-transformers/dist/openapi/parser.js +231 -0
- package/dist/libs/contracts-transformers/dist/openapi/schema-converter.js +201 -0
- package/dist/modules/contractspec-workspace/dist/ai/code-generation.js +137 -0
- package/dist/modules/contractspec-workspace/dist/ai/spec-creation.js +101 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/graph.js +84 -0
- package/dist/modules/contractspec-workspace/dist/analysis/deps/parse-imports.js +30 -0
- package/dist/modules/contractspec-workspace/dist/analysis/diff/semantic.js +96 -0
- package/dist/modules/contractspec-workspace/dist/analysis/feature-scan.js +151 -0
- package/dist/modules/contractspec-workspace/dist/analysis/spec-scan.js +344 -0
- package/dist/modules/contractspec-workspace/dist/analysis/validate/spec-structure.js +122 -0
- package/dist/modules/contractspec-workspace/dist/templates/app-config.js +105 -0
- package/dist/modules/contractspec-workspace/dist/templates/data-view.js +68 -0
- package/dist/modules/contractspec-workspace/dist/templates/event.js +38 -0
- package/dist/modules/contractspec-workspace/dist/templates/experiment.js +87 -0
- package/dist/modules/contractspec-workspace/dist/templates/handler.js +95 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration-utils.js +104 -0
- package/dist/modules/contractspec-workspace/dist/templates/integration.js +62 -0
- package/dist/modules/contractspec-workspace/dist/templates/knowledge.js +68 -0
- package/dist/modules/contractspec-workspace/dist/templates/migration.js +60 -0
- package/dist/modules/contractspec-workspace/dist/templates/operation.js +100 -0
- package/dist/modules/contractspec-workspace/dist/templates/presentation.js +78 -0
- package/dist/modules/contractspec-workspace/dist/templates/telemetry.js +89 -0
- package/dist/modules/contractspec-workspace/dist/templates/utils.js +38 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow-runner.js +48 -0
- package/dist/modules/contractspec-workspace/dist/templates/workflow.js +67 -0
- package/dist/modules/contractspec-workspace/dist/types/generation-types.js +20 -0
- package/dist/services/agent-guide/adapters/claude-code.js +144 -3
- package/dist/services/agent-guide/adapters/cursor-cli.js +135 -3
- package/dist/services/agent-guide/adapters/generic-mcp.js +159 -3
- package/dist/services/agent-guide/adapters/index.js +30 -1
- package/dist/services/agent-guide/agent-guide-service.js +148 -1
- package/dist/services/agent-guide/index.js +5 -1
- package/dist/services/build.js +140 -1
- package/dist/services/ci-check/ci-check-service.js +393 -1
- package/dist/services/ci-check/index.js +2 -1
- package/dist/services/ci-check/types.js +28 -1
- package/dist/services/clean.js +71 -1
- package/dist/services/config.js +76 -1
- package/dist/services/deps.js +62 -1
- package/dist/services/diff.js +33 -1
- package/dist/services/doctor/checks/ai.js +118 -2
- package/dist/services/doctor/checks/cli.js +146 -1
- package/dist/services/doctor/checks/config.js +170 -1
- package/dist/services/doctor/checks/deps.js +180 -1
- package/dist/services/doctor/checks/index.js +6 -1
- package/dist/services/doctor/checks/mcp.js +144 -1
- package/dist/services/doctor/checks/workspace.js +243 -1
- package/dist/services/doctor/doctor-service.js +115 -2
- package/dist/services/doctor/index.js +2 -1
- package/dist/services/doctor/types.js +26 -1
- package/dist/services/implementation/discovery.js +143 -2
- package/dist/services/implementation/index.js +2 -1
- package/dist/services/implementation/resolver.js +223 -1
- package/dist/services/index.js +53 -1
- package/dist/services/integrity-diagram.js +274 -6
- package/dist/services/integrity.js +272 -1
- package/dist/services/list.js +35 -1
- package/dist/services/openapi/export-service.js +51 -2
- package/dist/services/openapi/import-service.js +75 -1
- package/dist/services/openapi/index.js +4 -1
- package/dist/services/openapi/sync-service.js +121 -1
- package/dist/services/openapi/validate-service.js +130 -1
- package/dist/services/regenerator.js +23 -1
- package/dist/services/registry.js +73 -1
- package/dist/services/setup/config-generators.js +113 -26
- package/dist/services/setup/file-merger.js +60 -2
- package/dist/services/setup/index.js +4 -1
- package/dist/services/setup/setup-service.js +95 -1
- package/dist/services/setup/targets/agents-md.js +46 -1
- package/dist/services/setup/targets/cli-config.js +59 -1
- package/dist/services/setup/targets/cursor-rules.js +47 -1
- package/dist/services/setup/targets/mcp-claude.js +59 -1
- package/dist/services/setup/targets/mcp-cursor.js +58 -1
- package/dist/services/setup/targets/vscode-settings.js +62 -1
- package/dist/services/setup/types.js +26 -1
- package/dist/services/sync.js +62 -1
- package/dist/services/test.js +30 -1
- package/dist/services/validate-implementation.js +69 -1
- package/dist/services/validate.js +47 -1
- package/dist/services/verification-cache/adapters/filesystem.js +121 -1
- package/dist/services/verification-cache/adapters/in-memory.js +45 -1
- package/dist/services/verification-cache/adapters/index.js +3 -1
- package/dist/services/verification-cache/adapters/workspace-state.js +90 -1
- package/dist/services/verification-cache/cache-service.js +255 -1
- package/dist/services/verification-cache/index.js +6 -1
- package/dist/services/verification-cache/types.js +15 -1
- package/dist/services/verify/ai-verifier.js +336 -9
- package/dist/services/verify/behavior-verifier.js +185 -1
- package/dist/services/verify/index.js +4 -1
- package/dist/services/verify/structure-verifier.js +195 -2
- package/dist/services/verify/verify-service.js +203 -3
- package/dist/services/watch.js +31 -1
- package/dist/services/workspace-info.js +102 -2
- package/dist/templates/app-config.template.js +101 -28
- package/dist/templates/data-view.template.js +42 -27
- package/dist/templates/event.template.js +29 -14
- package/dist/templates/experiment.template.js +77 -51
- package/dist/templates/handler.template.js +53 -17
- package/dist/templates/index.js +36 -1
- package/dist/templates/integration.template.js +134 -50
- package/dist/templates/knowledge.template.js +62 -21
- package/dist/templates/migration.template.js +50 -26
- package/dist/templates/operation.template.js +44 -28
- package/dist/templates/presentation.template.js +46 -20
- package/dist/templates/telemetry.template.js +74 -53
- package/dist/templates/workflow-runner.template.js +12 -6
- package/dist/templates/workflow.template.js +51 -24
- package/package.json +13 -9
- package/dist/adapters/index.d.ts +0 -7
- package/dist/ports/index.d.ts +0 -5
- package/dist/services/agent-guide/index.d.ts +0 -6
- package/dist/services/ci-check/index.d.ts +0 -2
- package/dist/services/doctor/index.d.ts +0 -2
- package/dist/services/implementation/index.d.ts +0 -3
- package/dist/services/index.d.ts +0 -56
- package/dist/services/openapi/index.d.ts +0 -5
- package/dist/services/verification-cache/adapters/index.d.ts +0 -3
- package/dist/services/verification-cache/index.d.ts +0 -6
- package/dist/services/verify/index.d.ts +0 -5
package/dist/formatters/text.js
CHANGED
|
@@ -1,2 +1,208 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/formatters/text.ts
|
|
2
|
+
/**
|
|
3
|
+
* Format CI check results as text lines.
|
|
4
|
+
* Returns structured lines that can be styled by the CLI.
|
|
5
|
+
*/
|
|
6
|
+
function formatAsTextLines(result, options = {}) {
|
|
7
|
+
const lines = [];
|
|
8
|
+
const { verbose = false, showTiming = true, groupByFile = false } = options;
|
|
9
|
+
lines.push({
|
|
10
|
+
text: "",
|
|
11
|
+
style: "normal"
|
|
12
|
+
});
|
|
13
|
+
lines.push({
|
|
14
|
+
text: "📋 ContractSpec CI Check Results",
|
|
15
|
+
style: "bold"
|
|
16
|
+
});
|
|
17
|
+
lines.push({
|
|
18
|
+
text: "",
|
|
19
|
+
style: "normal"
|
|
20
|
+
});
|
|
21
|
+
if (result.commitSha || result.branch) {
|
|
22
|
+
const gitInfo = [result.branch ? `branch: ${result.branch}` : null, result.commitSha ? `commit: ${result.commitSha.slice(0, 7)}` : null].filter(Boolean).join(", ");
|
|
23
|
+
lines.push({
|
|
24
|
+
text: `Git: ${gitInfo}`,
|
|
25
|
+
style: "muted"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
lines.push({
|
|
29
|
+
text: "",
|
|
30
|
+
style: "normal"
|
|
31
|
+
});
|
|
32
|
+
lines.push({
|
|
33
|
+
text: "Check Results:",
|
|
34
|
+
style: "bold"
|
|
35
|
+
});
|
|
36
|
+
for (const category of result.categories) {
|
|
37
|
+
const icon = category.passed ? "✓" : "✗";
|
|
38
|
+
const style = category.passed ? "success" : "error";
|
|
39
|
+
const stats = formatCategoryStats(category);
|
|
40
|
+
const timing = showTiming ? ` (${category.durationMs}ms)` : "";
|
|
41
|
+
lines.push({
|
|
42
|
+
text: ` ${icon} ${category.label}: ${stats}${timing}`,
|
|
43
|
+
style
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (result.issues.length > 0) {
|
|
47
|
+
lines.push({
|
|
48
|
+
text: "",
|
|
49
|
+
style: "normal"
|
|
50
|
+
});
|
|
51
|
+
lines.push({
|
|
52
|
+
text: "Issues:",
|
|
53
|
+
style: "bold"
|
|
54
|
+
});
|
|
55
|
+
if (groupByFile) {
|
|
56
|
+
const byFile = groupIssuesByFile(result.issues);
|
|
57
|
+
for (const [file, issues] of byFile) {
|
|
58
|
+
lines.push({
|
|
59
|
+
text: "",
|
|
60
|
+
style: "normal"
|
|
61
|
+
});
|
|
62
|
+
lines.push({
|
|
63
|
+
text: ` ${file || "(no file)"}`,
|
|
64
|
+
style: "bold",
|
|
65
|
+
indent: 1
|
|
66
|
+
});
|
|
67
|
+
for (const issue of issues) lines.push(...formatIssueLines(issue, verbose, 2));
|
|
68
|
+
}
|
|
69
|
+
} else {
|
|
70
|
+
const errors = result.issues.filter((i) => i.severity === "error");
|
|
71
|
+
const warnings = result.issues.filter((i) => i.severity === "warning");
|
|
72
|
+
const notes = result.issues.filter((i) => i.severity === "note");
|
|
73
|
+
if (errors.length > 0) {
|
|
74
|
+
lines.push({
|
|
75
|
+
text: "",
|
|
76
|
+
style: "normal"
|
|
77
|
+
});
|
|
78
|
+
lines.push({
|
|
79
|
+
text: " Errors:",
|
|
80
|
+
style: "error",
|
|
81
|
+
indent: 1
|
|
82
|
+
});
|
|
83
|
+
for (const issue of errors) lines.push(...formatIssueLines(issue, verbose, 2));
|
|
84
|
+
}
|
|
85
|
+
if (warnings.length > 0) {
|
|
86
|
+
lines.push({
|
|
87
|
+
text: "",
|
|
88
|
+
style: "normal"
|
|
89
|
+
});
|
|
90
|
+
lines.push({
|
|
91
|
+
text: " Warnings:",
|
|
92
|
+
style: "warning",
|
|
93
|
+
indent: 1
|
|
94
|
+
});
|
|
95
|
+
for (const issue of warnings) lines.push(...formatIssueLines(issue, verbose, 2));
|
|
96
|
+
}
|
|
97
|
+
if (notes.length > 0 && verbose) {
|
|
98
|
+
lines.push({
|
|
99
|
+
text: "",
|
|
100
|
+
style: "normal"
|
|
101
|
+
});
|
|
102
|
+
lines.push({
|
|
103
|
+
text: " Notes:",
|
|
104
|
+
style: "muted",
|
|
105
|
+
indent: 1
|
|
106
|
+
});
|
|
107
|
+
for (const issue of notes) lines.push(...formatIssueLines(issue, verbose, 2));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
lines.push({
|
|
112
|
+
text: "",
|
|
113
|
+
style: "normal"
|
|
114
|
+
});
|
|
115
|
+
lines.push({
|
|
116
|
+
text: "─".repeat(50),
|
|
117
|
+
style: "muted"
|
|
118
|
+
});
|
|
119
|
+
const summaryParts = [
|
|
120
|
+
result.totalErrors > 0 ? `${result.totalErrors} error(s)` : null,
|
|
121
|
+
result.totalWarnings > 0 ? `${result.totalWarnings} warning(s)` : null,
|
|
122
|
+
result.totalNotes > 0 && verbose ? `${result.totalNotes} note(s)` : null
|
|
123
|
+
].filter(Boolean);
|
|
124
|
+
if (summaryParts.length > 0) lines.push({
|
|
125
|
+
text: `Found: ${summaryParts.join(", ")}`,
|
|
126
|
+
style: result.success ? "warning" : "error"
|
|
127
|
+
});
|
|
128
|
+
if (showTiming) lines.push({
|
|
129
|
+
text: `Duration: ${result.durationMs}ms`,
|
|
130
|
+
style: "muted"
|
|
131
|
+
});
|
|
132
|
+
lines.push({
|
|
133
|
+
text: "",
|
|
134
|
+
style: "normal"
|
|
135
|
+
});
|
|
136
|
+
if (result.success) lines.push({
|
|
137
|
+
text: "✅ All CI checks passed!",
|
|
138
|
+
style: "success"
|
|
139
|
+
});
|
|
140
|
+
else lines.push({
|
|
141
|
+
text: "❌ CI checks failed",
|
|
142
|
+
style: "error"
|
|
143
|
+
});
|
|
144
|
+
lines.push({
|
|
145
|
+
text: "",
|
|
146
|
+
style: "normal"
|
|
147
|
+
});
|
|
148
|
+
return lines;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Format CI check results as plain text string.
|
|
152
|
+
*/
|
|
153
|
+
function formatAsText(result, options = {}) {
|
|
154
|
+
return formatAsTextLines(result, options).map((line) => " ".repeat(line.indent ?? 0) + line.text).join("\n");
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Format category stats.
|
|
158
|
+
*/
|
|
159
|
+
function formatCategoryStats(category) {
|
|
160
|
+
const parts = [];
|
|
161
|
+
if (category.errors > 0) parts.push(`${category.errors} error(s)`);
|
|
162
|
+
if (category.warnings > 0) parts.push(`${category.warnings} warning(s)`);
|
|
163
|
+
if (parts.length === 0) return "passed";
|
|
164
|
+
return parts.join(", ");
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Format a single issue as text lines.
|
|
168
|
+
*/
|
|
169
|
+
function formatIssueLines(issue, verbose, baseIndent) {
|
|
170
|
+
const lines = [];
|
|
171
|
+
const icon = issue.severity === "error" ? "✗" : issue.severity === "warning" ? "⚠" : "○";
|
|
172
|
+
const style = issue.severity === "error" ? "error" : issue.severity === "warning" ? "warning" : "muted";
|
|
173
|
+
let mainLine = `${icon} ${issue.message}`;
|
|
174
|
+
if (issue.file) {
|
|
175
|
+
const location = issue.line ? `:${issue.line}` : "";
|
|
176
|
+
mainLine += ` (${issue.file}${location})`;
|
|
177
|
+
}
|
|
178
|
+
lines.push({
|
|
179
|
+
text: mainLine,
|
|
180
|
+
style,
|
|
181
|
+
indent: baseIndent
|
|
182
|
+
});
|
|
183
|
+
if (verbose && issue.context) {
|
|
184
|
+
const contextStr = JSON.stringify(issue.context);
|
|
185
|
+
if (contextStr !== "{}") lines.push({
|
|
186
|
+
text: `Context: ${contextStr}`,
|
|
187
|
+
style: "muted",
|
|
188
|
+
indent: baseIndent + 1
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return lines;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Group issues by file.
|
|
195
|
+
*/
|
|
196
|
+
function groupIssuesByFile(issues) {
|
|
197
|
+
const byFile = /* @__PURE__ */ new Map();
|
|
198
|
+
for (const issue of issues) {
|
|
199
|
+
const file = issue.file ?? "";
|
|
200
|
+
if (!byFile.has(file)) byFile.set(file, []);
|
|
201
|
+
const fileIssues = byFile.get(file);
|
|
202
|
+
if (fileIssues) fileIssues.push(issue);
|
|
203
|
+
}
|
|
204
|
+
return new Map([...byFile.entries()].sort(([a], [b]) => a.localeCompare(b)));
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//#endregion
|
|
208
|
+
export { formatAsText, formatAsTextLines };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { GitAdapter, GitCleanOptions } from "./ports/git.js";
|
|
|
3
3
|
import { WatchEvent, WatchEventHandler, WatchEventType, WatchOptions, Watcher, WatcherAdapter } from "./ports/watcher.js";
|
|
4
4
|
import { AiAdapter, AiGenerateOptions, AiGenerateResult, AiGenerateStructuredOptions, AiValidationResult } from "./ports/ai.js";
|
|
5
5
|
import { LogLevel, LoggerAdapter, ProgressReporter, ProgressUpdate, WorkspaceAdapters } from "./ports/logger.js";
|
|
6
|
-
import "./ports/index.js";
|
|
7
6
|
import { createNodeFsAdapter } from "./adapters/fs.js";
|
|
8
7
|
import { createNodeGitAdapter } from "./adapters/git.js";
|
|
9
8
|
import { createNodeWatcherAdapter } from "./adapters/watcher.js";
|
|
@@ -11,7 +10,6 @@ import { createNodeAiAdapter } from "./adapters/ai.js";
|
|
|
11
10
|
import { createConsoleLoggerAdapter, createNoopLoggerAdapter } from "./adapters/logger.js";
|
|
12
11
|
import { CreateAdaptersOptions, createNodeAdapters } from "./adapters/factory.js";
|
|
13
12
|
import { PackageManager, WorkspaceInfo, detectPackageManager, findPackageRoot, findWorkspaceRoot, getExecCommand, getInstallCommand, getPackageName, getRunCommand, getWorkspaceInfo, getWorkspacePackages, isMonorepo } from "./adapters/workspace.js";
|
|
14
|
-
import "./adapters/index.js";
|
|
15
13
|
import { AgentMode, AiProvider, Config } from "./types/config.js";
|
|
16
14
|
import { ValidateSpecOptions, ValidateSpecResult, validateSpec, validateSpecs } from "./services/validate.js";
|
|
17
15
|
import { ValidateImplementationOptions, ValidateImplementationResult, validateImplementationFiles } from "./services/validate-implementation.js";
|
|
@@ -61,7 +59,6 @@ import { VerificationCacheService, cacheKeyToString, computeContentHash, createV
|
|
|
61
59
|
import { InMemoryCacheStorage, createInMemoryCacheStorage } from "./services/verification-cache/adapters/in-memory.js";
|
|
62
60
|
import { FileSystemCacheStorage, createFileSystemCacheStorage } from "./services/verification-cache/adapters/filesystem.js";
|
|
63
61
|
import { KeyValueStore, WorkspaceStateCacheStorage, createWorkspaceStateCacheStorage } from "./services/verification-cache/adapters/workspace-state.js";
|
|
64
|
-
import "./services/index.js";
|
|
65
62
|
import { index_d_exports as index_d_exports$1 } from "./formatters/index.js";
|
|
66
63
|
import { index_d_exports as index_d_exports$2 } from "./templates/index.js";
|
|
67
64
|
import { index_d_exports } from "./ai/index.js";
|
package/dist/index.js
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DEFAULT_WORKSPACE_CONFIG } from "./modules/contractspec-workspace/dist/types/generation-types.js";
|
|
2
|
+
import { extractEmittedEvents, extractPolicyRefs, extractTestRefs, inferSpecTypeFromFilePath, scanAllSpecsFromSource, scanSpecSource } from "./modules/contractspec-workspace/dist/analysis/spec-scan.js";
|
|
3
|
+
import { isFeatureFile, scanFeatureSource } from "./modules/contractspec-workspace/dist/analysis/feature-scan.js";
|
|
4
|
+
import { computeSemanticDiff } from "./modules/contractspec-workspace/dist/analysis/diff/semantic.js";
|
|
5
|
+
import { addContractNode, buildReverseEdges, createContractGraph, detectCycles, findMissingDependencies, toDot } from "./modules/contractspec-workspace/dist/analysis/deps/graph.js";
|
|
6
|
+
import { parseImportedSpecNames } from "./modules/contractspec-workspace/dist/analysis/deps/parse-imports.js";
|
|
7
|
+
import { validateSpecStructure } from "./modules/contractspec-workspace/dist/analysis/validate/spec-structure.js";
|
|
8
|
+
import { capitalize, escapeString, toCamelCase, toKebabCase, toPascalCase } from "./modules/contractspec-workspace/dist/templates/utils.js";
|
|
9
|
+
import { generateOperationSpec } from "./modules/contractspec-workspace/dist/templates/operation.js";
|
|
10
|
+
import { generateEventSpec } from "./modules/contractspec-workspace/dist/templates/event.js";
|
|
11
|
+
import { generatePresentationSpec } from "./modules/contractspec-workspace/dist/templates/presentation.js";
|
|
12
|
+
import { generateWorkflowSpec } from "./modules/contractspec-workspace/dist/templates/workflow.js";
|
|
13
|
+
import { generateWorkflowRunnerTemplate } from "./modules/contractspec-workspace/dist/templates/workflow-runner.js";
|
|
14
|
+
import { generateDataViewSpec } from "./modules/contractspec-workspace/dist/templates/data-view.js";
|
|
15
|
+
import { generateTelemetrySpec } from "./modules/contractspec-workspace/dist/templates/telemetry.js";
|
|
16
|
+
import { generateExperimentSpec } from "./modules/contractspec-workspace/dist/templates/experiment.js";
|
|
17
|
+
import { generateAppBlueprintSpec } from "./modules/contractspec-workspace/dist/templates/app-config.js";
|
|
18
|
+
import { generateMigrationSpec } from "./modules/contractspec-workspace/dist/templates/migration.js";
|
|
19
|
+
import { generateIntegrationSpec } from "./modules/contractspec-workspace/dist/templates/integration.js";
|
|
20
|
+
import { generateKnowledgeSpaceSpec } from "./modules/contractspec-workspace/dist/templates/knowledge.js";
|
|
21
|
+
import { generateComponentTemplate, generateHandlerTemplate, generateTestTemplate } from "./modules/contractspec-workspace/dist/templates/handler.js";
|
|
22
|
+
import { addExampleContext, buildEventSpecPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, getSystemPrompt } from "./modules/contractspec-workspace/dist/ai/spec-creation.js";
|
|
23
|
+
import { buildComponentPrompt, buildFormPrompt, buildHandlerPrompt, buildTestPrompt, getCodeGenSystemPrompt } from "./modules/contractspec-workspace/dist/ai/code-generation.js";
|
|
24
|
+
import { createNodeFsAdapter } from "./adapters/fs.js";
|
|
25
|
+
import { createNodeGitAdapter } from "./adapters/git.js";
|
|
26
|
+
import { createNodeWatcherAdapter } from "./adapters/watcher.js";
|
|
27
|
+
import { createNodeAiAdapter } from "./adapters/ai.js";
|
|
28
|
+
import { createConsoleLoggerAdapter, createNoopLoggerAdapter } from "./adapters/logger.js";
|
|
29
|
+
import { createNodeAdapters } from "./adapters/factory.js";
|
|
30
|
+
import { detectPackageManager, findPackageRoot, findWorkspaceRoot, getExecCommand, getInstallCommand, getPackageName, getRunCommand, getWorkspaceInfo, getWorkspacePackages, isMonorepo } from "./adapters/workspace.js";
|
|
31
|
+
import "./adapters/index.js";
|
|
32
|
+
import { validateSpec, validateSpecs } from "./services/validate.js";
|
|
33
|
+
import { validateImplementationFiles } from "./services/validate-implementation.js";
|
|
34
|
+
import { compareSpecs } from "./services/diff.js";
|
|
35
|
+
import { analyzeDeps, exportGraphAsDot, getContractNode, getGraphStats } from "./services/deps.js";
|
|
36
|
+
import { groupSpecsByType, listSpecs } from "./services/list.js";
|
|
37
|
+
import { getApiKey, loadWorkspaceConfig, mergeWorkspaceConfig } from "./services/config.js";
|
|
38
|
+
import { buildSpec } from "./services/build.js";
|
|
39
|
+
import { importFromOpenApiService } from "./services/openapi/import-service.js";
|
|
40
|
+
import { syncWithOpenApiService } from "./services/openapi/sync-service.js";
|
|
41
|
+
import { validateAgainstOpenApiService } from "./services/openapi/validate-service.js";
|
|
42
|
+
import { exportOpenApi } from "./services/openapi/export-service.js";
|
|
43
|
+
import { RegistryClient, addToRegistry, listFromRegistry, resolveRegistryUrl, searchRegistry } from "./services/registry.js";
|
|
44
|
+
import { syncSpecs } from "./services/sync.js";
|
|
45
|
+
import { watchSpecs } from "./services/watch.js";
|
|
46
|
+
import { cleanArtifacts } from "./services/clean.js";
|
|
47
|
+
import { runTests } from "./services/test.js";
|
|
48
|
+
import { createRegeneratorService } from "./services/regenerator.js";
|
|
49
|
+
import { findAllConfigFiles, formatWorkspaceInfo, getExtendedWorkspaceInfo, mergeMonorepoConfigs } from "./services/workspace-info.js";
|
|
50
|
+
import { analyzeIntegrity, filterIssuesBySeverity, filterIssuesByType, getAllSpecs } from "./services/integrity.js";
|
|
51
|
+
import { generateMermaidDiagram } from "./services/integrity-diagram.js";
|
|
52
|
+
import { ALL_SETUP_TARGETS, SETUP_TARGET_LABELS } from "./services/setup/types.js";
|
|
53
|
+
import { generateAgentsMd, generateClaudeMcpConfig, generateContractsrcConfig, generateCursorMcpConfig, generateCursorRules, generateVscodeSettings, getClaudeDesktopConfigPath } from "./services/setup/config-generators.js";
|
|
54
|
+
import { deepMergeOverwrite, deepMergePreserve, formatJson, safeParseJson } from "./services/setup/file-merger.js";
|
|
55
|
+
import { runSetup } from "./services/setup/setup-service.js";
|
|
56
|
+
import { ALL_CHECK_CATEGORIES, CHECK_CATEGORY_LABELS } from "./services/doctor/types.js";
|
|
57
|
+
import { formatCheckResult, formatDoctorSummary, runDoctor } from "./services/doctor/doctor-service.js";
|
|
58
|
+
import { ALL_CI_CHECK_CATEGORIES, CI_CHECK_CATEGORY_LABELS } from "./services/ci-check/types.js";
|
|
59
|
+
import { discoverAllImplementations, discoverImplementationsForSpec, extractSpecReferences, inferImplementationType } from "./services/implementation/discovery.js";
|
|
60
|
+
import { getImplementationSummary, resolveAllImplementations, resolveImplementations } from "./services/implementation/resolver.js";
|
|
61
|
+
import { DEFAULT_CACHE_CONFIG } from "./services/verification-cache/types.js";
|
|
62
|
+
import { VerificationCacheService, cacheKeyToString, computeContentHash, createVerificationCacheService, stringToCacheKey } from "./services/verification-cache/cache-service.js";
|
|
63
|
+
import { InMemoryCacheStorage, createInMemoryCacheStorage } from "./services/verification-cache/adapters/in-memory.js";
|
|
64
|
+
import { FileSystemCacheStorage, createFileSystemCacheStorage } from "./services/verification-cache/adapters/filesystem.js";
|
|
65
|
+
import { WorkspaceStateCacheStorage, createWorkspaceStateCacheStorage } from "./services/verification-cache/adapters/workspace-state.js";
|
|
66
|
+
import { runCIChecks } from "./services/ci-check/ci-check-service.js";
|
|
67
|
+
import { ClaudeCodeAdapter, claudeCodeAdapter } from "./services/agent-guide/adapters/claude-code.js";
|
|
68
|
+
import { CursorCLIAdapter, cursorCLIAdapter } from "./services/agent-guide/adapters/cursor-cli.js";
|
|
69
|
+
import { GenericMCPAdapter, genericMCPAdapter } from "./services/agent-guide/adapters/generic-mcp.js";
|
|
70
|
+
import { agentAdapters, getAgentAdapter, listAgentTypes } from "./services/agent-guide/adapters/index.js";
|
|
71
|
+
import { AgentGuideService, agentGuideService, createAgentGuideService } from "./services/agent-guide/agent-guide-service.js";
|
|
72
|
+
import { verifyStructure } from "./services/verify/structure-verifier.js";
|
|
73
|
+
import { verifyBehavior } from "./services/verify/behavior-verifier.js";
|
|
74
|
+
import { createQuickAIReview, verifySemanticFields, verifyWithAI, verifyWithAIEnhanced } from "./services/verify/ai-verifier.js";
|
|
75
|
+
import { VerifyService, createVerifyService, verifyService } from "./services/verify/verify-service.js";
|
|
76
|
+
import "./services/index.js";
|
|
77
|
+
import { formatters_exports } from "./formatters/index.js";
|
|
78
|
+
import { templates_exports } from "./templates/index.js";
|
|
79
|
+
import { ai_exports } from "./ai/index.js";
|
|
80
|
+
|
|
81
|
+
export { ALL_CHECK_CATEGORIES, ALL_CI_CHECK_CATEGORIES, ALL_SETUP_TARGETS, AgentGuideService, CHECK_CATEGORY_LABELS, CI_CHECK_CATEGORY_LABELS, ClaudeCodeAdapter, CursorCLIAdapter, DEFAULT_CACHE_CONFIG, DEFAULT_WORKSPACE_CONFIG, FileSystemCacheStorage, GenericMCPAdapter, InMemoryCacheStorage, RegistryClient, SETUP_TARGET_LABELS, VerificationCacheService, VerifyService, WorkspaceStateCacheStorage, addContractNode, addExampleContext, addToRegistry, agentAdapters, agentGuideService, ai_exports as ai, analyzeDeps, analyzeIntegrity, buildComponentPrompt, buildEventSpecPrompt, buildFormPrompt, buildHandlerPrompt, buildOperationSpecPrompt, buildPresentationSpecPrompt, buildReverseEdges, buildSpec, buildTestPrompt, cacheKeyToString, capitalize, claudeCodeAdapter, cleanArtifacts, compareSpecs, computeContentHash, computeSemanticDiff, createAgentGuideService, createConsoleLoggerAdapter, createContractGraph, createFileSystemCacheStorage, createInMemoryCacheStorage, createNodeAdapters, createNodeAiAdapter, createNodeFsAdapter, createNodeGitAdapter, createNodeWatcherAdapter, createNoopLoggerAdapter, createQuickAIReview, createRegeneratorService, createVerificationCacheService, createVerifyService, createWorkspaceStateCacheStorage, cursorCLIAdapter, deepMergeOverwrite, deepMergePreserve, detectCycles, detectPackageManager, discoverAllImplementations, discoverImplementationsForSpec, escapeString, exportGraphAsDot, exportOpenApi, extractEmittedEvents, extractPolicyRefs, extractSpecReferences, extractTestRefs, filterIssuesBySeverity, filterIssuesByType, findAllConfigFiles, findMissingDependencies, findPackageRoot, findWorkspaceRoot, formatCheckResult, formatDoctorSummary, formatJson, formatWorkspaceInfo, formatters_exports as formatters, generateAgentsMd, generateAppBlueprintSpec, generateClaudeMcpConfig, generateComponentTemplate, generateContractsrcConfig, generateCursorMcpConfig, generateCursorRules, generateDataViewSpec, generateEventSpec, generateExperimentSpec, generateHandlerTemplate, generateIntegrationSpec, generateKnowledgeSpaceSpec, generateMermaidDiagram, generateMigrationSpec, generateOperationSpec, generatePresentationSpec, generateTelemetrySpec, generateTestTemplate, generateVscodeSettings, generateWorkflowRunnerTemplate, generateWorkflowSpec, genericMCPAdapter, getAgentAdapter, getAllSpecs, getApiKey, getClaudeDesktopConfigPath, getCodeGenSystemPrompt, getContractNode, getExecCommand, getExtendedWorkspaceInfo, getGraphStats, getImplementationSummary, getInstallCommand, getPackageName, getRunCommand, getSystemPrompt, getWorkspaceInfo, getWorkspacePackages, groupSpecsByType, importFromOpenApiService, inferImplementationType, inferSpecTypeFromFilePath, isFeatureFile, isMonorepo, listAgentTypes, listFromRegistry, listSpecs, loadWorkspaceConfig, mergeMonorepoConfigs, mergeWorkspaceConfig, parseImportedSpecNames, resolveAllImplementations, resolveImplementations, resolveRegistryUrl, runCIChecks, runDoctor, runSetup, runTests, safeParseJson, scanAllSpecsFromSource, scanFeatureSource, scanSpecSource, searchRegistry, stringToCacheKey, syncSpecs, syncWithOpenApiService, templates_exports as templates, toCamelCase, toDot, toKebabCase, toPascalCase, validateAgainstOpenApiService, validateImplementationFiles, validateSpec, validateSpecStructure, validateSpecs, verifyBehavior, verifySemanticFields, verifyService, verifyStructure, verifyWithAI, verifyWithAIEnhanced, watchSpecs };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { DEFAULT_MODELS, getModelsForProvider } from "./models.js";
|
|
2
|
+
import { anthropic } from "@ai-sdk/anthropic";
|
|
3
|
+
import { openai } from "@ai-sdk/openai";
|
|
4
|
+
import { ollama } from "ollama-ai-provider";
|
|
5
|
+
import { google } from "@ai-sdk/google";
|
|
6
|
+
import { mistral } from "@ai-sdk/mistral";
|
|
7
|
+
|
|
8
|
+
//#region ../../libs/ai-providers/dist/factory.js
|
|
9
|
+
/**
|
|
10
|
+
* Base provider implementation
|
|
11
|
+
*/
|
|
12
|
+
var BaseProvider = class {
|
|
13
|
+
name;
|
|
14
|
+
model;
|
|
15
|
+
mode;
|
|
16
|
+
config;
|
|
17
|
+
cachedModel = null;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.name = config.provider;
|
|
20
|
+
this.model = config.model ?? DEFAULT_MODELS[config.provider];
|
|
21
|
+
this.mode = this.determineMode(config);
|
|
22
|
+
this.config = config;
|
|
23
|
+
}
|
|
24
|
+
determineMode(config) {
|
|
25
|
+
if (config.provider === "ollama") return "local";
|
|
26
|
+
if (config.apiKey) return "byok";
|
|
27
|
+
return "managed";
|
|
28
|
+
}
|
|
29
|
+
getModel() {
|
|
30
|
+
if (!this.cachedModel) this.cachedModel = this.createModel();
|
|
31
|
+
return this.cachedModel;
|
|
32
|
+
}
|
|
33
|
+
createModel() {
|
|
34
|
+
const { apiKey, baseUrl, proxyUrl, organizationId } = this.config;
|
|
35
|
+
switch (this.name) {
|
|
36
|
+
case "ollama": {
|
|
37
|
+
const originalBaseUrl = process.env.OLLAMA_BASE_URL;
|
|
38
|
+
if (baseUrl && baseUrl !== "http://localhost:11434") process.env.OLLAMA_BASE_URL = baseUrl;
|
|
39
|
+
const ollamaModel = ollama(this.model);
|
|
40
|
+
if (originalBaseUrl !== void 0) process.env.OLLAMA_BASE_URL = originalBaseUrl;
|
|
41
|
+
else if (baseUrl && baseUrl !== "http://localhost:11434") delete process.env.OLLAMA_BASE_URL;
|
|
42
|
+
return ollamaModel;
|
|
43
|
+
}
|
|
44
|
+
case "openai":
|
|
45
|
+
if (this.mode === "managed") {
|
|
46
|
+
const originalBaseUrl = process.env.OPENAI_BASE_URL;
|
|
47
|
+
if (proxyUrl) process.env.OPENAI_BASE_URL = proxyUrl;
|
|
48
|
+
const model = openai(this.model);
|
|
49
|
+
if (originalBaseUrl !== void 0) process.env.OPENAI_BASE_URL = originalBaseUrl;
|
|
50
|
+
else if (proxyUrl) delete process.env.OPENAI_BASE_URL;
|
|
51
|
+
return model;
|
|
52
|
+
}
|
|
53
|
+
return openai(this.model);
|
|
54
|
+
case "anthropic":
|
|
55
|
+
if (this.mode === "managed") {
|
|
56
|
+
const originalBaseUrl = process.env.OPENAI_BASE_URL;
|
|
57
|
+
if (proxyUrl) process.env.OPENAI_BASE_URL = proxyUrl;
|
|
58
|
+
const model = openai(this.model);
|
|
59
|
+
if (originalBaseUrl !== void 0) process.env.OPENAI_BASE_URL = originalBaseUrl;
|
|
60
|
+
else if (proxyUrl) delete process.env.OPENAI_BASE_URL;
|
|
61
|
+
return model;
|
|
62
|
+
}
|
|
63
|
+
return anthropic(this.model);
|
|
64
|
+
case "mistral":
|
|
65
|
+
if (this.mode === "managed") {
|
|
66
|
+
const originalBaseUrl = process.env.OPENAI_BASE_URL;
|
|
67
|
+
if (proxyUrl) process.env.OPENAI_BASE_URL = proxyUrl;
|
|
68
|
+
const model = openai(this.model);
|
|
69
|
+
if (originalBaseUrl !== void 0) process.env.OPENAI_BASE_URL = originalBaseUrl;
|
|
70
|
+
else if (proxyUrl) delete process.env.OPENAI_BASE_URL;
|
|
71
|
+
return model;
|
|
72
|
+
}
|
|
73
|
+
return mistral(this.model);
|
|
74
|
+
case "gemini":
|
|
75
|
+
if (this.mode === "managed") {
|
|
76
|
+
const originalBaseUrl = process.env.OPENAI_BASE_URL;
|
|
77
|
+
if (proxyUrl) process.env.OPENAI_BASE_URL = proxyUrl;
|
|
78
|
+
const model = openai(this.model);
|
|
79
|
+
if (originalBaseUrl !== void 0) process.env.OPENAI_BASE_URL = originalBaseUrl;
|
|
80
|
+
else if (proxyUrl) delete process.env.OPENAI_BASE_URL;
|
|
81
|
+
return model;
|
|
82
|
+
}
|
|
83
|
+
return google(this.model);
|
|
84
|
+
default: throw new Error(`Unknown provider: ${this.name}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
async listModels() {
|
|
88
|
+
if (this.name === "ollama") return this.listOllamaModels();
|
|
89
|
+
return getModelsForProvider(this.name);
|
|
90
|
+
}
|
|
91
|
+
async listOllamaModels() {
|
|
92
|
+
try {
|
|
93
|
+
const baseUrl = this.config.baseUrl ?? "http://localhost:11434";
|
|
94
|
+
const response = await fetch(`${baseUrl}/api/tags`);
|
|
95
|
+
if (!response.ok) return getModelsForProvider("ollama");
|
|
96
|
+
return ((await response.json()).models ?? []).map((m) => ({
|
|
97
|
+
id: m.name,
|
|
98
|
+
name: m.name,
|
|
99
|
+
provider: "ollama",
|
|
100
|
+
contextWindow: 8e3,
|
|
101
|
+
capabilities: {
|
|
102
|
+
vision: false,
|
|
103
|
+
tools: false,
|
|
104
|
+
reasoning: false,
|
|
105
|
+
streaming: true
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
} catch {
|
|
109
|
+
return getModelsForProvider("ollama");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async validate() {
|
|
113
|
+
if (this.name === "ollama") return this.validateOllama();
|
|
114
|
+
if (this.mode === "byok" && !this.config.apiKey) return {
|
|
115
|
+
valid: false,
|
|
116
|
+
error: `API key required for ${this.name}`
|
|
117
|
+
};
|
|
118
|
+
if (this.mode === "managed" && !this.config.proxyUrl && !this.config.organizationId) return {
|
|
119
|
+
valid: false,
|
|
120
|
+
error: "Managed mode requires proxyUrl or organizationId"
|
|
121
|
+
};
|
|
122
|
+
return { valid: true };
|
|
123
|
+
}
|
|
124
|
+
async validateOllama() {
|
|
125
|
+
try {
|
|
126
|
+
const baseUrl = this.config.baseUrl ?? "http://localhost:11434";
|
|
127
|
+
const response = await fetch(`${baseUrl}/api/tags`);
|
|
128
|
+
if (!response.ok) return {
|
|
129
|
+
valid: false,
|
|
130
|
+
error: `Ollama server returned ${response.status}`
|
|
131
|
+
};
|
|
132
|
+
const models = (await response.json()).models ?? [];
|
|
133
|
+
if (!models.some((m) => m.name === this.model)) return {
|
|
134
|
+
valid: false,
|
|
135
|
+
error: `Model "${this.model}" not found. Available: ${models.map((m) => m.name).join(", ")}`
|
|
136
|
+
};
|
|
137
|
+
return { valid: true };
|
|
138
|
+
} catch (error) {
|
|
139
|
+
return {
|
|
140
|
+
valid: false,
|
|
141
|
+
error: `Cannot connect to Ollama at ${this.config.baseUrl ?? "http://localhost:11434"}: ${error instanceof Error ? error.message : String(error)}`
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Create a provider from configuration
|
|
148
|
+
*/
|
|
149
|
+
function createProvider(config) {
|
|
150
|
+
return new BaseProvider(config);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
//#endregion
|
|
154
|
+
export { createProvider };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { getRecommendedModels } from "./models.js";
|
|
2
|
+
import { createProvider } from "./factory.js";
|
|
3
|
+
|
|
4
|
+
//#region ../../libs/ai-providers/dist/legacy.js
|
|
5
|
+
/**
|
|
6
|
+
* Map legacy provider names to new ones
|
|
7
|
+
*/
|
|
8
|
+
function mapLegacyProvider(legacy) {
|
|
9
|
+
switch (legacy) {
|
|
10
|
+
case "claude": return "anthropic";
|
|
11
|
+
case "custom": return "openai";
|
|
12
|
+
default: return legacy;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get AI provider from legacy Config type
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use createProvider() instead
|
|
19
|
+
*/
|
|
20
|
+
function getAIProvider(config) {
|
|
21
|
+
const provider = mapLegacyProvider(config.aiProvider);
|
|
22
|
+
let apiKey;
|
|
23
|
+
switch (provider) {
|
|
24
|
+
case "openai":
|
|
25
|
+
apiKey = process.env.OPENAI_API_KEY;
|
|
26
|
+
break;
|
|
27
|
+
case "anthropic":
|
|
28
|
+
apiKey = process.env.ANTHROPIC_API_KEY;
|
|
29
|
+
break;
|
|
30
|
+
case "mistral":
|
|
31
|
+
apiKey = process.env.MISTRAL_API_KEY;
|
|
32
|
+
break;
|
|
33
|
+
case "gemini":
|
|
34
|
+
apiKey = process.env.GOOGLE_API_KEY ?? process.env.GEMINI_API_KEY;
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
return createProvider({
|
|
38
|
+
provider,
|
|
39
|
+
model: config.aiModel,
|
|
40
|
+
apiKey,
|
|
41
|
+
baseUrl: config.customEndpoint
|
|
42
|
+
}).getModel();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Validate provider from legacy Config type
|
|
46
|
+
*
|
|
47
|
+
* @deprecated Use validateProvider() from './validation' instead
|
|
48
|
+
*/
|
|
49
|
+
async function validateProvider(config) {
|
|
50
|
+
const provider = mapLegacyProvider(config.aiProvider);
|
|
51
|
+
if (provider === "ollama") return { success: true };
|
|
52
|
+
if (provider === "anthropic" && !process.env.ANTHROPIC_API_KEY) return {
|
|
53
|
+
success: false,
|
|
54
|
+
error: "ANTHROPIC_API_KEY environment variable not set"
|
|
55
|
+
};
|
|
56
|
+
if (provider === "openai" && !process.env.OPENAI_API_KEY) return {
|
|
57
|
+
success: false,
|
|
58
|
+
error: "OPENAI_API_KEY environment variable not set"
|
|
59
|
+
};
|
|
60
|
+
if (provider === "mistral" && !process.env.MISTRAL_API_KEY) return {
|
|
61
|
+
success: false,
|
|
62
|
+
error: "MISTRAL_API_KEY environment variable not set"
|
|
63
|
+
};
|
|
64
|
+
if (provider === "gemini" && !process.env.GOOGLE_API_KEY && !process.env.GEMINI_API_KEY) return {
|
|
65
|
+
success: false,
|
|
66
|
+
error: "GOOGLE_API_KEY or GEMINI_API_KEY environment variable not set"
|
|
67
|
+
};
|
|
68
|
+
return { success: true };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//#endregion
|
|
72
|
+
export { getAIProvider, validateProvider };
|