@treeseed/sdk 0.3.4 → 0.4.1
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/README.md +22 -3
- package/dist/fixture-support.d.ts +24 -0
- package/dist/fixture-support.js +337 -0
- package/dist/index.d.ts +1 -7
- package/dist/index.js +0 -6
- package/dist/operations/runtime.js +1 -1
- package/dist/operations/services/config-runtime.d.ts +5 -5
- package/dist/operations/services/config-runtime.js +1 -1
- package/dist/operations/services/deploy.js +1 -1
- package/dist/operations/services/runtime-paths.d.ts +1 -0
- package/dist/operations/services/runtime-paths.js +3 -1
- package/dist/operations/services/runtime-tools.js +1 -1
- package/dist/operations/services/template-registry.d.ts +3 -3
- package/dist/operations/services/template-registry.js +5 -4
- package/dist/platform/books-data.d.ts +29 -1
- package/dist/platform/books-data.js +82 -1
- package/dist/platform/deploy-config.d.ts +4 -1
- package/dist/platform/deploy-config.js +222 -1
- package/dist/platform/deploy-runtime.js +1 -1
- package/dist/platform/environment.d.ts +1 -1
- package/dist/platform/environment.js +3 -3
- package/dist/platform/plugin.d.ts +51 -2
- package/dist/platform/plugin.js +3 -1
- package/dist/platform/plugins/constants.d.ts +1 -1
- package/dist/platform/plugins/constants.js +1 -1
- package/dist/platform/plugins/runtime.d.ts +1 -1
- package/dist/platform/plugins/runtime.js +5 -5
- package/dist/platform/plugins.d.ts +2 -2
- package/dist/platform/plugins.js +1 -1
- package/dist/platform/tenant/runtime-config.js +1 -1
- package/dist/platform/tenant-config.d.ts +7 -1
- package/dist/platform/tenant-config.js +153 -1
- package/dist/plugin-default.d.ts +25 -0
- package/dist/plugin-default.js +37 -0
- package/dist/scripts/aggregate-book.js +1 -1
- package/dist/scripts/build-tenant-worker.js +2 -2
- package/dist/scripts/tenant-destroy.js +1 -1
- package/dist/scripts/tenant-dev.js +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +1 -1
- package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +6 -0
- package/package.json +9 -25
- package/dist/platform/deploy/config.d.ts +0 -4
- package/dist/platform/deploy/config.js +0 -222
- package/dist/platform/plugins/plugin.d.ts +0 -51
- package/dist/platform/plugins/plugin.js +0 -6
- package/dist/platform/tenant/config.d.ts +0 -9
- package/dist/platform/tenant/config.js +0 -154
- package/dist/platform/utils/books-data.d.ts +0 -29
- package/dist/platform/utils/books-data.js +0 -82
- package/dist/utils/agents/contracts/messages.d.ts +0 -88
- package/dist/utils/agents/contracts/messages.js +0 -139
- package/dist/utils/agents/contracts/run.d.ts +0 -20
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +0 -117
- package/dist/utils/agents/runtime-types.js +0 -4
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
id: string;
|
|
3
|
+
provides: {
|
|
4
|
+
forms: string[];
|
|
5
|
+
operations: string[];
|
|
6
|
+
agents: {
|
|
7
|
+
execution: string[];
|
|
8
|
+
mutation: string[];
|
|
9
|
+
repository: string[];
|
|
10
|
+
verification: string[];
|
|
11
|
+
notification: string[];
|
|
12
|
+
research: string[];
|
|
13
|
+
handlers: string[];
|
|
14
|
+
};
|
|
15
|
+
deploy: string[];
|
|
16
|
+
content: {
|
|
17
|
+
docs: string[];
|
|
18
|
+
};
|
|
19
|
+
site: string[];
|
|
20
|
+
};
|
|
21
|
+
graphRankingProviders: {
|
|
22
|
+
default: import("./sdk-types.ts").SdkGraphRankingProvider;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { createDefaultGraphRankingProvider } from "./graph/ranking.js";
|
|
2
|
+
import { defineTreeseedPlugin } from "./platform/plugin.js";
|
|
3
|
+
var plugin_default_default = defineTreeseedPlugin({
|
|
4
|
+
id: "treeseed-sdk-default",
|
|
5
|
+
provides: {
|
|
6
|
+
forms: ["store_only", "notify_admin", "full_email"],
|
|
7
|
+
operations: ["default"],
|
|
8
|
+
agents: {
|
|
9
|
+
execution: ["stub", "manual", "copilot"],
|
|
10
|
+
mutation: ["local_branch"],
|
|
11
|
+
repository: ["stub", "git"],
|
|
12
|
+
verification: ["stub", "local"],
|
|
13
|
+
notification: ["stub"],
|
|
14
|
+
research: ["stub"],
|
|
15
|
+
handlers: [
|
|
16
|
+
"planner",
|
|
17
|
+
"architect",
|
|
18
|
+
"engineer",
|
|
19
|
+
"notifier",
|
|
20
|
+
"researcher",
|
|
21
|
+
"reviewer",
|
|
22
|
+
"releaser"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
deploy: ["cloudflare"],
|
|
26
|
+
content: {
|
|
27
|
+
docs: ["default"]
|
|
28
|
+
},
|
|
29
|
+
site: ["default"]
|
|
30
|
+
},
|
|
31
|
+
graphRankingProviders: {
|
|
32
|
+
default: createDefaultGraphRankingProvider()
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export {
|
|
36
|
+
plugin_default_default as default
|
|
37
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { buildTenantBookRuntime } from '../platform/utils/books-data.js';
|
|
4
|
-
import { loadTreeseedManifest } from '../platform/tenant
|
|
4
|
+
import { loadTreeseedManifest } from '../platform/tenant-config.js';
|
|
5
5
|
const PROJECT_TENANT = loadTreeseedManifest();
|
|
6
6
|
const { BOOKS, TREESEED_LIBRARY_DOWNLOAD } = buildTenantBookRuntime(PROJECT_TENANT, {
|
|
7
7
|
projectRoot: PROJECT_TENANT.__tenantRoot ?? process.cwd(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { dirname, resolve } from 'node:path';
|
|
3
3
|
import { build } from 'esbuild';
|
|
4
|
-
import { loadTreeseedDeployConfig } from '../platform/deploy
|
|
5
|
-
import { loadTreeseedManifest } from '../platform/tenant
|
|
4
|
+
import { loadTreeseedDeployConfig } from '../platform/deploy-config.js';
|
|
5
|
+
import { loadTreeseedManifest } from '../platform/tenant-config.js';
|
|
6
6
|
import { parseSiteConfig } from '../platform/utils/site-config-schema.js';
|
|
7
7
|
import { corePackageRoot } from '../operations/services/runtime-tools.js';
|
|
8
8
|
const tenantRoot = process.cwd();
|
|
@@ -3,7 +3,7 @@ import readline from 'node:readline/promises';
|
|
|
3
3
|
import { stdin as input, stdout as output } from 'node:process';
|
|
4
4
|
import { applyTreeseedEnvironmentToProcess, assertTreeseedCommandEnvironment } from '../operations/services/config-runtime.js';
|
|
5
5
|
import { cleanupDestroyedState, createPersistentDeployTarget, destroyCloudflareResources, loadDeployState, printDestroySummary, validateDestroyPrerequisites, } from '../operations/services/deploy.js';
|
|
6
|
-
import { deriveCloudflareWorkerName } from '../platform/deploy
|
|
6
|
+
import { deriveCloudflareWorkerName } from '../platform/deploy-config.js';
|
|
7
7
|
const tenantRoot = process.cwd();
|
|
8
8
|
function parseArgs(argv) {
|
|
9
9
|
const parsed = {
|
|
@@ -2,7 +2,7 @@ import { spawnSync } from 'node:child_process';
|
|
|
2
2
|
import { corePackageRoot, packageScriptPath, spawnNodeBinary, resolveWranglerBin } from '../operations/services/runtime-tools.js';
|
|
3
3
|
import { applyTreeseedEnvironmentToProcess, assertTreeseedCommandEnvironment } from '../operations/services/config-runtime.js';
|
|
4
4
|
import { ensureGeneratedWranglerConfig } from '../operations/services/deploy.js';
|
|
5
|
-
import { loadTreeseedDeployConfig } from '../platform/deploy
|
|
5
|
+
import { loadTreeseedDeployConfig } from '../platform/deploy-config.js';
|
|
6
6
|
import { createTenantWatchEntries, isEditablePackageWorkspace, startPollingWatch, stopManagedProcess, writeDevReloadStamp, workspaceSdkRoot, } from '../operations/services/watch-dev.js';
|
|
7
7
|
const tenantRoot = process.cwd();
|
|
8
8
|
const cliArgs = process.argv.slice(2);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Shared Treeseed SDK for content-backed and D1-backed object models.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -87,6 +87,10 @@
|
|
|
87
87
|
"types": "./dist/verification.d.ts",
|
|
88
88
|
"default": "./dist/verification.js"
|
|
89
89
|
},
|
|
90
|
+
"./fixture-support": {
|
|
91
|
+
"types": "./dist/fixture-support.d.ts",
|
|
92
|
+
"default": "./dist/fixture-support.js"
|
|
93
|
+
},
|
|
90
94
|
"./scripts/verify-driver": "./scripts/verify-driver.mjs",
|
|
91
95
|
"./workflow-support": {
|
|
92
96
|
"types": "./dist/workflow-support.d.ts",
|
|
@@ -120,6 +124,10 @@
|
|
|
120
124
|
"types": "./dist/platform/plugin.d.ts",
|
|
121
125
|
"default": "./dist/platform/plugin.js"
|
|
122
126
|
},
|
|
127
|
+
"./plugin-default": {
|
|
128
|
+
"types": "./dist/plugin-default.d.ts",
|
|
129
|
+
"default": "./dist/plugin-default.js"
|
|
130
|
+
},
|
|
123
131
|
"./platform/books-data": {
|
|
124
132
|
"types": "./dist/platform/books-data.d.ts",
|
|
125
133
|
"default": "./dist/platform/books-data.js"
|
|
@@ -180,26 +188,14 @@
|
|
|
180
188
|
"types": "./dist/types/agents.d.ts",
|
|
181
189
|
"default": "./dist/types/agents.js"
|
|
182
190
|
},
|
|
183
|
-
"./types/agents.js": {
|
|
184
|
-
"types": "./dist/types/agents.d.ts",
|
|
185
|
-
"default": "./dist/types/agents.js"
|
|
186
|
-
},
|
|
187
191
|
"./types/cloudflare": {
|
|
188
192
|
"types": "./dist/types/cloudflare.d.ts",
|
|
189
193
|
"default": "./dist/types/cloudflare.js"
|
|
190
194
|
},
|
|
191
|
-
"./types/cloudflare.js": {
|
|
192
|
-
"types": "./dist/types/cloudflare.d.ts",
|
|
193
|
-
"default": "./dist/types/cloudflare.js"
|
|
194
|
-
},
|
|
195
195
|
"./wrangler-d1": {
|
|
196
196
|
"types": "./dist/wrangler-d1.d.ts",
|
|
197
197
|
"default": "./dist/wrangler-d1.js"
|
|
198
198
|
},
|
|
199
|
-
"./wrangler-d1.js": {
|
|
200
|
-
"types": "./dist/wrangler-d1.d.ts",
|
|
201
|
-
"default": "./dist/wrangler-d1.js"
|
|
202
|
-
},
|
|
203
199
|
"./stores/cursor-store": {
|
|
204
200
|
"types": "./dist/stores/cursor-store.d.ts",
|
|
205
201
|
"default": "./dist/stores/cursor-store.js"
|
|
@@ -223,18 +219,6 @@
|
|
|
223
219
|
"./stores/subscription-store": {
|
|
224
220
|
"types": "./dist/stores/subscription-store.d.ts",
|
|
225
221
|
"default": "./dist/stores/subscription-store.js"
|
|
226
|
-
},
|
|
227
|
-
"./utils/agents/runtime-types": {
|
|
228
|
-
"types": "./dist/utils/agents/runtime-types.d.ts",
|
|
229
|
-
"default": "./dist/utils/agents/runtime-types.js"
|
|
230
|
-
},
|
|
231
|
-
"./utils/agents/contracts/messages": {
|
|
232
|
-
"types": "./dist/utils/agents/contracts/messages.d.ts",
|
|
233
|
-
"default": "./dist/utils/agents/contracts/messages.js"
|
|
234
|
-
},
|
|
235
|
-
"./utils/agents/contracts/run": {
|
|
236
|
-
"types": "./dist/utils/agents/contracts/run.d.ts",
|
|
237
|
-
"default": "./dist/utils/agents/contracts/run.js"
|
|
238
222
|
}
|
|
239
223
|
}
|
|
240
224
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TreeseedDeployConfig } from '../contracts.ts';
|
|
2
|
-
export declare function resolveTreeseedDeployConfigPath(configPath?: string): string;
|
|
3
|
-
export declare function deriveCloudflareWorkerName(config: TreeseedDeployConfig): string;
|
|
4
|
-
export declare function loadTreeseedDeployConfig(configPath?: string): TreeseedDeployConfig;
|
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { parse as parseYaml } from "yaml";
|
|
4
|
-
import { normalizeAliasedRecord } from "../../field-aliases.js";
|
|
5
|
-
import { resolveTreeseedTenantRoot } from "../tenant/config.js";
|
|
6
|
-
import {
|
|
7
|
-
TREESEED_DEFAULT_PLUGIN_REFERENCES,
|
|
8
|
-
TREESEED_DEFAULT_PROVIDER_SELECTIONS
|
|
9
|
-
} from "../plugins/constants.js";
|
|
10
|
-
const deployConfigFieldAliases = {
|
|
11
|
-
siteUrl: { key: "siteUrl", aliases: ["site_url"] },
|
|
12
|
-
contactEmail: { key: "contactEmail", aliases: ["contact_email"] }
|
|
13
|
-
};
|
|
14
|
-
const cloudflareFieldAliases = {
|
|
15
|
-
accountId: { key: "accountId", aliases: ["account_id"] },
|
|
16
|
-
workerName: { key: "workerName", aliases: ["worker_name"] }
|
|
17
|
-
};
|
|
18
|
-
const CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER = "replace-with-cloudflare-account-id";
|
|
19
|
-
function expectString(value, label) {
|
|
20
|
-
if (typeof value !== "string" || !value.trim()) {
|
|
21
|
-
throw new Error(`Invalid deploy config: expected ${label} to be a non-empty string.`);
|
|
22
|
-
}
|
|
23
|
-
return value.trim();
|
|
24
|
-
}
|
|
25
|
-
function optionalString(value) {
|
|
26
|
-
if (typeof value !== "string" || !value.trim()) {
|
|
27
|
-
return void 0;
|
|
28
|
-
}
|
|
29
|
-
return value.trim();
|
|
30
|
-
}
|
|
31
|
-
function optionalCloudflareAccountId(value) {
|
|
32
|
-
const accountId = optionalString(value);
|
|
33
|
-
return accountId === CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER ? void 0 : accountId;
|
|
34
|
-
}
|
|
35
|
-
function optionalBoolean(value, label) {
|
|
36
|
-
if (value === void 0) {
|
|
37
|
-
return void 0;
|
|
38
|
-
}
|
|
39
|
-
if (typeof value !== "boolean") {
|
|
40
|
-
throw new Error(`Invalid deploy config: expected ${label} to be a boolean when provided.`);
|
|
41
|
-
}
|
|
42
|
-
return value;
|
|
43
|
-
}
|
|
44
|
-
function optionalRecord(value, label) {
|
|
45
|
-
if (value === void 0 || value === null) {
|
|
46
|
-
return void 0;
|
|
47
|
-
}
|
|
48
|
-
if (typeof value !== "object" || Array.isArray(value)) {
|
|
49
|
-
throw new Error(`Invalid deploy config: expected ${label} to be an object when provided.`);
|
|
50
|
-
}
|
|
51
|
-
return value;
|
|
52
|
-
}
|
|
53
|
-
function parsePluginReferences(value) {
|
|
54
|
-
if (value === void 0) {
|
|
55
|
-
return [...TREESEED_DEFAULT_PLUGIN_REFERENCES];
|
|
56
|
-
}
|
|
57
|
-
if (!Array.isArray(value)) {
|
|
58
|
-
throw new Error("Invalid deploy config: expected plugins to be an array.");
|
|
59
|
-
}
|
|
60
|
-
return value.map((entry, index) => {
|
|
61
|
-
const record = optionalRecord(entry, `plugins[${index}]`);
|
|
62
|
-
return {
|
|
63
|
-
package: expectString(record?.package, `plugins[${index}].package`),
|
|
64
|
-
enabled: record?.enabled === void 0 ? true : optionalBoolean(record.enabled, `plugins[${index}].enabled`),
|
|
65
|
-
config: record?.config === void 0 ? {} : optionalRecord(record.config, `plugins[${index}].config`)
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
function parseProviderSelections(value) {
|
|
70
|
-
const record = optionalRecord(value, "providers");
|
|
71
|
-
if (!record) {
|
|
72
|
-
return structuredClone(TREESEED_DEFAULT_PROVIDER_SELECTIONS);
|
|
73
|
-
}
|
|
74
|
-
const agentProviders = optionalRecord(record.agents, "providers.agents") ?? {};
|
|
75
|
-
const contentProviders = optionalRecord(record.content, "providers.content") ?? {};
|
|
76
|
-
return {
|
|
77
|
-
forms: expectString(record.forms ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.forms, "providers.forms"),
|
|
78
|
-
operations: expectString(record.operations ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.operations, "providers.operations"),
|
|
79
|
-
agents: {
|
|
80
|
-
execution: expectString(
|
|
81
|
-
agentProviders.execution ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.execution,
|
|
82
|
-
"providers.agents.execution"
|
|
83
|
-
),
|
|
84
|
-
mutation: expectString(
|
|
85
|
-
agentProviders.mutation ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.mutation,
|
|
86
|
-
"providers.agents.mutation"
|
|
87
|
-
),
|
|
88
|
-
repository: expectString(
|
|
89
|
-
agentProviders.repository ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.repository,
|
|
90
|
-
"providers.agents.repository"
|
|
91
|
-
),
|
|
92
|
-
verification: expectString(
|
|
93
|
-
agentProviders.verification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.verification,
|
|
94
|
-
"providers.agents.verification"
|
|
95
|
-
),
|
|
96
|
-
notification: expectString(
|
|
97
|
-
agentProviders.notification ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.notification,
|
|
98
|
-
"providers.agents.notification"
|
|
99
|
-
),
|
|
100
|
-
research: expectString(
|
|
101
|
-
agentProviders.research ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.agents.research,
|
|
102
|
-
"providers.agents.research"
|
|
103
|
-
)
|
|
104
|
-
},
|
|
105
|
-
deploy: expectString(record.deploy ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.deploy, "providers.deploy"),
|
|
106
|
-
content: {
|
|
107
|
-
docs: expectString(
|
|
108
|
-
contentProviders.docs ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.content.docs,
|
|
109
|
-
"providers.content.docs"
|
|
110
|
-
)
|
|
111
|
-
},
|
|
112
|
-
site: expectString(record.site ?? TREESEED_DEFAULT_PROVIDER_SELECTIONS.site, "providers.site")
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
function parseServiceEnvironmentConfig(value, label) {
|
|
116
|
-
const record = optionalRecord(value, label) ?? {};
|
|
117
|
-
return {
|
|
118
|
-
baseUrl: optionalString(record.baseUrl),
|
|
119
|
-
domain: optionalString(record.domain),
|
|
120
|
-
railwayEnvironment: optionalString(record.railwayEnvironment)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
function parseManagedServiceConfig(value, label) {
|
|
124
|
-
const record = optionalRecord(value, label);
|
|
125
|
-
if (!record) {
|
|
126
|
-
return void 0;
|
|
127
|
-
}
|
|
128
|
-
const railway = optionalRecord(record.railway, `${label}.railway`) ?? {};
|
|
129
|
-
const environments = optionalRecord(record.environments, `${label}.environments`) ?? {};
|
|
130
|
-
return {
|
|
131
|
-
enabled: record.enabled === void 0 ? void 0 : optionalBoolean(record.enabled, `${label}.enabled`),
|
|
132
|
-
provider: optionalString(record.provider),
|
|
133
|
-
rootDir: optionalString(record.rootDir),
|
|
134
|
-
publicBaseUrl: optionalString(record.publicBaseUrl),
|
|
135
|
-
railway: {
|
|
136
|
-
projectId: optionalString(railway.projectId),
|
|
137
|
-
projectName: optionalString(railway.projectName),
|
|
138
|
-
serviceId: optionalString(railway.serviceId),
|
|
139
|
-
serviceName: optionalString(railway.serviceName),
|
|
140
|
-
rootDir: optionalString(railway.rootDir),
|
|
141
|
-
buildCommand: optionalString(railway.buildCommand),
|
|
142
|
-
startCommand: optionalString(railway.startCommand)
|
|
143
|
-
},
|
|
144
|
-
environments: {
|
|
145
|
-
local: parseServiceEnvironmentConfig(environments.local, `${label}.environments.local`),
|
|
146
|
-
staging: parseServiceEnvironmentConfig(environments.staging, `${label}.environments.staging`),
|
|
147
|
-
prod: parseServiceEnvironmentConfig(environments.prod, `${label}.environments.prod`)
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
function parseManagedServicesConfig(value) {
|
|
152
|
-
const record = optionalRecord(value, "services");
|
|
153
|
-
if (!record) {
|
|
154
|
-
return void 0;
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
api: parseManagedServiceConfig(record.api, "services.api"),
|
|
158
|
-
agents: parseManagedServiceConfig(record.agents, "services.agents")
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
function parseDeployConfig(raw) {
|
|
162
|
-
const parsed = normalizeAliasedRecord(
|
|
163
|
-
deployConfigFieldAliases,
|
|
164
|
-
parseYaml(raw) ?? {}
|
|
165
|
-
);
|
|
166
|
-
const cloudflare = normalizeAliasedRecord(
|
|
167
|
-
cloudflareFieldAliases,
|
|
168
|
-
optionalRecord(parsed.cloudflare, "cloudflare") ?? {}
|
|
169
|
-
);
|
|
170
|
-
const smtp = optionalRecord(parsed.smtp, "smtp") ?? {};
|
|
171
|
-
const turnstile = optionalRecord(parsed.turnstile, "turnstile") ?? {};
|
|
172
|
-
optionalBoolean(turnstile.enabled, "turnstile.enabled");
|
|
173
|
-
return {
|
|
174
|
-
name: expectString(parsed.name, "name"),
|
|
175
|
-
slug: expectString(parsed.slug, "slug"),
|
|
176
|
-
siteUrl: expectString(parsed.siteUrl, "siteUrl"),
|
|
177
|
-
contactEmail: expectString(parsed.contactEmail, "contactEmail"),
|
|
178
|
-
cloudflare: {
|
|
179
|
-
accountId: optionalCloudflareAccountId(cloudflare.accountId) ?? optionalCloudflareAccountId(process.env.CLOUDFLARE_ACCOUNT_ID) ?? CLOUDFLARE_ACCOUNT_ID_PLACEHOLDER,
|
|
180
|
-
workerName: optionalString(cloudflare.workerName)
|
|
181
|
-
},
|
|
182
|
-
plugins: parsePluginReferences(parsed.plugins),
|
|
183
|
-
providers: parseProviderSelections(parsed.providers),
|
|
184
|
-
services: parseManagedServicesConfig(parsed.services),
|
|
185
|
-
smtp: {
|
|
186
|
-
enabled: optionalBoolean(smtp.enabled, "smtp.enabled")
|
|
187
|
-
},
|
|
188
|
-
turnstile: {
|
|
189
|
-
enabled: true
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
function resolveTreeseedDeployConfigPath(configPath = "treeseed.site.yaml") {
|
|
194
|
-
const tenantRoot = resolveTreeseedTenantRoot();
|
|
195
|
-
const candidate = resolve(tenantRoot, configPath);
|
|
196
|
-
if (!existsSync(candidate)) {
|
|
197
|
-
throw new Error(`Unable to resolve Treeseed deploy config at "${candidate}".`);
|
|
198
|
-
}
|
|
199
|
-
return candidate;
|
|
200
|
-
}
|
|
201
|
-
function deriveCloudflareWorkerName(config) {
|
|
202
|
-
return config.cloudflare.workerName?.trim() || config.slug;
|
|
203
|
-
}
|
|
204
|
-
function loadTreeseedDeployConfig(configPath = "treeseed.site.yaml") {
|
|
205
|
-
const resolvedConfigPath = resolveTreeseedDeployConfigPath(configPath);
|
|
206
|
-
const tenantRoot = dirname(resolvedConfigPath);
|
|
207
|
-
const parsed = parseDeployConfig(readFileSync(resolvedConfigPath, "utf8"));
|
|
208
|
-
Object.defineProperty(parsed, "__tenantRoot", {
|
|
209
|
-
value: tenantRoot,
|
|
210
|
-
enumerable: false
|
|
211
|
-
});
|
|
212
|
-
Object.defineProperty(parsed, "__configPath", {
|
|
213
|
-
value: resolvedConfigPath,
|
|
214
|
-
enumerable: false
|
|
215
|
-
});
|
|
216
|
-
return parsed;
|
|
217
|
-
}
|
|
218
|
-
export {
|
|
219
|
-
deriveCloudflareWorkerName,
|
|
220
|
-
loadTreeseedDeployConfig,
|
|
221
|
-
resolveTreeseedDeployConfigPath
|
|
222
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { TreeseedDeployConfig, TreeseedTenantConfig } from '../contracts.ts';
|
|
2
|
-
import type { TreeseedEnvironmentRegistryOverlay } from '../environment.ts';
|
|
3
|
-
import type { SdkGraphRankingProvider } from '../../sdk-types.ts';
|
|
4
|
-
export type TreeseedSiteLayerDefinition = {
|
|
5
|
-
root: string;
|
|
6
|
-
kinds?: Array<'pages' | 'styles' | 'components'>;
|
|
7
|
-
};
|
|
8
|
-
export type TreeseedSiteRouteContribution = {
|
|
9
|
-
pattern: string;
|
|
10
|
-
entrypoint?: string;
|
|
11
|
-
resourcePath?: string;
|
|
12
|
-
};
|
|
13
|
-
export type TreeseedSiteExtensionContribution = {
|
|
14
|
-
routes?: TreeseedSiteRouteContribution[];
|
|
15
|
-
starlightComponents?: Record<string, string>;
|
|
16
|
-
customCss?: string[];
|
|
17
|
-
remarkPlugins?: unknown[];
|
|
18
|
-
rehypePlugins?: unknown[];
|
|
19
|
-
envSchema?: Record<string, unknown>;
|
|
20
|
-
vitePlugins?: unknown[];
|
|
21
|
-
integrations?: unknown[];
|
|
22
|
-
routeMiddleware?: unknown[];
|
|
23
|
-
};
|
|
24
|
-
export type TreeseedPluginSiteContext = {
|
|
25
|
-
projectRoot: string;
|
|
26
|
-
tenantConfig: TreeseedTenantConfig;
|
|
27
|
-
siteConfig?: unknown;
|
|
28
|
-
deployConfig?: TreeseedDeployConfig;
|
|
29
|
-
pluginConfig: Record<string, unknown>;
|
|
30
|
-
};
|
|
31
|
-
export type TreeseedPluginEnvironmentContext = {
|
|
32
|
-
projectRoot: string;
|
|
33
|
-
tenantConfig?: TreeseedTenantConfig;
|
|
34
|
-
deployConfig?: TreeseedDeployConfig;
|
|
35
|
-
pluginConfig: Record<string, unknown>;
|
|
36
|
-
};
|
|
37
|
-
export type TreeseedGraphRankingProviderContribution = SdkGraphRankingProvider | ((context: TreeseedPluginEnvironmentContext) => SdkGraphRankingProvider | undefined);
|
|
38
|
-
export interface TreeseedPlugin {
|
|
39
|
-
id?: string;
|
|
40
|
-
provides?: Record<string, any> & {
|
|
41
|
-
operations?: string[];
|
|
42
|
-
};
|
|
43
|
-
operationProviders?: Record<string, unknown>;
|
|
44
|
-
siteProviders?: Record<string, TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution)>;
|
|
45
|
-
siteHooks?: TreeseedSiteExtensionContribution | ((context: TreeseedPluginSiteContext) => TreeseedSiteExtensionContribution);
|
|
46
|
-
siteLayers?: TreeseedSiteLayerDefinition[] | ((context: TreeseedPluginSiteContext) => TreeseedSiteLayerDefinition[] | undefined);
|
|
47
|
-
environmentRegistry?: TreeseedEnvironmentRegistryOverlay | ((context: TreeseedPluginEnvironmentContext) => TreeseedEnvironmentRegistryOverlay | undefined);
|
|
48
|
-
graphRankingProviders?: Record<string, TreeseedGraphRankingProviderContribution>;
|
|
49
|
-
[key: string]: unknown;
|
|
50
|
-
}
|
|
51
|
-
export declare function defineTreeseedPlugin<T extends TreeseedPlugin>(plugin: T): T;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { TreeseedTenantConfig } from '../contracts.ts';
|
|
2
|
-
declare function resolveTenantRoot(): string;
|
|
3
|
-
export declare function defineTreeseedTenant<T>(tenantConfig: T): T;
|
|
4
|
-
export declare function loadTreeseedManifest(manifestPath?: string): TreeseedTenantConfig;
|
|
5
|
-
export declare const loadTreeseedTenantManifest: typeof loadTreeseedManifest;
|
|
6
|
-
export declare const resolveTreeseedTenantRoot: typeof resolveTenantRoot;
|
|
7
|
-
export declare function getTenantContentRoot(tenantConfig: Pick<TreeseedTenantConfig, 'content'>, collectionName: string): string;
|
|
8
|
-
export declare function tenantFeatureEnabled(tenantConfig: Pick<TreeseedTenantConfig, 'features'>, featureName: string): boolean;
|
|
9
|
-
export {};
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { dirname, resolve } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { parse as parseYaml } from "yaml";
|
|
5
|
-
import { normalizeAliasedRecord } from "../../field-aliases.js";
|
|
6
|
-
function resolvePackageRoot() {
|
|
7
|
-
const moduleUrl = typeof import.meta?.url === "string" ? import.meta.url : null;
|
|
8
|
-
if (!moduleUrl) {
|
|
9
|
-
return process.cwd();
|
|
10
|
-
}
|
|
11
|
-
return resolve(dirname(fileURLToPath(moduleUrl)), "../..");
|
|
12
|
-
}
|
|
13
|
-
const packageRoot = resolvePackageRoot();
|
|
14
|
-
const packageFixtureRoot = resolve(packageRoot, ".fixtures", "treeseed-fixtures", "sites", "working-site");
|
|
15
|
-
const explicitTenantRoot = process.env.TREESEED_TENANT_ROOT ? resolve(process.env.TREESEED_TENANT_ROOT) : null;
|
|
16
|
-
const manifestFieldAliases = {
|
|
17
|
-
siteConfigPath: { key: "siteConfigPath", aliases: ["site_config_path"] }
|
|
18
|
-
};
|
|
19
|
-
const manifestContentFieldAliases = {
|
|
20
|
-
pages: { key: "pages", aliases: ["page_root", "pages_root"] },
|
|
21
|
-
notes: { key: "notes", aliases: ["notes_root"] },
|
|
22
|
-
questions: { key: "questions", aliases: ["questions_root"] },
|
|
23
|
-
objectives: { key: "objectives", aliases: ["objectives_root"] },
|
|
24
|
-
people: { key: "people", aliases: ["people_root"] },
|
|
25
|
-
agents: { key: "agents", aliases: ["agents_root"] },
|
|
26
|
-
books: { key: "books", aliases: ["books_root"] },
|
|
27
|
-
docs: { key: "docs", aliases: ["knowledge", "knowledge_root", "docs_root"] }
|
|
28
|
-
};
|
|
29
|
-
const manifestOverrideFieldAliases = {
|
|
30
|
-
pagesRoot: { key: "pagesRoot", aliases: ["pages_root"] },
|
|
31
|
-
stylesRoot: { key: "stylesRoot", aliases: ["styles_root"] },
|
|
32
|
-
componentsRoot: { key: "componentsRoot", aliases: ["components_root"] }
|
|
33
|
-
};
|
|
34
|
-
function pathWithin(parent, candidate) {
|
|
35
|
-
const normalizedParent = resolve(parent);
|
|
36
|
-
const normalizedCandidate = resolve(candidate);
|
|
37
|
-
return normalizedCandidate === normalizedParent || normalizedCandidate.startsWith(`${normalizedParent}/`);
|
|
38
|
-
}
|
|
39
|
-
function collectTenantRootCandidates(start) {
|
|
40
|
-
const candidates = [];
|
|
41
|
-
let current = resolve(start);
|
|
42
|
-
while (true) {
|
|
43
|
-
candidates.push(
|
|
44
|
-
current,
|
|
45
|
-
resolve(current, ".fixtures", "treeseed-fixtures", "sites", "working-site"),
|
|
46
|
-
resolve(current, "fixture")
|
|
47
|
-
);
|
|
48
|
-
const parent = resolve(current, "..");
|
|
49
|
-
if (parent === current) {
|
|
50
|
-
break;
|
|
51
|
-
}
|
|
52
|
-
current = parent;
|
|
53
|
-
}
|
|
54
|
-
return candidates;
|
|
55
|
-
}
|
|
56
|
-
function uniqueCandidates(entries) {
|
|
57
|
-
return [...new Set(entries.map((entry) => resolve(entry)))];
|
|
58
|
-
}
|
|
59
|
-
function tenantRootCandidates() {
|
|
60
|
-
const cwd = resolve(process.cwd());
|
|
61
|
-
const cwdCandidates = collectTenantRootCandidates(cwd);
|
|
62
|
-
const packageCandidates = collectTenantRootCandidates(packageRoot);
|
|
63
|
-
if (explicitTenantRoot) {
|
|
64
|
-
return uniqueCandidates([explicitTenantRoot, ...cwdCandidates, packageFixtureRoot, ...packageCandidates]);
|
|
65
|
-
}
|
|
66
|
-
if (pathWithin(packageRoot, cwd)) {
|
|
67
|
-
return uniqueCandidates([packageFixtureRoot, ...cwdCandidates, ...packageCandidates]);
|
|
68
|
-
}
|
|
69
|
-
return uniqueCandidates([...cwdCandidates, packageFixtureRoot, ...packageCandidates]);
|
|
70
|
-
}
|
|
71
|
-
function resolveTenantPath(manifestPath) {
|
|
72
|
-
if (existsSync(manifestPath)) {
|
|
73
|
-
return resolve(manifestPath);
|
|
74
|
-
}
|
|
75
|
-
const candidates = tenantRootCandidates().map((root) => resolve(root, manifestPath));
|
|
76
|
-
for (const candidate of candidates) {
|
|
77
|
-
if (existsSync(candidate)) {
|
|
78
|
-
return candidate;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
throw new Error(
|
|
82
|
-
`Unable to resolve Treeseed tenant manifest at "${manifestPath}" from ${process.cwd()} or ${packageFixtureRoot}.`
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
function resolveTenantRoot() {
|
|
86
|
-
const candidates = tenantRootCandidates();
|
|
87
|
-
for (const candidate of candidates) {
|
|
88
|
-
if (existsSync(resolve(candidate, "src/manifest.yaml"))) {
|
|
89
|
-
return candidate;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
throw new Error(
|
|
93
|
-
`Unable to resolve a Treeseed tenant root from ${process.cwd()} or ${packageFixtureRoot}.`
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
function defineTreeseedTenant(tenantConfig) {
|
|
97
|
-
return tenantConfig;
|
|
98
|
-
}
|
|
99
|
-
function loadTreeseedManifest(manifestPath = "./src/manifest.yaml") {
|
|
100
|
-
const resolvedManifestPath = resolveTenantPath(manifestPath);
|
|
101
|
-
const tenantRoot = resolve(dirname(resolvedManifestPath), "..");
|
|
102
|
-
const parsed = normalizeAliasedRecord(
|
|
103
|
-
manifestFieldAliases,
|
|
104
|
-
parseYaml(readFileSync(resolvedManifestPath, "utf8"))
|
|
105
|
-
);
|
|
106
|
-
const content = normalizeAliasedRecord(
|
|
107
|
-
manifestContentFieldAliases,
|
|
108
|
-
parsed.content ?? {}
|
|
109
|
-
);
|
|
110
|
-
const overrides = parsed.overrides ? normalizeAliasedRecord(
|
|
111
|
-
manifestOverrideFieldAliases,
|
|
112
|
-
parsed.overrides
|
|
113
|
-
) : void 0;
|
|
114
|
-
const tenantConfig = defineTreeseedTenant({
|
|
115
|
-
...parsed,
|
|
116
|
-
siteConfigPath: resolve(tenantRoot, parsed.siteConfigPath),
|
|
117
|
-
content: Object.fromEntries(
|
|
118
|
-
Object.entries(content ?? {}).map(([collectionName, rootPath]) => [
|
|
119
|
-
collectionName,
|
|
120
|
-
resolve(tenantRoot, String(rootPath))
|
|
121
|
-
])
|
|
122
|
-
),
|
|
123
|
-
overrides: overrides ? {
|
|
124
|
-
pagesRoot: overrides.pagesRoot ? resolve(tenantRoot, overrides.pagesRoot) : void 0,
|
|
125
|
-
stylesRoot: overrides.stylesRoot ? resolve(tenantRoot, overrides.stylesRoot) : void 0,
|
|
126
|
-
componentsRoot: overrides.componentsRoot ? resolve(tenantRoot, overrides.componentsRoot) : void 0
|
|
127
|
-
} : void 0
|
|
128
|
-
});
|
|
129
|
-
Object.defineProperty(tenantConfig, "__tenantRoot", {
|
|
130
|
-
value: tenantRoot,
|
|
131
|
-
enumerable: false
|
|
132
|
-
});
|
|
133
|
-
return tenantConfig;
|
|
134
|
-
}
|
|
135
|
-
const loadTreeseedTenantManifest = loadTreeseedManifest;
|
|
136
|
-
const resolveTreeseedTenantRoot = resolveTenantRoot;
|
|
137
|
-
function getTenantContentRoot(tenantConfig, collectionName) {
|
|
138
|
-
const root = tenantConfig.content[collectionName];
|
|
139
|
-
if (!root) {
|
|
140
|
-
throw new Error(`Unknown tenant content collection: ${collectionName}`);
|
|
141
|
-
}
|
|
142
|
-
return root;
|
|
143
|
-
}
|
|
144
|
-
function tenantFeatureEnabled(tenantConfig, featureName) {
|
|
145
|
-
return tenantConfig.features?.[featureName] !== false;
|
|
146
|
-
}
|
|
147
|
-
export {
|
|
148
|
-
defineTreeseedTenant,
|
|
149
|
-
getTenantContentRoot,
|
|
150
|
-
loadTreeseedManifest,
|
|
151
|
-
loadTreeseedTenantManifest,
|
|
152
|
-
resolveTreeseedTenantRoot,
|
|
153
|
-
tenantFeatureEnabled
|
|
154
|
-
};
|