@h-rig/core 0.0.6-alpha.18 → 0.0.6-alpha.181
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/agent-role-registry.d.ts +4 -0
- package/dist/src/agent-role-registry.js +27 -0
- package/dist/src/authority-paths.d.ts +15 -0
- package/dist/src/authority-paths.js +80 -0
- package/dist/src/baked-secrets.d.ts +3 -0
- package/dist/src/baked-secrets.js +63 -0
- package/dist/src/build-time-config.d.ts +12 -0
- package/dist/src/build-time-config.js +25 -0
- package/dist/src/build-time-config.macro.d.ts +1 -0
- package/dist/src/capability-loaders.d.ts +51 -0
- package/dist/src/capability-loaders.js +870 -0
- package/dist/src/capability.d.ts +79 -0
- package/dist/src/capability.js +63 -0
- package/dist/src/checkout-root.d.ts +1 -0
- package/dist/src/checkout-root.js +30 -0
- package/dist/src/config-env.d.ts +4 -0
- package/dist/src/config-env.js +23 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.js +44 -0
- package/dist/src/declarative-config.d.ts +14 -0
- package/dist/src/declarative-config.js +85 -0
- package/dist/src/default-kernel.d.ts +1 -0
- package/dist/src/default-kernel.js +12 -0
- package/dist/src/define-config.d.ts +20 -0
- package/dist/src/define-config.js +28 -15
- package/dist/src/define-plugin.d.ts +13 -0
- package/dist/src/define-plugin.js +4 -43
- package/dist/src/embedded-plugins.d.ts +59 -0
- package/dist/src/embedded-plugins.js +22 -0
- package/dist/src/exec.d.ts +13 -0
- package/dist/src/exec.js +101 -0
- package/dist/src/harness-paths.d.ts +9 -0
- package/dist/src/harness-paths.js +126 -0
- package/dist/src/hook-materializer.d.ts +21 -0
- package/dist/src/hook-materializer.js +152 -0
- package/dist/src/hook-protocol.d.ts +2 -0
- package/dist/src/hook-protocol.js +432 -0
- package/dist/src/hook-runner.d.ts +48 -0
- package/dist/src/hook-runner.js +868 -0
- package/dist/src/hook-runtime.d.ts +52 -0
- package/dist/src/hook-runtime.js +432 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/src/index.js +210 -2499
- package/dist/src/json-files.d.ts +9 -0
- package/dist/src/json-files.js +124 -0
- package/dist/src/kernel-boot.d.ts +2 -0
- package/dist/src/kernel-boot.js +10 -0
- package/dist/src/kernel-entrypoint.d.ts +22 -0
- package/dist/src/kernel-entrypoint.js +660 -0
- package/dist/src/kernel-plugin-abi.d.ts +1 -0
- package/dist/src/kernel-plugin-abi.js +1 -0
- package/dist/src/kernel-resolver.d.ts +2 -0
- package/dist/src/kernel-resolver.js +6 -0
- package/dist/src/layout.d.ts +10 -0
- package/dist/src/layout.js +138 -0
- package/dist/src/load-config.d.ts +2 -0
- package/dist/src/load-config.js +535 -30
- package/dist/src/placement.d.ts +58 -0
- package/dist/src/placement.js +53 -0
- package/dist/src/plugin-host-context.d.ts +65 -0
- package/dist/src/plugin-host-context.js +1171 -0
- package/dist/src/plugin-host-registries.d.ts +31 -0
- package/dist/src/plugin-host-registries.js +79 -0
- package/dist/src/plugin-host.d.ts +77 -0
- package/dist/src/plugin-host.js +127 -63
- package/dist/src/plugin-runtime.d.ts +173 -0
- package/dist/src/project-plugins.d.ts +63 -0
- package/dist/src/project-plugins.js +905 -0
- package/dist/src/remote-config.d.ts +125 -0
- package/dist/src/remote-config.js +85 -0
- package/dist/src/root-resolver.d.ts +5 -0
- package/dist/src/root-resolver.js +68 -0
- package/dist/src/run-provisioning.d.ts +37 -0
- package/dist/src/run-provisioning.js +35 -0
- package/dist/src/runtime-context.d.ts +20 -0
- package/dist/src/runtime-context.js +257 -0
- package/dist/src/runtime-events.d.ts +44 -0
- package/dist/src/runtime-events.js +208 -0
- package/dist/src/runtime-overlay.d.ts +11 -0
- package/dist/src/runtime-overlay.js +69 -0
- package/dist/src/runtime-paths.d.ts +21 -0
- package/dist/src/runtime-paths.js +181 -0
- package/dist/src/runtime-provisioning-env.d.ts +5 -0
- package/dist/src/runtime-provisioning-env.js +217 -0
- package/dist/src/runtime-runner-context.d.ts +12 -0
- package/dist/src/runtime-runner-context.js +1 -0
- package/dist/src/safe-identifiers.d.ts +44 -0
- package/dist/src/safe-identifiers.js +96 -0
- package/dist/src/scope-rules.d.ts +4 -0
- package/dist/src/scope-rules.js +21 -0
- package/dist/src/server-paths.d.ts +22 -0
- package/dist/src/server-paths.js +219 -0
- package/dist/src/setup-version.d.ts +3 -0
- package/dist/src/setup-version.js +14 -0
- package/dist/src/task-record-reader.d.ts +3 -0
- package/dist/src/task-record-reader.js +9 -0
- package/dist/src/validator-registry.d.ts +27 -0
- package/dist/src/validator-registry.js +64 -0
- package/package.json +162 -10
- package/dist/src/engineReadModelReducer.js +0 -1780
- package/dist/src/rig-init-builder.js +0 -57
- package/dist/src/rigSelectors.js +0 -293
- package/dist/src/taskGraph.js +0 -64
- package/dist/src/taskGraphCodes.js +0 -26
- package/dist/src/taskGraphLayout.js +0 -374
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/core/src/layout.ts
|
|
3
|
+
import { existsSync as existsSync2 } from "fs";
|
|
4
|
+
import { resolve as resolve2 } from "path";
|
|
5
|
+
import {
|
|
6
|
+
RIG_DEFINITION_DIRNAME,
|
|
7
|
+
RIG_STATE_DIRNAME
|
|
8
|
+
} from "@rig/contracts";
|
|
9
|
+
|
|
10
|
+
// packages/core/src/checkout-root.ts
|
|
11
|
+
import { dirname, resolve } from "path";
|
|
12
|
+
import { existsSync } from "fs";
|
|
13
|
+
function findNearestGitCheckoutRoot(startDir) {
|
|
14
|
+
let current = resolve(startDir);
|
|
15
|
+
for (;; ) {
|
|
16
|
+
if (existsSync(resolve(current, ".git")))
|
|
17
|
+
return current;
|
|
18
|
+
const parent = dirname(current);
|
|
19
|
+
if (parent === current)
|
|
20
|
+
return null;
|
|
21
|
+
current = parent;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function resolveCheckoutRoot(projectRoot) {
|
|
25
|
+
const normalizedProjectRoot = resolve(projectRoot);
|
|
26
|
+
const explicit = process.env.MONOREPO_ROOT?.trim();
|
|
27
|
+
if (explicit) {
|
|
28
|
+
const explicitRoot = resolve(explicit);
|
|
29
|
+
const gitRoot = findNearestGitCheckoutRoot(explicitRoot);
|
|
30
|
+
if (gitRoot)
|
|
31
|
+
return gitRoot;
|
|
32
|
+
throw new Error(`MONOREPO_ROOT points to ${explicitRoot}, but no git checkout was found there or above it.`);
|
|
33
|
+
}
|
|
34
|
+
return findNearestGitCheckoutRoot(normalizedProjectRoot) ?? normalizedProjectRoot;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// packages/core/src/layout.ts
|
|
38
|
+
var resolveMonorepoRoot = resolveCheckoutRoot;
|
|
39
|
+
function resolveNearestRigProjectRoot(startDir) {
|
|
40
|
+
let current = resolve2(startDir);
|
|
41
|
+
let weakMarkerCandidate = null;
|
|
42
|
+
let projectCandidate = null;
|
|
43
|
+
for (;; ) {
|
|
44
|
+
const hasDefinition = existsSync2(resolve2(current, RIG_DEFINITION_DIRNAME));
|
|
45
|
+
const hasState = existsSync2(resolve2(current, RIG_STATE_DIRNAME));
|
|
46
|
+
const hasConfig = existsSync2(resolve2(current, ".rig", "rig.config.ts")) || existsSync2(resolve2(current, ".rig", "rig.config.json"));
|
|
47
|
+
const hasGit = existsSync2(resolve2(current, ".git"));
|
|
48
|
+
const hasControlPlane = existsSync2(resolve2(current, "packages", "cli", "bin", "rig.ts")) || existsSync2(resolve2(current, "packages", "server"));
|
|
49
|
+
if ((hasDefinition || hasState || hasConfig) && weakMarkerCandidate === null) {
|
|
50
|
+
weakMarkerCandidate = current;
|
|
51
|
+
}
|
|
52
|
+
if ((hasControlPlane || hasConfig) && projectCandidate === null) {
|
|
53
|
+
projectCandidate = current;
|
|
54
|
+
}
|
|
55
|
+
if (hasGit) {
|
|
56
|
+
return projectCandidate ?? current;
|
|
57
|
+
}
|
|
58
|
+
const parent = resolve2(current, "..");
|
|
59
|
+
if (parent === current) {
|
|
60
|
+
return projectCandidate ?? weakMarkerCandidate ?? resolve2(startDir);
|
|
61
|
+
}
|
|
62
|
+
current = parent;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function resolveRigDataRoot(projectRoot) {
|
|
66
|
+
return resolveMonorepoRoot(projectRoot);
|
|
67
|
+
}
|
|
68
|
+
function resolveRuntimeWorkspaceLayout(workspaceDir) {
|
|
69
|
+
const root = resolve2(workspaceDir);
|
|
70
|
+
const rigRoot = resolve2(root, ".rig");
|
|
71
|
+
const logsDir = resolve2(rigRoot, "logs");
|
|
72
|
+
const stateDir = resolve2(rigRoot, "state");
|
|
73
|
+
const runtimeDir = resolve2(rigRoot, "runtime");
|
|
74
|
+
const binDir = resolve2(rigRoot, "bin");
|
|
75
|
+
return {
|
|
76
|
+
workspaceDir: root,
|
|
77
|
+
rigRoot,
|
|
78
|
+
stateDir,
|
|
79
|
+
logsDir,
|
|
80
|
+
runtimeDir,
|
|
81
|
+
homeDir: resolve2(rigRoot, "home"),
|
|
82
|
+
tmpDir: resolve2(rigRoot, "tmp"),
|
|
83
|
+
cacheDir: resolve2(rigRoot, "cache"),
|
|
84
|
+
sessionDir: resolve2(rigRoot, "session"),
|
|
85
|
+
binDir,
|
|
86
|
+
distDir: resolve2(rigRoot, "dist"),
|
|
87
|
+
pluginBinDir: resolve2(binDir, "plugins"),
|
|
88
|
+
contextPath: resolve2(rigRoot, "runtime-context.json"),
|
|
89
|
+
controlPlaneEventsFile: resolve2(logsDir, "control-plane.events.jsonl")
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function resolveActiveRuntimeWorkspaceRoot(_monorepoRoot) {
|
|
93
|
+
const explicit = process.env.RIG_TASK_WORKSPACE?.trim();
|
|
94
|
+
if (!explicit) {
|
|
95
|
+
throw new Error("No active runtime workspace. Set RIG_TASK_WORKSPACE or provision a task runtime first.");
|
|
96
|
+
}
|
|
97
|
+
return resolve2(explicit);
|
|
98
|
+
}
|
|
99
|
+
function resolveRigLayout(projectRoot) {
|
|
100
|
+
const monorepoRoot = resolveMonorepoRoot(projectRoot);
|
|
101
|
+
const definitionRoot = resolve2(projectRoot, RIG_DEFINITION_DIRNAME);
|
|
102
|
+
const runtimeWorkspaceRoot = resolveActiveRuntimeWorkspaceRoot(monorepoRoot);
|
|
103
|
+
const runtimeLayout = resolveRuntimeWorkspaceLayout(runtimeWorkspaceRoot);
|
|
104
|
+
const policyDir = resolve2(definitionRoot, "policy");
|
|
105
|
+
return {
|
|
106
|
+
projectRoot,
|
|
107
|
+
monorepoRoot,
|
|
108
|
+
definitionRoot,
|
|
109
|
+
runtimeWorkspaceRoot,
|
|
110
|
+
stateRoot: runtimeLayout.rigRoot,
|
|
111
|
+
configPath: resolve2(definitionRoot, "config.sh"),
|
|
112
|
+
policyDir,
|
|
113
|
+
policyFile: resolve2(policyDir, "policy.json"),
|
|
114
|
+
pluginsDir: resolve2(definitionRoot, "plugins"),
|
|
115
|
+
hooksDir: resolve2(definitionRoot, "hooks"),
|
|
116
|
+
toolsDir: resolve2(definitionRoot, "tools"),
|
|
117
|
+
templatesDir: resolve2(definitionRoot, "templates"),
|
|
118
|
+
validationDir: resolve2(definitionRoot, "validation"),
|
|
119
|
+
stateDir: runtimeLayout.stateDir,
|
|
120
|
+
logsDir: runtimeLayout.logsDir,
|
|
121
|
+
notificationsDir: resolve2(definitionRoot, "notifications"),
|
|
122
|
+
runtimeDir: runtimeLayout.runtimeDir,
|
|
123
|
+
distDir: runtimeLayout.distDir,
|
|
124
|
+
binDir: runtimeLayout.binDir,
|
|
125
|
+
pluginBinDir: runtimeLayout.pluginBinDir,
|
|
126
|
+
keybindingsPath: resolve2(definitionRoot, "keybindings.json"),
|
|
127
|
+
controlPlaneEventsFile: runtimeLayout.controlPlaneEventsFile
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
resolveRuntimeWorkspaceLayout,
|
|
132
|
+
resolveRigLayout,
|
|
133
|
+
resolveRigDataRoot,
|
|
134
|
+
resolveNearestRigProjectRoot,
|
|
135
|
+
resolveMonorepoRoot,
|
|
136
|
+
RIG_STATE_DIRNAME,
|
|
137
|
+
RIG_DEFINITION_DIRNAME
|
|
138
|
+
};
|