@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,243 @@
|
|
|
1
|
+
const CLAUSE_KEYWORDS = /* @__PURE__ */ new Set(["for", "in", "via", "depth", "where", "limit", "budget", "as"]);
|
|
2
|
+
const VALID_STAGES = ["plan", "implement", "research", "debug", "review"];
|
|
3
|
+
const VALID_VIEWS = ["list", "brief", "full", "map"];
|
|
4
|
+
const VALID_RELATIONS = ["related", "depends_on", "implements", "references", "parent", "child", "supersedes"];
|
|
5
|
+
const VALID_WHERE_FIELDS = /* @__PURE__ */ new Set(["type", "status", "audience", "tag", "domain"]);
|
|
6
|
+
function tokenize(source) {
|
|
7
|
+
const tokens = [];
|
|
8
|
+
let current = "";
|
|
9
|
+
let quote = null;
|
|
10
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
11
|
+
const char = source[index];
|
|
12
|
+
if (quote) {
|
|
13
|
+
if (char === quote) {
|
|
14
|
+
tokens.push(current);
|
|
15
|
+
current = "";
|
|
16
|
+
quote = null;
|
|
17
|
+
} else {
|
|
18
|
+
current += char;
|
|
19
|
+
}
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (char === '"' || char === "'") {
|
|
23
|
+
if (current.trim()) {
|
|
24
|
+
tokens.push(current.trim());
|
|
25
|
+
current = "";
|
|
26
|
+
}
|
|
27
|
+
quote = char;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (/\s/u.test(char)) {
|
|
31
|
+
if (current.trim()) {
|
|
32
|
+
tokens.push(current.trim());
|
|
33
|
+
current = "";
|
|
34
|
+
}
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
current += char;
|
|
38
|
+
}
|
|
39
|
+
if (quote) {
|
|
40
|
+
return { tokens, error: "Unterminated quoted string in ctx query." };
|
|
41
|
+
}
|
|
42
|
+
if (current.trim()) {
|
|
43
|
+
tokens.push(current.trim());
|
|
44
|
+
}
|
|
45
|
+
return { tokens, error: null };
|
|
46
|
+
}
|
|
47
|
+
function nextClauseIndex(tokens, start) {
|
|
48
|
+
for (let index = start; index < tokens.length; index += 1) {
|
|
49
|
+
if (CLAUSE_KEYWORDS.has(tokens[index])) {
|
|
50
|
+
return index;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return tokens.length;
|
|
54
|
+
}
|
|
55
|
+
function nextClauseIndexForClause(tokens, start, clause) {
|
|
56
|
+
for (let index = start; index < tokens.length; index += 1) {
|
|
57
|
+
const token = tokens[index];
|
|
58
|
+
if (!CLAUSE_KEYWORDS.has(token)) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
if (clause === "where" && token === "in") {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
return index;
|
|
65
|
+
}
|
|
66
|
+
return tokens.length;
|
|
67
|
+
}
|
|
68
|
+
function parseTarget(rawTarget) {
|
|
69
|
+
if (rawTarget.startsWith("@")) {
|
|
70
|
+
return { id: "seed:0", kind: "id", value: rawTarget.slice(1) };
|
|
71
|
+
}
|
|
72
|
+
if (rawTarget.startsWith("/")) {
|
|
73
|
+
return { id: "seed:0", kind: "path", value: rawTarget };
|
|
74
|
+
}
|
|
75
|
+
if (rawTarget.startsWith("#")) {
|
|
76
|
+
return { id: "seed:0", kind: "tag", value: rawTarget.slice(1) };
|
|
77
|
+
}
|
|
78
|
+
if (rawTarget.startsWith("%")) {
|
|
79
|
+
return { id: "seed:0", kind: "type", value: rawTarget.slice(1) };
|
|
80
|
+
}
|
|
81
|
+
return { id: "seed:0", kind: "query", value: rawTarget };
|
|
82
|
+
}
|
|
83
|
+
function parseWhere(expression) {
|
|
84
|
+
const equality = expression.match(/^\s*([a-z_]+)\s*=\s*([^)]+?)\s*$/iu);
|
|
85
|
+
if (equality) {
|
|
86
|
+
const field = equality[1].toLowerCase();
|
|
87
|
+
if (!VALID_WHERE_FIELDS.has(field)) {
|
|
88
|
+
return { error: `Unsupported where field "${field}".` };
|
|
89
|
+
}
|
|
90
|
+
return [{ field, op: "eq", value: equality[2].trim() }];
|
|
91
|
+
}
|
|
92
|
+
const membership = expression.match(/^\s*([a-z_]+)\s+in\s*\(([^)]*)\)\s*$/iu);
|
|
93
|
+
if (membership) {
|
|
94
|
+
const field = membership[1].toLowerCase();
|
|
95
|
+
if (!VALID_WHERE_FIELDS.has(field)) {
|
|
96
|
+
return { error: `Unsupported where field "${field}".` };
|
|
97
|
+
}
|
|
98
|
+
const values = membership[2].split(",").map((entry) => entry.trim()).filter(Boolean);
|
|
99
|
+
if (values.length === 0) {
|
|
100
|
+
return { error: "where in (...) must include at least one value." };
|
|
101
|
+
}
|
|
102
|
+
return [{ field, op: "in", value: values }];
|
|
103
|
+
}
|
|
104
|
+
return { error: `Invalid where clause "${expression}".` };
|
|
105
|
+
}
|
|
106
|
+
function parseGraphDsl(source) {
|
|
107
|
+
const errors = [];
|
|
108
|
+
const request = {
|
|
109
|
+
stage: "plan",
|
|
110
|
+
relations: ["related", "references"],
|
|
111
|
+
view: "brief",
|
|
112
|
+
options: {
|
|
113
|
+
depth: 1,
|
|
114
|
+
limit: 8,
|
|
115
|
+
maxNodes: 8
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const budget = {};
|
|
119
|
+
const seenClauses = /* @__PURE__ */ new Set();
|
|
120
|
+
const tokenized = tokenize(source.trim());
|
|
121
|
+
if (tokenized.error) {
|
|
122
|
+
return { ok: false, query: null, errors: [tokenized.error] };
|
|
123
|
+
}
|
|
124
|
+
const { tokens } = tokenized;
|
|
125
|
+
if (tokens.length === 0) {
|
|
126
|
+
return { ok: false, query: null, errors: ["ctx query is empty."] };
|
|
127
|
+
}
|
|
128
|
+
if (tokens[0] !== "ctx") {
|
|
129
|
+
return { ok: false, query: null, errors: ["ctx query must start with the `ctx` command."] };
|
|
130
|
+
}
|
|
131
|
+
const firstClause = nextClauseIndex(tokens, 1);
|
|
132
|
+
const targetTokens = tokens.slice(1, firstClause);
|
|
133
|
+
if (targetTokens.length === 0) {
|
|
134
|
+
return { ok: false, query: null, errors: ["ctx query must include a target."] };
|
|
135
|
+
}
|
|
136
|
+
request.seeds = [parseTarget(targetTokens.join(" "))];
|
|
137
|
+
for (let index = firstClause; index < tokens.length; ) {
|
|
138
|
+
const clause = tokens[index];
|
|
139
|
+
if (!CLAUSE_KEYWORDS.has(clause)) {
|
|
140
|
+
errors.push(`Unexpected token "${clause}".`);
|
|
141
|
+
index += 1;
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (seenClauses.has(clause)) {
|
|
145
|
+
errors.push(`Clause "${clause}" may only appear once.`);
|
|
146
|
+
}
|
|
147
|
+
seenClauses.add(clause);
|
|
148
|
+
const valueStart = index + 1;
|
|
149
|
+
const valueEnd = nextClauseIndexForClause(tokens, valueStart, clause);
|
|
150
|
+
const rawValue = tokens.slice(valueStart, valueEnd).join(" ").trim();
|
|
151
|
+
if (!rawValue) {
|
|
152
|
+
errors.push(`Clause "${clause}" requires a value.`);
|
|
153
|
+
index = valueEnd;
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
switch (clause) {
|
|
157
|
+
case "for":
|
|
158
|
+
if (!VALID_STAGES.includes(rawValue)) {
|
|
159
|
+
errors.push(`Invalid stage "${rawValue}".`);
|
|
160
|
+
} else {
|
|
161
|
+
request.stage = rawValue;
|
|
162
|
+
}
|
|
163
|
+
break;
|
|
164
|
+
case "in": {
|
|
165
|
+
const scopePaths = rawValue.split("+").map((entry) => entry.trim()).filter(Boolean);
|
|
166
|
+
if (scopePaths.length === 0 || scopePaths.some((entry) => !entry.startsWith("/"))) {
|
|
167
|
+
errors.push(`Invalid scope path list "${rawValue}".`);
|
|
168
|
+
} else {
|
|
169
|
+
request.scopePaths = scopePaths;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
case "via": {
|
|
174
|
+
const relations = rawValue.split(",").map((entry) => entry.trim().toLowerCase()).filter(Boolean);
|
|
175
|
+
const invalid = relations.filter((entry) => !VALID_RELATIONS.includes(entry));
|
|
176
|
+
if (invalid.length > 0) {
|
|
177
|
+
errors.push(`Invalid relations: ${invalid.join(", ")}`);
|
|
178
|
+
} else {
|
|
179
|
+
request.relations = relations;
|
|
180
|
+
}
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
case "depth": {
|
|
184
|
+
const depth = Number(rawValue);
|
|
185
|
+
if (!Number.isInteger(depth) || depth < 0 || depth > 3) {
|
|
186
|
+
errors.push(`Depth must be an integer between 0 and 3, received "${rawValue}".`);
|
|
187
|
+
} else {
|
|
188
|
+
request.options = { ...request.options ?? {}, depth };
|
|
189
|
+
}
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
case "where": {
|
|
193
|
+
const parsed = parseWhere(rawValue);
|
|
194
|
+
if ("error" in parsed) {
|
|
195
|
+
errors.push(parsed.error);
|
|
196
|
+
} else {
|
|
197
|
+
request.where = parsed;
|
|
198
|
+
}
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
case "limit": {
|
|
202
|
+
const limit = Number(rawValue);
|
|
203
|
+
if (!Number.isInteger(limit) || limit <= 0) {
|
|
204
|
+
errors.push(`Limit must be a positive integer, received "${rawValue}".`);
|
|
205
|
+
} else {
|
|
206
|
+
request.options = { ...request.options ?? {}, limit, maxNodes: limit };
|
|
207
|
+
budget.maxNodes = limit;
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
case "budget": {
|
|
212
|
+
const maxTokens = Number(rawValue);
|
|
213
|
+
if (!Number.isInteger(maxTokens) || maxTokens <= 0) {
|
|
214
|
+
errors.push(`Budget must be a positive integer, received "${rawValue}".`);
|
|
215
|
+
} else {
|
|
216
|
+
budget.maxTokens = maxTokens;
|
|
217
|
+
}
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
case "as":
|
|
221
|
+
if (!VALID_VIEWS.includes(rawValue)) {
|
|
222
|
+
errors.push(`Invalid view "${rawValue}".`);
|
|
223
|
+
} else {
|
|
224
|
+
request.view = rawValue;
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
default:
|
|
228
|
+
errors.push(`Unknown clause "${clause}".`);
|
|
229
|
+
}
|
|
230
|
+
index = valueEnd;
|
|
231
|
+
}
|
|
232
|
+
if (Object.keys(budget).length > 0) {
|
|
233
|
+
request.budget = budget;
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
ok: errors.length === 0,
|
|
237
|
+
query: errors.length === 0 ? request : null,
|
|
238
|
+
errors
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
parseGraphDsl
|
|
243
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SdkContextPack, SdkContextPackRequest, SdkGraphEdge, SdkGraphNode, SdkGraphQueryOptions, SdkGraphQueryRequest, SdkGraphQueryResult, SdkGraphPathExplanation, SdkGraphRankingProvider, SdkGraphSearchOptions, SdkGraphSearchResult, SdkGraphSeedResolution, SdkGraphTraversalResult } from '../sdk-types.ts';
|
|
2
|
+
import type { GraphBuildState } from './build.ts';
|
|
3
|
+
export declare class GraphQueryEngine {
|
|
4
|
+
private readonly state;
|
|
5
|
+
private readonly onQuery?;
|
|
6
|
+
private readonly nodesById;
|
|
7
|
+
private readonly edgesById;
|
|
8
|
+
private readonly outgoing;
|
|
9
|
+
private readonly incoming;
|
|
10
|
+
private readonly fileSections;
|
|
11
|
+
private readonly rankingProvider;
|
|
12
|
+
private readonly rankingIndex;
|
|
13
|
+
constructor(state: GraphBuildState, onQuery?: ((name: string, detail?: string) => void) | undefined, rankingProvider?: SdkGraphRankingProvider);
|
|
14
|
+
private filterSearchResults;
|
|
15
|
+
private eligibleNodeIds;
|
|
16
|
+
searchFiles(query: string, options?: SdkGraphSearchOptions): SdkGraphSearchResult[];
|
|
17
|
+
searchSections(query: string, options?: SdkGraphSearchOptions): SdkGraphSearchResult[];
|
|
18
|
+
searchEntities(query: string, options?: SdkGraphSearchOptions): SdkGraphSearchResult[];
|
|
19
|
+
getNode(id: string): SdkGraphNode | null;
|
|
20
|
+
getNeighbors(id: string, options?: SdkGraphQueryOptions): {
|
|
21
|
+
node: SdkGraphNode | null;
|
|
22
|
+
nodes: SdkGraphNode[];
|
|
23
|
+
edges: SdkGraphEdge[];
|
|
24
|
+
};
|
|
25
|
+
followReferences(seedId: string, options?: SdkGraphQueryOptions): SdkGraphTraversalResult;
|
|
26
|
+
getBacklinks(id: string, options?: SdkGraphQueryOptions): {
|
|
27
|
+
node: SdkGraphNode | null;
|
|
28
|
+
nodes: SdkGraphNode[];
|
|
29
|
+
edges: SdkGraphEdge[];
|
|
30
|
+
};
|
|
31
|
+
getRelated(id: string, options?: SdkGraphQueryOptions): import("../sdk-types.ts").SdkGraphQueryNodeResult[];
|
|
32
|
+
getSubgraph(seedIds: string[], options?: SdkGraphQueryOptions): SdkGraphTraversalResult;
|
|
33
|
+
resolveSeeds(request: SdkGraphQueryRequest): SdkGraphSeedResolution;
|
|
34
|
+
queryGraph(request: SdkGraphQueryRequest): SdkGraphQueryResult;
|
|
35
|
+
buildContextPack(request: SdkContextPackRequest): SdkContextPack;
|
|
36
|
+
parseDsl(source: string): import("../sdk-types.ts").SdkGraphDslParseResult;
|
|
37
|
+
explainReferenceChain(fromId: string, toId: string): SdkGraphPathExplanation | null;
|
|
38
|
+
resolveReference(reference: string, options?: {
|
|
39
|
+
fromNodeId?: string;
|
|
40
|
+
fromPath?: string;
|
|
41
|
+
models?: string[];
|
|
42
|
+
}): SdkGraphNode | null;
|
|
43
|
+
serializeIndexes(): {
|
|
44
|
+
providerId: string;
|
|
45
|
+
ranking: Record<string, unknown> | null;
|
|
46
|
+
};
|
|
47
|
+
}
|