@treeseed/core 0.3.0 → 0.4.0

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.
Files changed (54) hide show
  1. package/README.md +26 -3
  2. package/dist/config.js +1 -1
  3. package/dist/content-config.js +1 -1
  4. package/dist/content.js +3 -3
  5. package/dist/index.js +1 -68
  6. package/dist/scripts/aggregate-book.js +1 -1
  7. package/dist/scripts/build-dist.js +3 -14
  8. package/dist/scripts/build-tenant-worker.js +2 -2
  9. package/dist/scripts/run-fixture-astro-command.js +219 -0
  10. package/dist/site-resources.d.ts +2 -2
  11. package/dist/site.js +3 -3
  12. package/dist/tenant/bridge.js +1 -1
  13. package/dist/tenant/runtime-config.js +1 -1
  14. package/dist/utils/forms/config.js +5 -1
  15. package/dist/utils/forms/provider-runtime.js +42 -0
  16. package/dist/utils/forms/service.js +2 -2
  17. package/dist/utils/starlight-nav.js +6 -1
  18. package/package.json +5 -37
  19. package/dist/agents/index.js +0 -5
  20. package/dist/agents/registry-helper.js +0 -14
  21. package/dist/agents/registry.js +0 -88
  22. package/dist/contracts.d.ts +0 -1
  23. package/dist/contracts.js +0 -0
  24. package/dist/deploy/config.d.ts +0 -1
  25. package/dist/deploy/config.js +0 -10
  26. package/dist/deploy/runtime.js +0 -81
  27. package/dist/environment.d.ts +0 -2
  28. package/dist/environment.js +0 -26
  29. package/dist/plugin-default.js +0 -4
  30. package/dist/plugins/builtin/default-plugin.js +0 -37
  31. package/dist/plugins/constants.d.ts +0 -1
  32. package/dist/plugins/constants.js +0 -10
  33. package/dist/plugins/plugin.d.ts +0 -2
  34. package/dist/plugins/plugin.js +0 -4
  35. package/dist/plugins/runtime.d.ts +0 -32
  36. package/dist/plugins/runtime.js +0 -138
  37. package/dist/tenant/config.js +0 -16
  38. package/dist/types/agents.d.ts +0 -1
  39. package/dist/types/agents.js +0 -1
  40. package/dist/utils/agents/adapters/execution.js +0 -90
  41. package/dist/utils/agents/adapters/mutations.js +0 -30
  42. package/dist/utils/agents/adapters/notification.js +0 -16
  43. package/dist/utils/agents/adapters/repository.js +0 -61
  44. package/dist/utils/agents/adapters/research.js +0 -25
  45. package/dist/utils/agents/adapters/verification.js +0 -62
  46. package/dist/utils/agents/cli-tools.js +0 -5
  47. package/dist/utils/agents/contracts/messages.d.ts +0 -88
  48. package/dist/utils/agents/contracts/messages.js +0 -138
  49. package/dist/utils/agents/contracts/run.d.ts +0 -20
  50. package/dist/utils/agents/contracts/run.js +0 -0
  51. package/dist/utils/agents/runtime-types.d.ts +0 -117
  52. package/dist/utils/agents/runtime-types.js +0 -4
  53. package/dist/utils/books-data.js +0 -14
  54. package/dist/utils/plugin-runtime.js +0 -158
