@treeseed/sdk 0.1.2 → 0.3.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 +97 -506
- package/dist/{src/cli-tools.d.ts → cli-tools.d.ts} +1 -1
- package/dist/cli-tools.js +5 -3
- package/dist/{src/content-store.d.ts → content-store.d.ts} +3 -2
- package/dist/content-store.js +52 -20
- package/dist/{src/d1-store.d.ts → d1-store.d.ts} +62 -1
- package/dist/d1-store.js +625 -65
- package/dist/field-aliases.d.ts +11 -0
- package/dist/field-aliases.js +41 -0
- package/dist/graph/build.d.ts +19 -0
- package/dist/graph/build.js +949 -0
- package/dist/graph/dsl.d.ts +2 -0
- package/dist/graph/dsl.js +243 -0
- package/dist/graph/query.d.ts +47 -0
- package/dist/graph/query.js +447 -0
- package/dist/graph/ranking.d.ts +3 -0
- package/dist/graph/ranking.js +483 -0
- package/dist/graph/schema.d.ts +142 -0
- package/dist/graph/schema.js +133 -0
- package/dist/graph.d.ts +52 -0
- package/dist/graph.js +133 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +91 -2
- package/dist/model-registry.d.ts +8 -0
- package/dist/model-registry.js +351 -25
- package/dist/operations/providers/default.d.ts +10 -0
- package/dist/operations/providers/default.js +514 -0
- package/dist/operations/runtime.d.ts +7 -0
- package/dist/operations/runtime.js +60 -0
- package/dist/operations/services/config-runtime.d.ts +269 -0
- package/dist/operations/services/config-runtime.js +1397 -0
- package/dist/operations/services/d1-migration.d.ts +6 -0
- package/dist/operations/services/d1-migration.js +89 -0
- package/dist/operations/services/deploy.d.ts +371 -0
- package/dist/operations/services/deploy.js +981 -0
- package/dist/operations/services/git-workflow.d.ts +49 -0
- package/dist/operations/services/git-workflow.js +218 -0
- package/dist/operations/services/github-automation.d.ts +156 -0
- package/dist/operations/services/github-automation.js +256 -0
- package/dist/operations/services/local-dev.d.ts +9 -0
- package/dist/operations/services/local-dev.js +106 -0
- package/dist/operations/services/mailpit-runtime.d.ts +4 -0
- package/dist/operations/services/mailpit-runtime.js +59 -0
- package/dist/operations/services/railway-deploy.d.ts +53 -0
- package/dist/operations/services/railway-deploy.js +123 -0
- package/dist/operations/services/runtime-paths.d.ts +19 -0
- package/dist/operations/services/runtime-paths.js +54 -0
- package/dist/operations/services/runtime-tools.d.ts +117 -0
- package/dist/operations/services/runtime-tools.js +358 -0
- package/dist/operations/services/save-deploy-preflight.d.ts +34 -0
- package/dist/operations/services/save-deploy-preflight.js +76 -0
- package/dist/operations/services/template-registry.d.ts +88 -0
- package/dist/operations/services/template-registry.js +407 -0
- package/dist/operations/services/watch-dev.d.ts +21 -0
- package/dist/operations/services/watch-dev.js +284 -0
- package/dist/operations/services/workspace-preflight.d.ts +40 -0
- package/dist/operations/services/workspace-preflight.js +165 -0
- package/dist/operations/services/workspace-save.d.ts +42 -0
- package/dist/operations/services/workspace-save.js +235 -0
- package/dist/operations/services/workspace-tools.d.ts +16 -0
- package/dist/operations/services/workspace-tools.js +270 -0
- package/dist/operations-registry.d.ts +5 -0
- package/dist/operations-registry.js +68 -0
- package/dist/operations-types.d.ts +71 -0
- package/dist/operations-types.js +17 -0
- package/dist/operations.d.ts +6 -0
- package/dist/operations.js +16 -0
- package/dist/platform/books-data.d.ts +1 -0
- package/dist/platform/books-data.js +1 -0
- package/dist/platform/contracts.d.ts +158 -0
- package/dist/platform/contracts.js +0 -0
- package/dist/platform/deploy/config.d.ts +4 -0
- package/dist/platform/deploy/config.js +222 -0
- package/dist/platform/deploy-config.d.ts +1 -0
- package/dist/platform/deploy-config.js +1 -0
- package/dist/platform/deploy-runtime.d.ts +18 -0
- package/dist/platform/deploy-runtime.js +78 -0
- package/dist/platform/env.yaml +394 -0
- package/dist/platform/environment.d.ts +130 -0
- package/dist/platform/environment.js +331 -0
- package/dist/platform/plugin.d.ts +2 -0
- package/dist/platform/plugin.js +4 -0
- package/dist/platform/plugins/constants.d.ts +22 -0
- package/dist/platform/plugins/constants.js +29 -0
- package/dist/platform/plugins/plugin.d.ts +51 -0
- package/dist/platform/plugins/plugin.js +6 -0
- package/dist/platform/plugins/runtime.d.ts +35 -0
- package/dist/platform/plugins/runtime.js +161 -0
- package/dist/platform/plugins.d.ts +6 -0
- package/dist/platform/plugins.js +38 -0
- package/dist/platform/site-config-schema.js +1 -0
- package/dist/platform/tenant/config.d.ts +9 -0
- package/dist/platform/tenant/config.js +154 -0
- package/dist/platform/tenant/runtime-config.d.ts +4 -0
- package/dist/platform/tenant/runtime-config.js +20 -0
- package/dist/platform/tenant-config.d.ts +1 -0
- package/dist/platform/tenant-config.js +1 -0
- package/dist/platform/utils/books-data.d.ts +29 -0
- package/dist/platform/utils/books-data.js +82 -0
- package/dist/platform/utils/site-config-schema.js +321 -0
- package/dist/remote.d.ts +175 -0
- package/dist/remote.js +202 -0
- package/dist/runtime.js +35 -22
- package/dist/scripts/aggregate-book.js +121 -0
- package/dist/scripts/build-dist.js +54 -13
- package/dist/scripts/build-tenant-worker.js +36 -0
- package/dist/scripts/cleanup-markdown.js +373 -0
- package/dist/scripts/cli-test-fixtures.js +48 -0
- package/dist/scripts/config-treeseed.js +95 -0
- package/dist/scripts/ensure-mailpit.js +29 -0
- package/dist/scripts/local-dev.js +129 -0
- package/dist/scripts/logs-mailpit.js +2 -0
- package/dist/scripts/patch-starlight-content-path.js +172 -0
- package/dist/scripts/release-verify.js +34 -6
- package/dist/scripts/run-fixture-astro-command.js +18 -0
- package/dist/scripts/scaffold-site.js +65 -0
- package/dist/scripts/stop-mailpit.js +5 -0
- package/dist/scripts/sync-dev-vars.js +6 -0
- package/dist/scripts/sync-template.js +20 -0
- package/dist/scripts/template-catalog.test.js +100 -0
- package/dist/scripts/template-command.js +31 -0
- package/dist/scripts/tenant-astro-command.js +3 -0
- package/dist/scripts/tenant-build.js +16 -0
- package/dist/scripts/tenant-check.js +7 -0
- package/dist/scripts/tenant-d1-migrate-local.js +11 -0
- package/dist/scripts/tenant-deploy.js +180 -0
- package/dist/scripts/tenant-destroy.js +104 -0
- package/dist/scripts/tenant-dev.js +171 -0
- package/dist/scripts/tenant-lint.js +4 -0
- package/dist/scripts/tenant-test.js +4 -0
- package/dist/scripts/test-cloudflare-local.js +212 -0
- package/dist/scripts/test-scaffold.js +314 -0
- package/dist/scripts/test-smoke.js +71 -13
- package/dist/scripts/treeseed-assert-release-tag-version.js +21 -0
- package/dist/scripts/treeseed-build-dist.js +134 -0
- package/dist/scripts/treeseed-publish-package.js +19 -0
- package/dist/scripts/treeseed-release-verify.js +131 -0
- package/dist/scripts/treeseed-run-ts.js +45 -0
- package/dist/scripts/validate-templates.js +6 -0
- package/dist/scripts/verify-driver.js +29 -0
- package/dist/scripts/workflow-commands.test.js +39 -0
- package/dist/scripts/workspace-close.js +24 -0
- package/dist/scripts/workspace-command-e2e.js +718 -0
- package/dist/scripts/workspace-lint.js +9 -0
- package/dist/scripts/workspace-preflight.js +22 -0
- package/dist/scripts/workspace-publish-changed-packages.js +16 -0
- package/dist/scripts/workspace-release-verify.js +81 -0
- package/dist/scripts/workspace-release.js +42 -0
- package/dist/scripts/workspace-save.js +124 -0
- package/dist/scripts/workspace-start-warning.js +3 -0
- package/dist/scripts/workspace-start.js +71 -0
- package/dist/scripts/workspace-test-unit.js +4 -0
- package/dist/scripts/workspace-test.js +11 -0
- package/dist/sdk-fields.d.ts +11 -0
- package/dist/sdk-fields.js +169 -0
- package/dist/sdk-filters.d.ts +4 -0
- package/dist/sdk-filters.js +12 -15
- package/dist/sdk-types.d.ts +796 -0
- package/dist/sdk-types.js +7 -1
- package/dist/sdk-version.d.ts +2 -0
- package/dist/sdk-version.js +42 -0
- package/dist/sdk.d.ts +215 -0
- package/dist/sdk.js +235 -11
- package/dist/stores/cursor-store.js +9 -3
- package/dist/stores/lease-store.js +8 -2
- package/dist/{src/stores → stores}/message-store.d.ts +1 -1
- package/dist/stores/message-store.js +27 -3
- package/dist/stores/operational-store.d.ts +24 -0
- package/dist/stores/operational-store.js +279 -0
- package/dist/stores/run-store.js +8 -1
- package/dist/stores/subscription-store.js +7 -5
- package/dist/template-catalog.d.ts +13 -0
- package/dist/template-catalog.js +141 -0
- package/dist/treeseed/services/compose.yml +7 -0
- package/dist/treeseed/template-catalog/catalog.fixture.json +55 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.d.ts +2 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/astro.config.ts +3 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/package.json +32 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/config.yaml +40 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/empty/.gitkeep +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/knowledge/handbook/index.mdx +11 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content/pages/welcome.mdx +11 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content.config.d.ts +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/content.config.ts +3 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/env.yaml +1 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/src/manifest.yaml +19 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/treeseed.site.yaml +26 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template/tsconfig.json +9 -0
- package/dist/treeseed/template-catalog/templates/starter-basic/template.config.json +90 -0
- package/dist/utils/agents/contracts/messages.d.ts +88 -0
- package/dist/utils/agents/contracts/messages.js +138 -0
- package/dist/utils/agents/contracts/run.d.ts +20 -0
- package/dist/utils/agents/contracts/run.js +0 -0
- package/dist/utils/agents/runtime-types.d.ts +117 -0
- package/dist/utils/agents/runtime-types.js +4 -0
- package/dist/verification.d.ts +20 -0
- package/dist/verification.js +98 -0
- package/dist/workflow/operations.d.ts +396 -0
- package/dist/workflow/operations.js +841 -0
- package/dist/workflow-state.d.ts +56 -0
- package/dist/workflow-state.js +195 -0
- package/dist/workflow-support.d.ts +9 -0
- package/dist/workflow-support.js +176 -0
- package/dist/workflow.d.ts +111 -0
- package/dist/workflow.js +97 -0
- package/package.json +111 -5
- package/scripts/verify-driver.mjs +29 -0
- package/dist/scripts/.ts-run-1775630384291-crtqr3izsa.js +0 -22
- package/dist/scripts/.ts-run-1775630388025-vnjle0z75a.js +0 -129
- package/dist/scripts/assert-release-tag-version.d.ts +0 -1
- package/dist/scripts/build-dist.d.ts +0 -1
- package/dist/scripts/fixture-tools.d.ts +0 -5
- package/dist/scripts/package-tools.d.ts +0 -15
- package/dist/scripts/publish-package.d.ts +0 -1
- package/dist/scripts/release-verify.d.ts +0 -1
- package/dist/scripts/test-smoke.d.ts +0 -1
- package/dist/src/index.d.ts +0 -6
- package/dist/src/model-registry.d.ts +0 -4
- package/dist/src/sdk-filters.d.ts +0 -4
- package/dist/src/sdk-types.d.ts +0 -285
- package/dist/src/sdk.d.ts +0 -109
- package/dist/test/test-fixture.d.ts +0 -1
- package/dist/test/utils/envelopes.test.d.ts +0 -1
- package/dist/test/utils/sdk.test.d.ts +0 -1
- package/dist/vitest.config.d.ts +0 -2
- /package/dist/{src/frontmatter.d.ts → frontmatter.d.ts} +0 -0
- /package/dist/{src/git-runtime.d.ts → git-runtime.d.ts} +0 -0
- /package/dist/{src/runtime.d.ts → runtime.d.ts} +0 -0
- /package/dist/{src/stores → stores}/cursor-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/envelopes.d.ts +0 -0
- /package/dist/{src/stores → stores}/helpers.d.ts +0 -0
- /package/dist/{src/stores → stores}/lease-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/run-store.d.ts +0 -0
- /package/dist/{src/stores → stores}/subscription-store.d.ts +0 -0
- /package/dist/{src/types → types}/agents.d.ts +0 -0
- /package/dist/{src/types → types}/cloudflare.d.ts +0 -0
- /package/dist/{src/wrangler-d1.d.ts → wrangler-d1.d.ts} +0 -0
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
import { changedWorkspacePackages, publishableWorkspacePackages, run, sortWorkspacePackages, workspacePackages, workspaceRoot } from "./workspace-tools.js";
|
|
4
|
+
const MERGE_CONFLICT_EXIT_CODE = 12;
|
|
5
|
+
function parseSemver(version) {
|
|
6
|
+
const match = String(version).trim().match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
7
|
+
if (!match) {
|
|
8
|
+
throw new Error(`Unsupported version "${version}". Expected x.y.z.`);
|
|
9
|
+
}
|
|
10
|
+
return {
|
|
11
|
+
major: Number(match[1]),
|
|
12
|
+
minor: Number(match[2]),
|
|
13
|
+
patch: Number(match[3])
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function incrementPatchVersion(version) {
|
|
17
|
+
const parsed = parseSemver(version);
|
|
18
|
+
return `${parsed.major}.${parsed.minor}.${parsed.patch + 1}`;
|
|
19
|
+
}
|
|
20
|
+
function incrementVersion(version, level = "patch") {
|
|
21
|
+
const parsed = parseSemver(version);
|
|
22
|
+
if (level === "major") {
|
|
23
|
+
return `${parsed.major + 1}.0.0`;
|
|
24
|
+
}
|
|
25
|
+
if (level === "minor") {
|
|
26
|
+
return `${parsed.major}.${parsed.minor + 1}.0`;
|
|
27
|
+
}
|
|
28
|
+
if (level === "patch") {
|
|
29
|
+
return `${parsed.major}.${parsed.minor}.${parsed.patch + 1}`;
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Unsupported release bump "${level}". Expected major, minor, or patch.`);
|
|
32
|
+
}
|
|
33
|
+
function readPackageJson(filePath) {
|
|
34
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
35
|
+
}
|
|
36
|
+
function writePackageJson(filePath, value) {
|
|
37
|
+
writeFileSync(filePath, `${JSON.stringify(value, null, 2)}
|
|
38
|
+
`, "utf8");
|
|
39
|
+
}
|
|
40
|
+
function internalDependencyFields(packageJson) {
|
|
41
|
+
return ["dependencies", "optionalDependencies", "peerDependencies", "devDependencies"].filter((field) => packageJson[field] && typeof packageJson[field] === "object");
|
|
42
|
+
}
|
|
43
|
+
function planWorkspaceVersionChanges(root = workspaceRoot()) {
|
|
44
|
+
const packages = workspacePackages(root).map((pkg) => ({
|
|
45
|
+
...pkg,
|
|
46
|
+
packageJsonPath: resolve(pkg.dir, "package.json"),
|
|
47
|
+
packageJson: readPackageJson(resolve(pkg.dir, "package.json"))
|
|
48
|
+
}));
|
|
49
|
+
const orderedPackages = sortWorkspacePackages(packages);
|
|
50
|
+
const publishable = new Set(publishableWorkspacePackages(root).map((pkg) => pkg.name));
|
|
51
|
+
const changedPublishable = new Set(
|
|
52
|
+
changedWorkspacePackages({
|
|
53
|
+
root,
|
|
54
|
+
packages: orderedPackages.filter((pkg) => publishable.has(pkg.name)),
|
|
55
|
+
includeDependents: false
|
|
56
|
+
}).map((pkg) => pkg.name)
|
|
57
|
+
);
|
|
58
|
+
const versions = new Map(orderedPackages.map((pkg) => [pkg.name, pkg.packageJson.version]));
|
|
59
|
+
const bumped = new Set(changedPublishable);
|
|
60
|
+
const touched = /* @__PURE__ */ new Set();
|
|
61
|
+
for (const name of changedPublishable) {
|
|
62
|
+
versions.set(name, incrementPatchVersion(versions.get(name)));
|
|
63
|
+
}
|
|
64
|
+
let changed = true;
|
|
65
|
+
while (changed) {
|
|
66
|
+
changed = false;
|
|
67
|
+
for (const pkg of orderedPackages) {
|
|
68
|
+
let packageDependencyChanged = false;
|
|
69
|
+
for (const field of internalDependencyFields(pkg.packageJson)) {
|
|
70
|
+
for (const depName of Object.keys(pkg.packageJson[field] ?? {})) {
|
|
71
|
+
if (!versions.has(depName)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const nextSpec = `^${versions.get(depName)}`;
|
|
75
|
+
if (pkg.packageJson[field][depName] === nextSpec) {
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
pkg.packageJson[field][depName] = nextSpec;
|
|
79
|
+
packageDependencyChanged = true;
|
|
80
|
+
touched.add(pkg.name);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (packageDependencyChanged && publishable.has(pkg.name) && !bumped.has(pkg.name)) {
|
|
84
|
+
bumped.add(pkg.name);
|
|
85
|
+
versions.set(pkg.name, incrementPatchVersion(versions.get(pkg.name)));
|
|
86
|
+
changed = true;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
for (const pkg of orderedPackages) {
|
|
91
|
+
if (!bumped.has(pkg.name)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const nextVersion = versions.get(pkg.name);
|
|
95
|
+
if (pkg.packageJson.version !== nextVersion) {
|
|
96
|
+
pkg.packageJson.version = nextVersion;
|
|
97
|
+
touched.add(pkg.name);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return {
|
|
101
|
+
packages: orderedPackages,
|
|
102
|
+
publishable,
|
|
103
|
+
bumped,
|
|
104
|
+
touched
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function applyWorkspaceVersionChanges(plan) {
|
|
108
|
+
for (const pkg of plan.packages) {
|
|
109
|
+
if (!plan.touched.has(pkg.name)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
writePackageJson(pkg.packageJsonPath, pkg.packageJson);
|
|
113
|
+
}
|
|
114
|
+
return plan;
|
|
115
|
+
}
|
|
116
|
+
function planWorkspaceReleaseBump(level = "patch", root = workspaceRoot()) {
|
|
117
|
+
const packages = workspacePackages(root).map((pkg) => ({
|
|
118
|
+
...pkg,
|
|
119
|
+
packageJsonPath: resolve(pkg.dir, "package.json"),
|
|
120
|
+
packageJson: readPackageJson(resolve(pkg.dir, "package.json"))
|
|
121
|
+
}));
|
|
122
|
+
const publishable = new Set(publishableWorkspacePackages(root).map((pkg) => pkg.name));
|
|
123
|
+
const touched = /* @__PURE__ */ new Set();
|
|
124
|
+
const versions = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const pkg of packages) {
|
|
126
|
+
if (!publishable.has(pkg.name)) {
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const nextVersion = incrementVersion(pkg.packageJson.version, level);
|
|
130
|
+
pkg.packageJson.version = nextVersion;
|
|
131
|
+
versions.set(pkg.name, nextVersion);
|
|
132
|
+
touched.add(pkg.name);
|
|
133
|
+
}
|
|
134
|
+
for (const pkg of packages) {
|
|
135
|
+
for (const field of internalDependencyFields(pkg.packageJson)) {
|
|
136
|
+
for (const depName of Object.keys(pkg.packageJson[field] ?? {})) {
|
|
137
|
+
if (!versions.has(depName)) {
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
pkg.packageJson[field][depName] = `^${versions.get(depName)}`;
|
|
141
|
+
touched.add(pkg.name);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
packages,
|
|
147
|
+
touched,
|
|
148
|
+
versions,
|
|
149
|
+
level
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function repoRoot(cwd = workspaceRoot()) {
|
|
153
|
+
return run("git", ["rev-parse", "--show-toplevel"], { cwd, capture: true }).trim();
|
|
154
|
+
}
|
|
155
|
+
function currentBranch(repoDir) {
|
|
156
|
+
return run("git", ["branch", "--show-current"], { cwd: repoDir, capture: true }).trim();
|
|
157
|
+
}
|
|
158
|
+
function originRemoteUrl(repoDir) {
|
|
159
|
+
return run("git", ["remote", "get-url", "origin"], { cwd: repoDir, capture: true }).trim();
|
|
160
|
+
}
|
|
161
|
+
function gitStatusPorcelain(repoDir) {
|
|
162
|
+
return run("git", ["status", "--porcelain"], { cwd: repoDir, capture: true }).trim();
|
|
163
|
+
}
|
|
164
|
+
function hasMeaningfulChanges(repoDir) {
|
|
165
|
+
return gitStatusPorcelain(repoDir).length > 0;
|
|
166
|
+
}
|
|
167
|
+
function countConflictMarkers(source) {
|
|
168
|
+
return {
|
|
169
|
+
start: (source.match(/^<{7} /gm) ?? []).length,
|
|
170
|
+
middle: (source.match(/^={7}$/gm) ?? []).length,
|
|
171
|
+
end: (source.match(/^>{7} /gm) ?? []).length
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
function collectMergeConflictReport(repoDir) {
|
|
175
|
+
const branch = currentBranch(repoDir);
|
|
176
|
+
const conflictedFiles = run("git", ["diff", "--name-only", "--diff-filter=U"], {
|
|
177
|
+
cwd: repoDir,
|
|
178
|
+
capture: true
|
|
179
|
+
}).split("\n").map((line) => line.trim()).filter(Boolean);
|
|
180
|
+
const status = run("git", ["status", "--short"], { cwd: repoDir, capture: true });
|
|
181
|
+
const perFile = conflictedFiles.map((filePath) => {
|
|
182
|
+
const fullPath = resolve(repoDir, filePath);
|
|
183
|
+
const source = existsSync(fullPath) ? readFileSync(fullPath, "utf8") : "";
|
|
184
|
+
return {
|
|
185
|
+
filePath,
|
|
186
|
+
markers: countConflictMarkers(source),
|
|
187
|
+
diff: run("git", ["diff", "--", filePath], { cwd: repoDir, capture: true })
|
|
188
|
+
};
|
|
189
|
+
});
|
|
190
|
+
return {
|
|
191
|
+
branch,
|
|
192
|
+
rebaseInProgress: true,
|
|
193
|
+
conflictedFiles,
|
|
194
|
+
status,
|
|
195
|
+
perFile
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function formatMergeConflictReport(report, repoDir, targetBranch = "main") {
|
|
199
|
+
const lines = [
|
|
200
|
+
`Treeseed save failed due to merge conflicts during \`git pull --rebase origin ${targetBranch}\`.`,
|
|
201
|
+
`Repository root: ${repoDir}`,
|
|
202
|
+
`Branch: ${report.branch}`,
|
|
203
|
+
`Rebase in progress: ${report.rebaseInProgress ? "yes" : "no"}`,
|
|
204
|
+
"Git status:",
|
|
205
|
+
report.status || "(no git status output)",
|
|
206
|
+
"Conflicted files:"
|
|
207
|
+
];
|
|
208
|
+
for (const file of report.perFile) {
|
|
209
|
+
lines.push(`- ${file.filePath}`);
|
|
210
|
+
lines.push(` markers: start=${file.markers.start} middle=${file.markers.middle} end=${file.markers.end}`);
|
|
211
|
+
lines.push(" diff:");
|
|
212
|
+
lines.push(file.diff || " (no diff output)");
|
|
213
|
+
}
|
|
214
|
+
lines.push("Next steps:");
|
|
215
|
+
lines.push("- Inspect conflicted files and reconcile local vs remote changes.");
|
|
216
|
+
lines.push("- After resolving files, run `git add <files>` and `git rebase --continue`.");
|
|
217
|
+
lines.push("- Or abort with `git rebase --abort` if you need to restart the save flow.");
|
|
218
|
+
return lines.join("\n");
|
|
219
|
+
}
|
|
220
|
+
export {
|
|
221
|
+
MERGE_CONFLICT_EXIT_CODE,
|
|
222
|
+
applyWorkspaceVersionChanges,
|
|
223
|
+
collectMergeConflictReport,
|
|
224
|
+
countConflictMarkers,
|
|
225
|
+
currentBranch,
|
|
226
|
+
formatMergeConflictReport,
|
|
227
|
+
gitStatusPorcelain,
|
|
228
|
+
hasMeaningfulChanges,
|
|
229
|
+
incrementPatchVersion,
|
|
230
|
+
incrementVersion,
|
|
231
|
+
originRemoteUrl,
|
|
232
|
+
planWorkspaceReleaseBump,
|
|
233
|
+
planWorkspaceVersionChanges,
|
|
234
|
+
repoRoot
|
|
235
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function workspaceRoot(startCwd?: string): any;
|
|
2
|
+
export declare function findNearestTreeseedRoot(startCwd?: string): string | null;
|
|
3
|
+
export declare function isWorkspaceRoot(root?: string): any;
|
|
4
|
+
export declare function hasCompleteTreeseedPackageCheckout(root?: string): boolean;
|
|
5
|
+
export declare function findNearestTreeseedWorkspaceRoot(startCwd?: string): any;
|
|
6
|
+
export declare function readJson(filePath: any): any;
|
|
7
|
+
export declare function workspacePackageJson(root?: any): any;
|
|
8
|
+
export declare function workspacePatterns(root?: any): any;
|
|
9
|
+
export declare function workspacePackages(root?: any): any[];
|
|
10
|
+
export declare function sortWorkspacePackages(packages: any): any[];
|
|
11
|
+
export declare function packagesWithScript(scriptName: any, root?: any): any[];
|
|
12
|
+
export declare function run(command: any, args: any, options?: {}): string;
|
|
13
|
+
export declare function changedWorkspacePackages(options?: {}): any[];
|
|
14
|
+
export declare function publishableWorkspacePackages(root?: any): any[];
|
|
15
|
+
export declare function createTempDir(prefix: any): string;
|
|
16
|
+
export declare function cleanupDir(dirPath: any): void;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync } from "node:fs";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { join, relative, resolve } from "node:path";
|
|
4
|
+
const TREESEED_WORKSPACE_PACKAGE_DIRS = ["sdk", "core", "cli", "agent", "api"];
|
|
5
|
+
function escapeRegex(source) {
|
|
6
|
+
return source.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
7
|
+
}
|
|
8
|
+
function segmentPatternToRegex(pattern) {
|
|
9
|
+
return new RegExp(`^${escapeRegex(pattern).replaceAll("*", ".*")}$`);
|
|
10
|
+
}
|
|
11
|
+
function expandWorkspacePattern(root, pattern) {
|
|
12
|
+
const segments = pattern.split(/[\\/]+/).filter(Boolean);
|
|
13
|
+
const results = [];
|
|
14
|
+
function visit(baseDir, index) {
|
|
15
|
+
if (index >= segments.length) {
|
|
16
|
+
results.push(baseDir);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const segment = segments[index];
|
|
20
|
+
if (!segment.includes("*")) {
|
|
21
|
+
const nextDir = resolve(baseDir, segment);
|
|
22
|
+
if (existsSync(nextDir)) {
|
|
23
|
+
visit(nextDir, index + 1);
|
|
24
|
+
}
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!existsSync(baseDir)) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const matcher = segmentPatternToRegex(segment);
|
|
31
|
+
for (const entry of readdirSync(baseDir, { withFileTypes: true })) {
|
|
32
|
+
if (!entry.isDirectory() || !matcher.test(entry.name)) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
visit(resolve(baseDir, entry.name), index + 1);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
visit(root, 0);
|
|
39
|
+
return results;
|
|
40
|
+
}
|
|
41
|
+
function workspaceRoot(startCwd = process.cwd()) {
|
|
42
|
+
return findNearestTreeseedWorkspaceRoot(startCwd) ?? resolve(startCwd);
|
|
43
|
+
}
|
|
44
|
+
function findNearestTreeseedRoot(startCwd = process.cwd()) {
|
|
45
|
+
let current = resolve(startCwd);
|
|
46
|
+
while (true) {
|
|
47
|
+
if (existsSync(resolve(current, "treeseed.site.yaml"))) {
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
const parent = resolve(current, "..");
|
|
51
|
+
if (parent === current) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
current = parent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function isWorkspaceRoot(root = process.cwd()) {
|
|
58
|
+
try {
|
|
59
|
+
return workspacePatterns(root).length > 0 || hasCompleteTreeseedPackageCheckout(root);
|
|
60
|
+
} catch {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function hasCompleteTreeseedPackageCheckout(root = process.cwd()) {
|
|
65
|
+
return TREESEED_WORKSPACE_PACKAGE_DIRS.every((dirName) => existsSync(resolve(root, "packages", dirName, "package.json")));
|
|
66
|
+
}
|
|
67
|
+
function findNearestTreeseedWorkspaceRoot(startCwd = process.cwd()) {
|
|
68
|
+
const tenantRoot = findNearestTreeseedRoot(startCwd);
|
|
69
|
+
if (!tenantRoot) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return isWorkspaceRoot(tenantRoot) ? tenantRoot : null;
|
|
73
|
+
}
|
|
74
|
+
function readJson(filePath) {
|
|
75
|
+
return JSON.parse(readFileSync(filePath, "utf8"));
|
|
76
|
+
}
|
|
77
|
+
function workspacePackageJson(root = workspaceRoot()) {
|
|
78
|
+
return readJson(resolve(root, "package.json"));
|
|
79
|
+
}
|
|
80
|
+
function workspacePatterns(root = workspaceRoot()) {
|
|
81
|
+
const packageJson = workspacePackageJson(root);
|
|
82
|
+
const workspaces = Array.isArray(packageJson.workspaces) ? packageJson.workspaces : Array.isArray(packageJson.workspaces?.packages) ? packageJson.workspaces.packages : [];
|
|
83
|
+
const patterns = workspaces.filter((value) => typeof value === "string" && value.trim().length > 0);
|
|
84
|
+
if (patterns.length > 0) {
|
|
85
|
+
return patterns;
|
|
86
|
+
}
|
|
87
|
+
return hasCompleteTreeseedPackageCheckout(root) ? ["packages/*"] : [];
|
|
88
|
+
}
|
|
89
|
+
function workspacePackages(root = workspaceRoot()) {
|
|
90
|
+
const discovered = /* @__PURE__ */ new Map();
|
|
91
|
+
for (const pattern of workspacePatterns(root)) {
|
|
92
|
+
for (const dir of expandWorkspacePattern(root, pattern)) {
|
|
93
|
+
const packageJsonPath = resolve(dir, "package.json");
|
|
94
|
+
if (!existsSync(packageJsonPath)) {
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const packageJson = readJson(packageJsonPath);
|
|
98
|
+
discovered.set(dir, {
|
|
99
|
+
dir,
|
|
100
|
+
name: packageJson.name,
|
|
101
|
+
packageJson,
|
|
102
|
+
relativeDir: relative(root, dir).replaceAll("\\", "/")
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return [...discovered.values()].sort((left, right) => left.name.localeCompare(right.name));
|
|
107
|
+
}
|
|
108
|
+
function internalDependenciesFor(pkg, packageNames) {
|
|
109
|
+
const internalDeps = /* @__PURE__ */ new Set();
|
|
110
|
+
for (const field of ["dependencies", "optionalDependencies", "peerDependencies", "devDependencies"]) {
|
|
111
|
+
for (const name of Object.keys(pkg.packageJson[field] ?? {})) {
|
|
112
|
+
if (packageNames.has(name)) {
|
|
113
|
+
internalDeps.add(name);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return internalDeps;
|
|
118
|
+
}
|
|
119
|
+
function sortWorkspacePackages(packages) {
|
|
120
|
+
const packageMap = new Map(packages.map((pkg) => [pkg.name, pkg]));
|
|
121
|
+
const packageNames = new Set(packageMap.keys());
|
|
122
|
+
const dependents = new Map(packages.map((pkg) => [pkg.name, /* @__PURE__ */ new Set()]));
|
|
123
|
+
const indegree = new Map(packages.map((pkg) => [pkg.name, 0]));
|
|
124
|
+
for (const pkg of packages) {
|
|
125
|
+
for (const dep of internalDependenciesFor(pkg, packageNames)) {
|
|
126
|
+
dependents.get(dep)?.add(pkg.name);
|
|
127
|
+
indegree.set(pkg.name, (indegree.get(pkg.name) ?? 0) + 1);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const ready = [...packages].filter((pkg) => (indegree.get(pkg.name) ?? 0) === 0).sort((left, right) => left.name.localeCompare(right.name));
|
|
131
|
+
const ordered = [];
|
|
132
|
+
while (ready.length > 0) {
|
|
133
|
+
const next = ready.shift();
|
|
134
|
+
if (!next) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
ordered.push(next);
|
|
138
|
+
for (const dependentName of [...dependents.get(next.name) ?? []].sort()) {
|
|
139
|
+
const nextDegree = (indegree.get(dependentName) ?? 0) - 1;
|
|
140
|
+
indegree.set(dependentName, nextDegree);
|
|
141
|
+
if (nextDegree === 0) {
|
|
142
|
+
const dependent = packageMap.get(dependentName);
|
|
143
|
+
if (dependent) {
|
|
144
|
+
ready.push(dependent);
|
|
145
|
+
ready.sort((left, right) => left.name.localeCompare(right.name));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (ordered.length !== packages.length) {
|
|
151
|
+
return [...packages].sort((left, right) => left.name.localeCompare(right.name));
|
|
152
|
+
}
|
|
153
|
+
return ordered;
|
|
154
|
+
}
|
|
155
|
+
function packagesWithScript(scriptName, root = workspaceRoot()) {
|
|
156
|
+
return sortWorkspacePackages(
|
|
157
|
+
workspacePackages(root).filter((pkg) => typeof pkg.packageJson.scripts?.[scriptName] === "string")
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
function run(command, args, options = {}) {
|
|
161
|
+
const result = spawnSync(command, args, {
|
|
162
|
+
cwd: options.cwd ?? workspaceRoot(),
|
|
163
|
+
env: { ...process.env, ...options.env ?? {} },
|
|
164
|
+
stdio: options.capture ? "pipe" : "inherit",
|
|
165
|
+
encoding: "utf8",
|
|
166
|
+
timeout: options.timeoutMs
|
|
167
|
+
});
|
|
168
|
+
if (result.status !== 0) {
|
|
169
|
+
const message = (result.error?.message ? `${result.error.message}
|
|
170
|
+
` : "") + (result.stderr?.trim() || result.stdout?.trim() || `${command} ${args.join(" ")} failed`);
|
|
171
|
+
throw new Error(message);
|
|
172
|
+
}
|
|
173
|
+
return (result.stdout ?? "").trim();
|
|
174
|
+
}
|
|
175
|
+
function canResolveGitRef(baseRef, cwd = workspaceRoot()) {
|
|
176
|
+
const result = spawnSync("git", ["rev-parse", "--verify", baseRef], {
|
|
177
|
+
cwd,
|
|
178
|
+
stdio: "pipe",
|
|
179
|
+
encoding: "utf8"
|
|
180
|
+
});
|
|
181
|
+
return result.status === 0;
|
|
182
|
+
}
|
|
183
|
+
function resolveChangedFilesBaseRef(baseRef, cwd = workspaceRoot()) {
|
|
184
|
+
if (canResolveGitRef(baseRef, cwd)) {
|
|
185
|
+
return baseRef;
|
|
186
|
+
}
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
function changedWorkspaceFiles(baseRef, cwd = workspaceRoot()) {
|
|
190
|
+
const changedFiles = /* @__PURE__ */ new Set();
|
|
191
|
+
const resolvedBaseRef = resolveChangedFilesBaseRef(baseRef, cwd);
|
|
192
|
+
const diffCommands = [
|
|
193
|
+
["diff", "--name-only"],
|
|
194
|
+
["diff", "--name-only", "--cached"],
|
|
195
|
+
["ls-files", "--others", "--exclude-standard"]
|
|
196
|
+
];
|
|
197
|
+
if (resolvedBaseRef) {
|
|
198
|
+
diffCommands.unshift(["diff", "--name-only", resolvedBaseRef, "HEAD"]);
|
|
199
|
+
}
|
|
200
|
+
for (const args of diffCommands) {
|
|
201
|
+
const output = run("git", args, { cwd, capture: true });
|
|
202
|
+
for (const line of output.split("\n").map((entry) => entry.trim()).filter(Boolean)) {
|
|
203
|
+
changedFiles.add(line);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return changedFiles;
|
|
207
|
+
}
|
|
208
|
+
function changedWorkspacePackages(options = {}) {
|
|
209
|
+
const root = options.root ?? workspaceRoot();
|
|
210
|
+
const baseRef = options.baseRef ?? process.env.TREESEED_RELEASE_BASE_REF ?? "HEAD^";
|
|
211
|
+
const includeDependents = options.includeDependents ?? false;
|
|
212
|
+
const packages = options.packages ?? workspacePackages(root);
|
|
213
|
+
const changedFiles = changedWorkspaceFiles(baseRef, root);
|
|
214
|
+
const changed = new Set(
|
|
215
|
+
packages.filter((pkg) => [...changedFiles].some((file) => file === pkg.relativeDir || file.startsWith(`${pkg.relativeDir}/`))).map((pkg) => pkg.name)
|
|
216
|
+
);
|
|
217
|
+
if (includeDependents && changed.size > 0) {
|
|
218
|
+
const packageMap = new Map(packages.map((pkg) => [pkg.name, pkg]));
|
|
219
|
+
const packageNames = new Set(packageMap.keys());
|
|
220
|
+
const reverseDeps = new Map(packages.map((pkg) => [pkg.name, /* @__PURE__ */ new Set()]));
|
|
221
|
+
for (const pkg of packages) {
|
|
222
|
+
for (const dep of internalDependenciesFor(pkg, packageNames)) {
|
|
223
|
+
reverseDeps.get(dep)?.add(pkg.name);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
const queue = [...changed];
|
|
227
|
+
while (queue.length > 0) {
|
|
228
|
+
const next = queue.shift();
|
|
229
|
+
for (const dependent of reverseDeps.get(next) ?? []) {
|
|
230
|
+
if (changed.has(dependent)) {
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
changed.add(dependent);
|
|
234
|
+
queue.push(dependent);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return sortWorkspacePackages(packages.filter((pkg) => changed.has(pkg.name)));
|
|
239
|
+
}
|
|
240
|
+
function publishableWorkspacePackages(root = workspaceRoot()) {
|
|
241
|
+
return packagesWithScript("release:publish", root);
|
|
242
|
+
}
|
|
243
|
+
function createTempDir(prefix) {
|
|
244
|
+
const baseRoot = resolve(process.env.TREESEED_TEMP_ROOT ?? resolve(workspaceRoot(), ".local", "tmp"));
|
|
245
|
+
mkdirSync(baseRoot, { recursive: true });
|
|
246
|
+
return mkdtempSync(join(baseRoot, prefix));
|
|
247
|
+
}
|
|
248
|
+
function cleanupDir(dirPath) {
|
|
249
|
+
if (dirPath && existsSync(dirPath)) {
|
|
250
|
+
rmSync(dirPath, { recursive: true, force: true });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
export {
|
|
254
|
+
changedWorkspacePackages,
|
|
255
|
+
cleanupDir,
|
|
256
|
+
createTempDir,
|
|
257
|
+
findNearestTreeseedRoot,
|
|
258
|
+
findNearestTreeseedWorkspaceRoot,
|
|
259
|
+
hasCompleteTreeseedPackageCheckout,
|
|
260
|
+
isWorkspaceRoot,
|
|
261
|
+
packagesWithScript,
|
|
262
|
+
publishableWorkspacePackages,
|
|
263
|
+
readJson,
|
|
264
|
+
run,
|
|
265
|
+
sortWorkspacePackages,
|
|
266
|
+
workspacePackageJson,
|
|
267
|
+
workspacePackages,
|
|
268
|
+
workspacePatterns,
|
|
269
|
+
workspaceRoot
|
|
270
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TreeseedOperationMetadata } from './operations-types.ts';
|
|
2
|
+
export declare const TRESEED_OPERATION_SPECS: TreeseedOperationMetadata[];
|
|
3
|
+
export declare const TRESEED_OPERATION_INDEX: Map<string, TreeseedOperationMetadata>;
|
|
4
|
+
export declare function findTreeseedOperation(name: string | null | undefined): TreeseedOperationMetadata | null;
|
|
5
|
+
export declare function listTreeseedOperationNames(): string[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
function operation(spec) {
|
|
2
|
+
return spec;
|
|
3
|
+
}
|
|
4
|
+
const TRESEED_OPERATION_SPECS = [
|
|
5
|
+
operation({ id: "workspace.status", name: "status", aliases: [], group: "Workflow", summary: "Show Treeseed project health and the current task state.", description: "Report branch/task state, runtime readiness, preview/deploy state, auth readiness, and recommended next operations.", provider: "default", related: ["tasks", "switch", "config"] }),
|
|
6
|
+
operation({ id: "branch.tasks", name: "tasks", aliases: [], group: "Workflow", summary: "List task branches and preview metadata.", description: "List task-based preview Git branches from local and origin, excluding protected and deprecated refs.", provider: "default", related: ["status", "switch", "close"] }),
|
|
7
|
+
operation({ id: "branch.switch", name: "switch", aliases: [], group: "Workflow", summary: "Create or resume a task branch.", description: "Create a new task branch from staging or resume an existing local or remote task branch.", provider: "default", related: ["tasks", "dev", "save"] }),
|
|
8
|
+
operation({ id: "branch.save", name: "save", aliases: [], group: "Workflow", summary: "Verify, commit, sync, push, and refresh preview for the current task.", description: "Run lint, test, and build verification, sync the current branch with origin, push it, and refresh the branch preview when enabled.", provider: "default", related: ["switch", "stage", "status"] }),
|
|
9
|
+
operation({ id: "branch.close", name: "close", aliases: [], group: "Workflow", summary: "Archive a task branch without merging it.", description: "Destroy branch preview resources, create a deprecated resurrection tag, push the tag, and delete the local and remote branch.", provider: "default", related: ["tasks", "switch", "stage"] }),
|
|
10
|
+
operation({ id: "branch.stage", name: "stage", aliases: [], group: "Workflow", summary: "Merge the current task into staging and clean it up.", description: "Verify the current task branch, merge it into staging, wait for staging automation, clean preview resources, create a deprecated resurrection tag, and delete the task branch.", provider: "default", related: ["save", "release", "close"] }),
|
|
11
|
+
operation({ id: "deploy.rollback", name: "rollback", aliases: [], group: "Workflow", summary: "Roll back staging or production to a recorded deployment.", description: "Redeploy a previously recorded staging or production commit using a temporary checkout of that revision.", provider: "default", related: ["status", "release"] }),
|
|
12
|
+
operation({ id: "workspace.doctor", name: "doctor", aliases: [], group: "Validation", summary: "Diagnose Treeseed tooling, auth, and workflow readiness.", description: "Collect doctor-style diagnostics for workspace readiness and optional safe repairs.", provider: "default", related: ["status", "config"] }),
|
|
13
|
+
operation({ id: "auth.login", name: "auth:login", aliases: [], group: "Validation", summary: "Authenticate against the configured Treeseed API.", description: "Start the device login flow against the active Treeseed API host and persist the returned session locally.", provider: "default", related: ["auth:check", "auth:whoami", "auth:logout"] }),
|
|
14
|
+
operation({ id: "auth.logout", name: "auth:logout", aliases: [], group: "Validation", summary: "Clear locally stored Treeseed API credentials.", description: "Remove the persisted local device-flow session for the active Treeseed API host.", provider: "default", related: ["auth:login", "auth:whoami"] }),
|
|
15
|
+
operation({ id: "auth.whoami", name: "auth:whoami", aliases: [], group: "Validation", summary: "Inspect the active Treeseed API identity.", description: "Use the persisted local remote session to query the active Treeseed API principal.", provider: "default", related: ["auth:login", "status"] }),
|
|
16
|
+
operation({ id: "template.list", name: "template", aliases: [], group: "Utilities", summary: "List, inspect, and validate templates from the Treeseed catalog.", description: "Use remote template metadata to list templates, show one template, or validate local template artifacts.", provider: "default", related: ["init", "sync"] }),
|
|
17
|
+
operation({ id: "template.sync", name: "sync", aliases: [], group: "Validation", summary: "Validate or reconcile the managed template surface for the current site.", description: "Use remote template metadata plus the local scaffold artifact to check or apply updates to the managed scaffold surface.", provider: "default", related: ["template", "init", "status"] }),
|
|
18
|
+
operation({ id: "project.init", name: "init", aliases: [], group: "Workflow", summary: "Scaffold a new Treeseed tenant project.", description: "Create a new Treeseed tenant directory from a remote-catalog template backed by the packaged scaffold artifact.", provider: "default", related: ["config", "switch", "dev"] }),
|
|
19
|
+
operation({ id: "project.config", name: "config", aliases: [], group: "Workflow", summary: "Configure and test the runtime foundation.", description: "Apply safe repairs, collect environment values, write local machine config, generate local env files, initialize environments, sync providers, and run doctor-style checks.", provider: "default", related: ["status", "switch", "dev"] }),
|
|
20
|
+
operation({ id: "deploy.release", name: "release", aliases: [], group: "Workflow", summary: "Promote staging to production with a version bump.", description: "Validate staging, apply one version bump, tag the release, merge staging into main, push, and rely on production deploy automation.", provider: "default", related: ["stage", "status", "rollback"] }),
|
|
21
|
+
operation({ id: "deploy.destroy", name: "destroy", aliases: [], group: "Workflow", summary: "Destroy a persistent environment and its local state.", description: "Delete the selected persistent environment resources and remove the local deploy state after confirmation.", provider: "default", related: ["config", "status"] }),
|
|
22
|
+
operation({ id: "local.dev", name: "dev", aliases: [], group: "Local Development", summary: "Start the unified local Treeseed development environment.", description: "Start the unified local Treeseed development environment.", provider: "default" }),
|
|
23
|
+
operation({ id: "local.devWatch", name: "dev:watch", aliases: [], group: "Local Development", summary: "Start local development with rebuild and watch mode.", description: "Start local development with rebuild and watch mode.", provider: "default" }),
|
|
24
|
+
operation({ id: "local.build", name: "build", aliases: [], group: "Local Development", summary: "Build the tenant site and generated worker artifacts.", description: "Build the tenant site and generated worker artifacts.", provider: "default" }),
|
|
25
|
+
operation({ id: "local.check", name: "check", aliases: [], group: "Local Development", summary: "Run the tenant check flow.", description: "Run the tenant check flow.", provider: "default" }),
|
|
26
|
+
operation({ id: "local.preview", name: "preview", aliases: [], group: "Local Development", summary: "Preview the built tenant site locally.", description: "Preview the built tenant site locally.", provider: "default" }),
|
|
27
|
+
operation({ id: "local.lint", name: "lint", aliases: [], group: "Validation", summary: "Run Treeseed lint checks.", description: "Run Treeseed lint checks.", provider: "default" }),
|
|
28
|
+
operation({ id: "local.test", name: "test", aliases: [], group: "Validation", summary: "Run Treeseed tests.", description: "Run Treeseed tests.", provider: "default" }),
|
|
29
|
+
operation({ id: "validation.testUnit", name: "test:unit", aliases: [], group: "Validation", summary: "Run workspace unit tests in dependency order.", description: "Run workspace unit tests in dependency order.", provider: "default" }),
|
|
30
|
+
operation({ id: "validation.preflight", name: "preflight", aliases: [], group: "Validation", summary: "Check local prerequisites and authentication state.", description: "Check local prerequisites and authentication state.", provider: "default" }),
|
|
31
|
+
operation({ id: "validation.authCheck", name: "auth:check", aliases: [], group: "Validation", summary: "Check local prerequisites and require authenticated tooling.", description: "Check local prerequisites and require authenticated tooling.", provider: "default" }),
|
|
32
|
+
operation({ id: "release.testE2e", name: "test:e2e", aliases: [], group: "Release Utilities", summary: "Run Treeseed end-to-end command tests.", description: "Run Treeseed end-to-end command tests.", provider: "default" }),
|
|
33
|
+
operation({ id: "release.testE2eLocal", name: "test:e2e:local", aliases: [], group: "Release Utilities", summary: "Run local-mode Treeseed end-to-end command tests.", description: "Run local-mode Treeseed end-to-end command tests.", provider: "default" }),
|
|
34
|
+
operation({ id: "release.testE2eStaging", name: "test:e2e:staging", aliases: [], group: "Release Utilities", summary: "Run staging-mode Treeseed end-to-end command tests.", description: "Run staging-mode Treeseed end-to-end command tests.", provider: "default" }),
|
|
35
|
+
operation({ id: "release.testE2eFull", name: "test:e2e:full", aliases: [], group: "Release Utilities", summary: "Run the full Treeseed end-to-end command suite.", description: "Run the full Treeseed end-to-end command suite.", provider: "default" }),
|
|
36
|
+
operation({ id: "release.testFast", name: "test:release", aliases: [], group: "Release Utilities", summary: "Run the fast release verification path.", description: "Run the fast release verification path.", provider: "default" }),
|
|
37
|
+
operation({ id: "release.verify", name: "test:release:full", aliases: ["release:verify"], group: "Release Utilities", summary: "Run the full release verification path.", description: "Run the full release verification path.", provider: "default" }),
|
|
38
|
+
operation({ id: "release.publishChanged", name: "release:publish:changed", aliases: [], group: "Release Utilities", summary: "Publish changed Treeseed workspace packages.", description: "Publish changed Treeseed workspace packages.", provider: "default" }),
|
|
39
|
+
operation({ id: "tools.astro", name: "astro", aliases: [], group: "Passthrough", summary: "Pass through to the packaged Astro CLI wrapper.", description: "Pass through to the packaged Astro CLI wrapper.", provider: "default" }),
|
|
40
|
+
operation({ id: "tools.syncDevvars", name: "sync:devvars", aliases: [], group: "Utilities", summary: "Regenerate .dev.vars from local configuration.", description: "Regenerate .dev.vars from local configuration.", provider: "default" }),
|
|
41
|
+
operation({ id: "services.mailpitUp", name: "mailpit:up", aliases: [], group: "Utilities", summary: "Start the package-managed Mailpit service.", description: "Start the package-managed Mailpit service.", provider: "default" }),
|
|
42
|
+
operation({ id: "services.mailpitDown", name: "mailpit:down", aliases: [], group: "Utilities", summary: "Stop the package-managed Mailpit service.", description: "Stop the package-managed Mailpit service.", provider: "default" }),
|
|
43
|
+
operation({ id: "services.mailpitLogs", name: "mailpit:logs", aliases: [], group: "Utilities", summary: "Show Mailpit logs.", description: "Show Mailpit logs.", provider: "default" }),
|
|
44
|
+
operation({ id: "data.d1MigrateLocal", name: "d1:migrate:local", aliases: [], group: "Utilities", summary: "Apply local D1 migrations.", description: "Apply local D1 migrations.", provider: "default" }),
|
|
45
|
+
operation({ id: "content.cleanupMarkdown", name: "cleanup:markdown", aliases: [], group: "Utilities", summary: "Normalize Markdown and MDX files.", description: "Normalize Markdown and MDX files.", provider: "default" }),
|
|
46
|
+
operation({ id: "content.cleanupMarkdownCheck", name: "cleanup:markdown:check", aliases: [], group: "Utilities", summary: "Check Markdown and MDX formatting without rewriting files.", description: "Check Markdown and MDX formatting without rewriting files.", provider: "default" }),
|
|
47
|
+
operation({ id: "tools.starlightPatch", name: "starlight:patch", aliases: [], group: "Utilities", summary: "Apply the Starlight content path patch.", description: "Apply the Starlight content path patch.", provider: "default" })
|
|
48
|
+
];
|
|
49
|
+
const TRESEED_OPERATION_INDEX = /* @__PURE__ */ new Map();
|
|
50
|
+
for (const spec of TRESEED_OPERATION_SPECS) {
|
|
51
|
+
TRESEED_OPERATION_INDEX.set(spec.name, spec);
|
|
52
|
+
for (const alias of spec.aliases) {
|
|
53
|
+
TRESEED_OPERATION_INDEX.set(alias, spec);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function findTreeseedOperation(name) {
|
|
57
|
+
if (!name) return null;
|
|
58
|
+
return TRESEED_OPERATION_INDEX.get(name) ?? null;
|
|
59
|
+
}
|
|
60
|
+
function listTreeseedOperationNames() {
|
|
61
|
+
return [...new Set(TRESEED_OPERATION_SPECS.map((spec) => spec.name))];
|
|
62
|
+
}
|
|
63
|
+
export {
|
|
64
|
+
TRESEED_OPERATION_INDEX,
|
|
65
|
+
TRESEED_OPERATION_SPECS,
|
|
66
|
+
findTreeseedOperation,
|
|
67
|
+
listTreeseedOperationNames
|
|
68
|
+
};
|