@@ -1,158 +0,0 @@
1
- import { loadTreeseedPluginRuntime } from "../plugins/runtime.js";
2
- import { BUILTIN_FORMS_PROVIDERS, finalizeFormsProvider } from "./forms/provider-core.js";
3
- import { StubExecutionAdapter, ManualExecutionAdapter, CopilotExecutionAdapter } from "./agents/adapters/execution.js";
4
- import { LocalBranchMutationAdapter } from "./agents/adapters/mutations.js";
5
- import { StubNotificationAdapter } from "./agents/adapters/notification.js";
6
- import { GitRepositoryInspectionAdapter, StubRepositoryInspectionAdapter } from "./agents/adapters/repository.js";
7
- import { StubResearchAdapter } from "./agents/adapters/research.js";
8
- import { LocalVerificationAdapter, StubVerificationAdapter } from "./agents/adapters/verification.js";
9
- let cachedAgentRuntime = null;
10
- let cachedFormsRuntime = null;
11
- function readPluginRecord(pluginEntry, key) {
12
- const value = pluginEntry.plugin[key];
13
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
14
- }
15
- function assertUniqueProvider(registry, id, owner) {
16
- if (registry.has(id)) {
17
- throw new Error(`Treeseed plugin runtime found duplicate provider "${id}" from ${owner}.`);
18
- }
19
- }
20
- function resetTreeseedPluginRuntimeForTests() {
21
- cachedAgentRuntime = null;
22
- cachedFormsRuntime = null;
23
- }
24
- function resolveFormsProvider(providerId) {
25
- if (!cachedFormsRuntime) {
26
- const runtime = loadTreeseedPluginRuntime();
27
- const providers = /* @__PURE__ */ new Map();
28
- for (const provider2 of Object.values(BUILTIN_FORMS_PROVIDERS)) {
29
- providers.set(provider2.id, provider2);
30
- }
31
- for (const pluginEntry of runtime.plugins) {
32
- const contributedProviders = readPluginRecord(pluginEntry, "formsProviders");
33
- for (const [id, provider2] of Object.entries(contributedProviders)) {
34
- assertUniqueProvider(providers, id, pluginEntry.package);
35
- providers.set(id, provider2);
36
- }
37
- }
38
- cachedFormsRuntime = { providers };
39
- }
40
- const provider = cachedFormsRuntime.providers.get(providerId);
41
- if (!provider) {
42
- throw new Error(`Treeseed forms provider "${providerId}" is not registered.`);
43
- }
44
- return finalizeFormsProvider(provider);
45
- }
46
- function collectAgentHandlersFromPlugin(pluginEntry, registry) {
47
- const contributedHandlers = readPluginRecord(pluginEntry, "agentHandlers");
48
- for (const [id, handler] of Object.entries(contributedHandlers)) {
49
- assertUniqueProvider(registry, id, pluginEntry.package);
50
- registry.set(id, handler);
51
- }
52
- }
53
- function buildAgentRuntime() {
54
- const runtime = loadTreeseedPluginRuntime();
55
- const execution = /* @__PURE__ */ new Map([
56
- ["stub", () => new StubExecutionAdapter()],
57
- ["manual", () => new ManualExecutionAdapter()],
58
- ["copilot", () => new CopilotExecutionAdapter()]
59
- ]);
60
- const mutation = /* @__PURE__ */ new Map([
61
- ["local_branch", (repoRoot) => new LocalBranchMutationAdapter(repoRoot)]
62
- ]);
63
- const repository = /* @__PURE__ */ new Map([
64
- ["stub", () => new StubRepositoryInspectionAdapter()],
65
- ["git", () => new GitRepositoryInspectionAdapter()]
66
- ]);
67
- const verification = /* @__PURE__ */ new Map([
68
- ["stub", () => new StubVerificationAdapter()],
69
- ["local", () => new LocalVerificationAdapter()]
70
- ]);
71
- const notification = /* @__PURE__ */ new Map([
72
- ["stub", () => new StubNotificationAdapter()]
73
- ]);
74
- const research = /* @__PURE__ */ new Map([
75
- ["stub", () => new StubResearchAdapter()]
76
- ]);
77
- const handlers = /* @__PURE__ */ new Map();
78
- for (const pluginEntry of runtime.plugins) {
79
- const agentProviders = readPluginRecord(pluginEntry, "agentProviders");
80
- for (const [id, factory] of Object.entries(agentProviders.execution ?? {})) {
81
- assertUniqueProvider(execution, id, pluginEntry.package);
82
- execution.set(id, factory);
83
- }
84
- for (const [id, factory] of Object.entries(
85
- agentProviders.mutation ?? {}
86
- )) {
87
- assertUniqueProvider(mutation, id, pluginEntry.package);
88
- mutation.set(id, factory);
89
- }
90
- for (const [id, factory] of Object.entries(
91
- agentProviders.repository ?? {}
92
- )) {
93
- assertUniqueProvider(repository, id, pluginEntry.package);
94
- repository.set(id, factory);
95
- }
96
- for (const [id, factory] of Object.entries(
97
- agentProviders.verification ?? {}
98
- )) {
99
- assertUniqueProvider(verification, id, pluginEntry.package);
100
- verification.set(id, factory);
101
- }
102
- for (const [id, factory] of Object.entries(
103
- agentProviders.notification ?? {}
104
- )) {
105
- assertUniqueProvider(notification, id, pluginEntry.package);
106
- notification.set(id, factory);
107
- }
108
- for (const [id, factory] of Object.entries(
109
- agentProviders.research ?? {}
110
- )) {
111
- assertUniqueProvider(research, id, pluginEntry.package);
112
- research.set(id, factory);
113
- }
114
- collectAgentHandlersFromPlugin(pluginEntry, handlers);
115
- }
116
- return {
117
- providers: {
118
- execution,
119
- mutation,
120
- repository,
121
- verification,
122
- notification,
123
- research
124
- },
125
- handlers
126
- };
127
- }
128
- function resolveAgentRuntimeProviders(repoRoot, selections) {
129
- if (!cachedAgentRuntime) {
130
- cachedAgentRuntime = buildAgentRuntime();
131
- }
132
- const executionFactory = cachedAgentRuntime.providers.execution.get(selections.execution);
133
- const mutationFactory = cachedAgentRuntime.providers.mutation.get(selections.mutation);
134
- const repositoryFactory = cachedAgentRuntime.providers.repository.get(selections.repository);
135
- const verificationFactory = cachedAgentRuntime.providers.verification.get(selections.verification);
136
- const notificationFactory = cachedAgentRuntime.providers.notification.get(selections.notification);
137
- const researchFactory = cachedAgentRuntime.providers.research.get(selections.research);
138
- if (!executionFactory) throw new Error(`Treeseed agent execution provider "${selections.execution}" is not registered.`);
139
- if (!mutationFactory) throw new Error(`Treeseed agent mutation provider "${selections.mutation}" is not registered.`);
140
- if (!repositoryFactory) throw new Error(`Treeseed agent repository provider "${selections.repository}" is not registered.`);
141
- if (!verificationFactory) throw new Error(`Treeseed agent verification provider "${selections.verification}" is not registered.`);
142
- if (!notificationFactory) throw new Error(`Treeseed agent notification provider "${selections.notification}" is not registered.`);
143
- if (!researchFactory) throw new Error(`Treeseed agent research provider "${selections.research}" is not registered.`);
144
- return {
145
- execution: executionFactory(),
146
- mutations: mutationFactory(repoRoot),
147
- repository: repositoryFactory(),
148
- verification: verificationFactory(),
149
- notifications: notificationFactory(),
150
- research: researchFactory(),
151
- handlers: cachedAgentRuntime.handlers
152
- };
153
- }
154
- export {
155
- resetTreeseedPluginRuntimeForTests,
156
- resolveAgentRuntimeProviders,
157
- resolveFormsProvider
158
- };