@flowdular/sdk 0.1.0 → 0.2.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.
- package/.ai/skills/test-hardening/SKILL.md +1 -1
- package/README.md +69 -12
- package/assets/flowdular-banner.png +0 -0
- package/modules/agents/package.json +1 -1
- package/modules/auth/package.json +1 -1
- package/modules/auth/src/client/AuthenticationCore.tsrx +3 -1
- package/modules/auth/src/server/endpoints.ts +3 -1
- package/modules/auth/src/server/runtime.ts +4 -0
- package/modules/automations/package.json +1 -1
- package/modules/automations-workflows-integration/package.json +1 -1
- package/modules/profile/package.json +1 -1
- package/modules/sandbox/package.json +1 -1
- package/modules/system/package.json +1 -1
- package/modules/users/package.json +1 -1
- package/modules/workflows/package.json +1 -1
- package/package.json +5 -13
- package/packages/ai-provider/package.json +1 -1
- package/packages/cli-protocol/package.json +1 -1
- package/packages/client/package.json +1 -1
- package/packages/client/src/routing.ts +39 -2
- package/packages/client/src/shell/BrandMark.tsrx +5 -1
- package/packages/client/src/shell/navigation.ts +3 -1
- package/packages/client/src/state.ts +6 -2
- package/packages/contracts/package.json +1 -1
- package/packages/contracts/schemas/project.schema.json +16 -42
- package/packages/database/package.json +1 -1
- package/packages/database-pglite/package.json +1 -1
- package/packages/database-testing/package.json +1 -1
- package/packages/dev-console/package.json +1 -1
- package/packages/harness/package.json +1 -1
- package/packages/kernel/package.json +1 -1
- package/packages/server/package.json +1 -1
- package/packages/server/src/application-routes.ts +80 -8
- package/packages/server/src/index.ts +4 -1
- package/packages/server/src/web-html.ts +9 -5
- package/packages/server/src/web.ts +59 -7
- package/packages/ui/package.json +1 -1
- package/packages/coding-agent/package.json +0 -44
- package/packages/coding-agent/src/drivers/byok.ts +0 -322
- package/packages/coding-agent/src/drivers/claude-code.ts +0 -290
- package/packages/coding-agent/src/drivers/codex.ts +0 -281
- package/packages/coding-agent/src/index.ts +0 -56
- package/packages/coding-agent/src/registry.ts +0 -119
- package/packages/coding-agent/src/roles/contract.ts +0 -60
- package/packages/coding-agent/src/roles/defaults.ts +0 -134
- package/packages/coding-agent/src/roles/handoff.ts +0 -41
- package/packages/coding-agent/src/roles/registry.ts +0 -156
- package/packages/coding-agent/src/roles/skills.ts +0 -72
- package/packages/coding-agent/src/roles/sync.ts +0 -88
- package/packages/coding-agent/src/types.ts +0 -102
- package/packages/coding-agent/src/workspace.ts +0 -275
- package/packages/sandbox/README.md +0 -691
- package/packages/sandbox/bin/flowdular-sandbox.mjs +0 -393
- package/packages/sandbox/dist/client/assets/App-ClMOrpyg.js +0 -11
- package/packages/sandbox/dist/client/assets/PreviewHost-BHiHrfbQ.js +0 -1
- package/packages/sandbox/dist/client/assets/auto-buGEq6de.js +0 -3
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-ext-wght-normal-d45eAU9y.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-cyrillic-wght-normal-BAAhND-U.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-greek-wght-normal-CmyJS8uq.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-ext-wght-normal-CIII54If.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-latin-wght-normal-IvpUvPa2.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/ibm-plex-sans-vietnamese-wght-normal-Dg1JeJN0.woff2 +0 -0
- package/packages/sandbox/dist/client/assets/index-CvwhlQ87.js +0 -4
- package/packages/sandbox/dist/client/assets/styles-BPWaGf55.js +0 -3
- package/packages/sandbox/dist/client/assets/styles-Dx1_KOag.css +0 -1
- package/packages/sandbox/dist/client/favicon.svg +0 -1
- package/packages/sandbox/dist/server/assets/auto-CVGNYyb3.js +0 -12785
- package/packages/sandbox/dist/server/assets/chunk-DDJLRBDX-3OUNo51g.js +0 -4125
- package/packages/sandbox/dist/server/assets/nodefs-DVSI7kG0.js +0 -24
- package/packages/sandbox/dist/server/assets/opfs-ahp-D56iokt1.js +0 -388
- package/packages/sandbox/dist/server/assets/token-Bvaq7Anz.js +0 -55
- package/packages/sandbox/dist/server/assets/token-util-BqSvdIPQ.js +0 -3
- package/packages/sandbox/dist/server/assets/token-util-CktFFT4z.js +0 -494
- package/packages/sandbox/dist/server/entry.js +0 -91671
- package/packages/sandbox/dist/server/favicon.svg +0 -1
- package/packages/sandbox/dist/server/index.html +0 -161
- package/packages/sandbox/index.html +0 -159
- package/packages/sandbox/octane.config.ts +0 -36
- package/packages/sandbox/package.json +0 -83
- package/packages/sandbox/public/favicon.svg +0 -1
- package/packages/sandbox/public/og.png +0 -0
- package/packages/sandbox/src/App.tsrx +0 -924
- package/packages/sandbox/src/client/ApprovalHandoff.tsrx +0 -39
- package/packages/sandbox/src/client/ChatPane.tsrx +0 -694
- package/packages/sandbox/src/client/ConnectView.tsrx +0 -86
- package/packages/sandbox/src/client/DiffPane.tsrx +0 -150
- package/packages/sandbox/src/client/EjectModal.tsrx +0 -571
- package/packages/sandbox/src/client/GateResults.tsrx +0 -60
- package/packages/sandbox/src/client/GitHubSettingsModal.tsrx +0 -219
- package/packages/sandbox/src/client/NewSessionForm.tsrx +0 -214
- package/packages/sandbox/src/client/SessionBar.tsrx +0 -151
- package/packages/sandbox/src/client/SessionPicker.tsrx +0 -472
- package/packages/sandbox/src/client/SpecEditor.tsrx +0 -109
- package/packages/sandbox/src/client/SpecReviewCard.tsrx +0 -321
- package/packages/sandbox/src/client/WorkCard.tsrx +0 -128
- package/packages/sandbox/src/client/WorkbenchModal.tsrx +0 -161
- package/packages/sandbox/src/client/WorkspaceMenu.tsrx +0 -100
- package/packages/sandbox/src/client/api.ts +0 -797
- package/packages/sandbox/src/client/attachments.ts +0 -73
- package/packages/sandbox/src/client/dashboard.ts +0 -46
- package/packages/sandbox/src/client/github-settings.ts +0 -48
- package/packages/sandbox/src/client/highlight.ts +0 -105
- package/packages/sandbox/src/client/i18n.ts +0 -32
- package/packages/sandbox/src/client/locales/en.json +0 -466
- package/packages/sandbox/src/client/locales/pl.json +0 -466
- package/packages/sandbox/src/client/session-labels.ts +0 -77
- package/packages/sandbox/src/client/state.ts +0 -108
- package/packages/sandbox/src/index.ts +0 -10
- package/packages/sandbox/src/preview/PreviewHost.tsrx +0 -373
- package/packages/sandbox/src/preview/load-module.ts +0 -16
- package/packages/sandbox/src/server/attachments.ts +0 -308
- package/packages/sandbox/src/server/auto-review.ts +0 -181
- package/packages/sandbox/src/server/checkpoints.ts +0 -90
- package/packages/sandbox/src/server/config.ts +0 -460
- package/packages/sandbox/src/server/dashboard.ts +0 -245
- package/packages/sandbox/src/server/delivery/configuration.ts +0 -193
- package/packages/sandbox/src/server/delivery/git-pr.ts +0 -1473
- package/packages/sandbox/src/server/delivery/index.ts +0 -83
- package/packages/sandbox/src/server/delivery/local.ts +0 -151
- package/packages/sandbox/src/server/delivery/official-modules.ts +0 -516
- package/packages/sandbox/src/server/delivery/plan.ts +0 -218
- package/packages/sandbox/src/server/delivery/policies.ts +0 -239
- package/packages/sandbox/src/server/delivery/record.ts +0 -41
- package/packages/sandbox/src/server/delivery/steps.ts +0 -464
- package/packages/sandbox/src/server/delivery/types.ts +0 -158
- package/packages/sandbox/src/server/dependencies.ts +0 -88
- package/packages/sandbox/src/server/diff.ts +0 -230
- package/packages/sandbox/src/server/gates.ts +0 -388
- package/packages/sandbox/src/server/index.ts +0 -139
- package/packages/sandbox/src/server/path-guard.ts +0 -282
- package/packages/sandbox/src/server/planning.ts +0 -749
- package/packages/sandbox/src/server/platform-client.ts +0 -189
- package/packages/sandbox/src/server/preview-database-host.ts +0 -340
- package/packages/sandbox/src/server/preview-database-protocol.ts +0 -163
- package/packages/sandbox/src/server/preview-database-proxy.ts +0 -356
- package/packages/sandbox/src/server/preview-database.ts +0 -109
- package/packages/sandbox/src/server/preview-ipc.ts +0 -15
- package/packages/sandbox/src/server/preview-modules.ts +0 -83
- package/packages/sandbox/src/server/preview-revision.ts +0 -44
- package/packages/sandbox/src/server/preview-runtime.ts +0 -467
- package/packages/sandbox/src/server/preview-worker-manager.ts +0 -436
- package/packages/sandbox/src/server/preview-worker.ts +0 -168
- package/packages/sandbox/src/server/reference.ts +0 -251
- package/packages/sandbox/src/server/routes.ts +0 -2258
- package/packages/sandbox/src/server/runtime.ts +0 -188
- package/packages/sandbox/src/server/session-owner.ts +0 -23
- package/packages/sandbox/src/server/sessions.ts +0 -849
- package/packages/sandbox/src/server/spec.ts +0 -471
- package/packages/sandbox/src/server/turn-lifecycle.ts +0 -56
- package/packages/sandbox/src/server/turns.ts +0 -993
- package/packages/sandbox/src/server/workspace-install.ts +0 -266
- package/packages/sandbox/src/server/workspace-root.ts +0 -73
- package/packages/sandbox/src/styles.css +0 -1573
- package/packages/sandbox/vite.config.ts +0 -133
|
@@ -1,516 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
3
|
-
mkdtemp,
|
|
4
|
-
stat,
|
|
5
|
-
readFile,
|
|
6
|
-
readdir,
|
|
7
|
-
rm,
|
|
8
|
-
writeFile,
|
|
9
|
-
} from 'node:fs/promises';
|
|
10
|
-
import { tmpdir } from 'node:os';
|
|
11
|
-
import { join } from 'node:path';
|
|
12
|
-
import { inspectAutoReview, moduleReviewRevision } from '../auto-review.ts';
|
|
13
|
-
import { modulePathOf, sessionPaths } from '../sessions.ts';
|
|
14
|
-
import { gitDeliveryRunner } from './git-pr.ts';
|
|
15
|
-
import {
|
|
16
|
-
GATES,
|
|
17
|
-
assertEjectCapability,
|
|
18
|
-
countDeliveredFiles,
|
|
19
|
-
planSessionModules,
|
|
20
|
-
} from './plan.ts';
|
|
21
|
-
import {
|
|
22
|
-
DeliveryError,
|
|
23
|
-
createStepRecorder,
|
|
24
|
-
exists,
|
|
25
|
-
runDeliveryGates,
|
|
26
|
-
stageModules,
|
|
27
|
-
} from './steps.ts';
|
|
28
|
-
import type { DeliveryContext, DeliveryTarget } from './types.ts';
|
|
29
|
-
|
|
30
|
-
export const OFFICIAL_MODULES_REPOSITORY = 'Flowdular/official-modules';
|
|
31
|
-
const REPOSITORY = OFFICIAL_MODULES_REPOSITORY;
|
|
32
|
-
const active = new Set<string>();
|
|
33
|
-
const ROOT_FILES = new Set([
|
|
34
|
-
'module.json',
|
|
35
|
-
'package.json',
|
|
36
|
-
'README.md',
|
|
37
|
-
'CHANGELOG.md',
|
|
38
|
-
'LICENSE',
|
|
39
|
-
'tsconfig.json',
|
|
40
|
-
'vitest.config.ts',
|
|
41
|
-
]);
|
|
42
|
-
const ROOTS = new Set(['src', 'tests', 'migrations', 'translations', 'spec']);
|
|
43
|
-
|
|
44
|
-
function fail(message: string): never {
|
|
45
|
-
throw new DeliveryError('OFFICIAL_MODULES_BLOCKED', message);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/* Reject extra files rather than silently publishing a subset of what was reviewed. */
|
|
49
|
-
export function assertOfficialSourcePaths(files: readonly string[]): void {
|
|
50
|
-
if (files.length > 4096) fail('The contribution exceeds 4096 source files.');
|
|
51
|
-
for (const file of files) {
|
|
52
|
-
const parts = file.split('/');
|
|
53
|
-
if (
|
|
54
|
-
file.length >= 240 ||
|
|
55
|
-
!/^[a-zA-Z0-9_./@+ -]+$/.test(file) ||
|
|
56
|
-
parts.some(
|
|
57
|
-
(part) =>
|
|
58
|
-
!part ||
|
|
59
|
-
part.startsWith('.') ||
|
|
60
|
-
part === 'node_modules' ||
|
|
61
|
-
part === 'dist',
|
|
62
|
-
) ||
|
|
63
|
-
!(parts.length === 1 ? ROOT_FILES.has(file) : ROOTS.has(parts[0]!))
|
|
64
|
-
) {
|
|
65
|
-
fail(
|
|
66
|
-
`Unsupported registry source path: ${file}. Remove private or generated files before review.`,
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function reviewedPlan(context: DeliveryContext) {
|
|
73
|
-
assertEjectCapability(context);
|
|
74
|
-
if (
|
|
75
|
-
context.session.modules.length !== 1 ||
|
|
76
|
-
context.session.modules[0]!.kind !== 'new'
|
|
77
|
-
)
|
|
78
|
-
fail(
|
|
79
|
-
'Submit one new module at a time. Existing registry modules need a contributor branch and compatibility review.',
|
|
80
|
-
);
|
|
81
|
-
const modules = (await planSessionModules(context)).map((module) => ({
|
|
82
|
-
...module,
|
|
83
|
-
enable: false,
|
|
84
|
-
}));
|
|
85
|
-
const paths = sessionPaths(
|
|
86
|
-
context.workspaceRoot,
|
|
87
|
-
context.session.id,
|
|
88
|
-
context.session.moduleSuffix,
|
|
89
|
-
);
|
|
90
|
-
for (const module of modules) {
|
|
91
|
-
assertOfficialSourcePaths(module.files);
|
|
92
|
-
if (
|
|
93
|
-
!/^[a-z][a-z0-9-]*$/.test(module.directory) ||
|
|
94
|
-
!/^[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)+$/.test(module.id)
|
|
95
|
-
)
|
|
96
|
-
fail('Invalid module identity.');
|
|
97
|
-
let bytes = 0;
|
|
98
|
-
for (const file of module.files) {
|
|
99
|
-
bytes += (await stat(join(modulePathOf(paths, module.directory), file)))
|
|
100
|
-
.size;
|
|
101
|
-
if (bytes > 32 * 1024 * 1024) fail('The contribution exceeds 32 MiB.');
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const review = await inspectAutoReview(paths, module);
|
|
105
|
-
if (!review.passed) fail(review.output);
|
|
106
|
-
}
|
|
107
|
-
return modules;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* This script runs only after the cloned registry's actual verification passes.
|
|
111
|
-
It uses its pinned distribution API, so hashing and packaging share a contract. */
|
|
112
|
-
const REVIEW_SCRIPT = `
|
|
113
|
-
import { mkdir, writeFile } from 'node:fs/promises';
|
|
114
|
-
import { readModuleSource, sourceDigest } from 'flowdular/distribution';
|
|
115
|
-
const [directory, id, revision] = process.argv.slice(1);
|
|
116
|
-
const sourceSha256 = sourceDigest(await readModuleSource(directory));
|
|
117
|
-
await mkdir('reviews', {recursive:true});
|
|
118
|
-
await writeFile('reviews/' + id + '.json', JSON.stringify({
|
|
119
|
-
sourceSha256,
|
|
120
|
-
requirements: ['Implement the human-approved specification in ' + directory + '/spec/module.yaml',
|
|
121
|
-
'Pass all sandbox gates and exact-source auto-review ' + revision,
|
|
122
|
-
'Pass the official repository verification against the pinned SDK'],
|
|
123
|
-
findings: [],
|
|
124
|
-
checks: ['typecheck','test','validate'].map(name => ({name,command:'pnpm ' + name,exitCode:0}))
|
|
125
|
-
}, null, '\\t') + '\\n');
|
|
126
|
-
`;
|
|
127
|
-
|
|
128
|
-
export function createOfficialModulesDeliveryTarget(): DeliveryTarget {
|
|
129
|
-
return {
|
|
130
|
-
id: 'official-modules',
|
|
131
|
-
available: async (context) => {
|
|
132
|
-
try {
|
|
133
|
-
await reviewedPlan(context);
|
|
134
|
-
const run = await gitDeliveryRunner(context);
|
|
135
|
-
const result = await run(
|
|
136
|
-
'gh',
|
|
137
|
-
['api', `repos/${REPOSITORY}`, '--jq', '.full_name'],
|
|
138
|
-
context.workspaceRoot,
|
|
139
|
-
);
|
|
140
|
-
if (
|
|
141
|
-
result.code !== 0 ||
|
|
142
|
-
result.output.trim().toLowerCase() !== REPOSITORY.toLowerCase()
|
|
143
|
-
)
|
|
144
|
-
return {
|
|
145
|
-
available: false,
|
|
146
|
-
reason:
|
|
147
|
-
'GitHub authentication and access to Flowdular/official-modules are required.',
|
|
148
|
-
};
|
|
149
|
-
return { available: true, reason: null };
|
|
150
|
-
} catch (error) {
|
|
151
|
-
return {
|
|
152
|
-
available: false,
|
|
153
|
-
reason:
|
|
154
|
-
error instanceof Error
|
|
155
|
-
? error.message
|
|
156
|
-
: 'A reviewed new module is required.',
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
plan: async (context) => {
|
|
161
|
-
const modules = await reviewedPlan(context);
|
|
162
|
-
const primary = modules[0]!;
|
|
163
|
-
return {
|
|
164
|
-
target: 'official-modules',
|
|
165
|
-
deliveredBy: 'official-modules',
|
|
166
|
-
moduleId: primary.id,
|
|
167
|
-
targetPath: primary.targetPath,
|
|
168
|
-
files: primary.files,
|
|
169
|
-
overwrites: [],
|
|
170
|
-
removes: [],
|
|
171
|
-
newPackages: primary.newPackages,
|
|
172
|
-
enable: false,
|
|
173
|
-
modules,
|
|
174
|
-
changedFiles: countDeliveredFiles(modules),
|
|
175
|
-
gates: [...GATES],
|
|
176
|
-
platformLocal: false,
|
|
177
|
-
restartRequired: false,
|
|
178
|
-
notes: [
|
|
179
|
-
`Open a PR to ${REPOSITORY}/main after sandbox review and registry verification. The module sources, tests and approved specification will be shared with that repository. Maintainers publish the registry after acceptance.`,
|
|
180
|
-
],
|
|
181
|
-
applied: false,
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
apply: async (context, plan, emit) => {
|
|
185
|
-
if (plan.target !== 'official-modules')
|
|
186
|
-
fail('The plan targets another repository.');
|
|
187
|
-
const key = `${context.workspaceRoot}:${context.session.id}`;
|
|
188
|
-
if (active.has(key)) fail('This contribution is already running.');
|
|
189
|
-
active.add(key);
|
|
190
|
-
let scratch: string | undefined;
|
|
191
|
-
try {
|
|
192
|
-
const modules = await reviewedPlan(context);
|
|
193
|
-
const module = modules[0]!;
|
|
194
|
-
const paths = sessionPaths(
|
|
195
|
-
context.workspaceRoot,
|
|
196
|
-
context.session.id,
|
|
197
|
-
context.session.moduleSuffix,
|
|
198
|
-
);
|
|
199
|
-
const source = modulePathOf(paths, module.directory);
|
|
200
|
-
const revision = await moduleReviewRevision(source);
|
|
201
|
-
const gates = await runDeliveryGates(context, GATES, emit);
|
|
202
|
-
const run = await gitDeliveryRunner(context);
|
|
203
|
-
const recorder = createStepRecorder(emit);
|
|
204
|
-
const command = async (
|
|
205
|
-
id: string,
|
|
206
|
-
executable: string,
|
|
207
|
-
args: string[],
|
|
208
|
-
cwd: string,
|
|
209
|
-
) => {
|
|
210
|
-
emit(`${id}.started`, {});
|
|
211
|
-
const result = await run(executable, args, cwd);
|
|
212
|
-
recorder.record(id, { ok: result.code === 0, output: result.output });
|
|
213
|
-
return result.output.trim();
|
|
214
|
-
};
|
|
215
|
-
scratch = await mkdtemp(join(tmpdir(), 'flowdular-official-'));
|
|
216
|
-
const checkout = join(scratch, 'registry');
|
|
217
|
-
await command(
|
|
218
|
-
'worktree',
|
|
219
|
-
'git',
|
|
220
|
-
[
|
|
221
|
-
'clone',
|
|
222
|
-
'--quiet',
|
|
223
|
-
'--depth',
|
|
224
|
-
'1',
|
|
225
|
-
'--branch',
|
|
226
|
-
'main',
|
|
227
|
-
`https://github.com/${REPOSITORY}.git`,
|
|
228
|
-
checkout,
|
|
229
|
-
],
|
|
230
|
-
scratch,
|
|
231
|
-
);
|
|
232
|
-
if (await exists(join(checkout, module.targetPath)))
|
|
233
|
-
fail(
|
|
234
|
-
'That module directory already exists in Official Modules. Use a contributor branch for updates.',
|
|
235
|
-
);
|
|
236
|
-
for (const entry of await readdir(join(checkout, 'modules'), {
|
|
237
|
-
withFileTypes: true,
|
|
238
|
-
})) {
|
|
239
|
-
if (!entry.isDirectory()) continue;
|
|
240
|
-
const manifest = JSON.parse(
|
|
241
|
-
await readFile(
|
|
242
|
-
join(checkout, 'modules', entry.name, 'module.json'),
|
|
243
|
-
'utf8',
|
|
244
|
-
),
|
|
245
|
-
);
|
|
246
|
-
if (manifest.id === module.id)
|
|
247
|
-
fail('That module ID already exists in Official Modules.');
|
|
248
|
-
}
|
|
249
|
-
const { copied } = await stageModules(paths, checkout, modules, emit);
|
|
250
|
-
const staged = join(checkout, module.targetPath);
|
|
251
|
-
if ((await moduleReviewRevision(staged)) !== revision)
|
|
252
|
-
fail('Source changed during staging. Repeat review.');
|
|
253
|
-
await command(
|
|
254
|
-
'install',
|
|
255
|
-
'pnpm',
|
|
256
|
-
['install', '--no-frozen-lockfile'],
|
|
257
|
-
checkout,
|
|
258
|
-
);
|
|
259
|
-
await command('verify', 'pnpm', ['verify'], checkout);
|
|
260
|
-
if (
|
|
261
|
-
(await moduleReviewRevision(staged)) !== revision ||
|
|
262
|
-
(await moduleReviewRevision(source)) !== revision
|
|
263
|
-
)
|
|
264
|
-
fail('Verification changed reviewed source. Repeat review.');
|
|
265
|
-
await command(
|
|
266
|
-
'review',
|
|
267
|
-
'node',
|
|
268
|
-
[
|
|
269
|
-
'--input-type=module',
|
|
270
|
-
'-e',
|
|
271
|
-
REVIEW_SCRIPT,
|
|
272
|
-
module.targetPath,
|
|
273
|
-
module.id,
|
|
274
|
-
revision,
|
|
275
|
-
],
|
|
276
|
-
checkout,
|
|
277
|
-
);
|
|
278
|
-
await command('pack', 'pnpm', ['release:pack', '--local'], checkout);
|
|
279
|
-
if ((await moduleReviewRevision(staged)) !== revision)
|
|
280
|
-
fail('Packaging changed reviewed source. Repeat review.');
|
|
281
|
-
const manifest = JSON.parse(
|
|
282
|
-
await readFile(join(staged, 'module.json'), 'utf8'),
|
|
283
|
-
);
|
|
284
|
-
if (
|
|
285
|
-
!/^[0-9]+\.[0-9]+\.[0-9]+(?:-[a-zA-Z0-9.-]+)?$/.test(manifest.version)
|
|
286
|
-
)
|
|
287
|
-
fail('Invalid release version.');
|
|
288
|
-
if (manifest.id !== module.id)
|
|
289
|
-
fail('Module identity differs from the reviewed session.');
|
|
290
|
-
const allowed = [
|
|
291
|
-
module.targetPath,
|
|
292
|
-
`reviews/${module.id}.json`,
|
|
293
|
-
`registry/releases/${module.id}/${manifest.version}.json`,
|
|
294
|
-
];
|
|
295
|
-
// Installation may update only the disposable lockfile. Never include it.
|
|
296
|
-
await command('commit', 'git', ['add', '--', ...allowed], checkout);
|
|
297
|
-
const offending = await command(
|
|
298
|
-
'guardrails',
|
|
299
|
-
'git',
|
|
300
|
-
[
|
|
301
|
-
'diff',
|
|
302
|
-
'--cached',
|
|
303
|
-
'--name-only',
|
|
304
|
-
'--',
|
|
305
|
-
'.',
|
|
306
|
-
...allowed.map((path) => `:(exclude)${path}`),
|
|
307
|
-
],
|
|
308
|
-
checkout,
|
|
309
|
-
);
|
|
310
|
-
if (offending) fail('Unexpected staged files.');
|
|
311
|
-
|
|
312
|
-
const unrelated = await command(
|
|
313
|
-
'guardrails',
|
|
314
|
-
'git',
|
|
315
|
-
['diff', '--name-only', '--', '.', ':(exclude)pnpm-lock.yaml'],
|
|
316
|
-
checkout,
|
|
317
|
-
);
|
|
318
|
-
if (unrelated)
|
|
319
|
-
fail('Verification changed files outside the contribution.');
|
|
320
|
-
const suffix = createHash('sha256')
|
|
321
|
-
.update(key + revision)
|
|
322
|
-
.digest('hex')
|
|
323
|
-
.slice(0, 24);
|
|
324
|
-
const branch = `official-module/${suffix}`;
|
|
325
|
-
const login = await command(
|
|
326
|
-
'provider',
|
|
327
|
-
'gh',
|
|
328
|
-
['api', 'user', '--jq', '.login'],
|
|
329
|
-
checkout,
|
|
330
|
-
);
|
|
331
|
-
if (!/^[A-Za-z0-9][A-Za-z0-9-]{0,38}$/.test(login))
|
|
332
|
-
fail('Invalid GitHub identity.');
|
|
333
|
-
const push = await command(
|
|
334
|
-
'provider',
|
|
335
|
-
'gh',
|
|
336
|
-
['api', `repos/${REPOSITORY}`, '--jq', '.permissions.push'],
|
|
337
|
-
checkout,
|
|
338
|
-
);
|
|
339
|
-
const destination =
|
|
340
|
-
push === 'true' ? REPOSITORY : `${login}/official-modules`;
|
|
341
|
-
const head = `${destination.split('/')[0]}:${branch}`;
|
|
342
|
-
const marker = `<!-- flowdular-official:${suffix} -->`;
|
|
343
|
-
const previous = await command(
|
|
344
|
-
'provider',
|
|
345
|
-
'gh',
|
|
346
|
-
[
|
|
347
|
-
'api',
|
|
348
|
-
`repos/${REPOSITORY}/pulls`,
|
|
349
|
-
'--method',
|
|
350
|
-
'GET',
|
|
351
|
-
'-f',
|
|
352
|
-
`head=${head}`,
|
|
353
|
-
'-f',
|
|
354
|
-
'state=open',
|
|
355
|
-
'--jq',
|
|
356
|
-
'[.[] | {url: .html_url, body: (.body // "")}]',
|
|
357
|
-
],
|
|
358
|
-
checkout,
|
|
359
|
-
);
|
|
360
|
-
|
|
361
|
-
const prs = JSON.parse(previous) as { url: string; body: string }[];
|
|
362
|
-
let url = prs.find((pr) => pr.body.includes(marker))?.url;
|
|
363
|
-
await command(
|
|
364
|
-
'branch',
|
|
365
|
-
'git',
|
|
366
|
-
['switch', '--quiet', '-c', branch],
|
|
367
|
-
checkout,
|
|
368
|
-
);
|
|
369
|
-
await command(
|
|
370
|
-
'commit',
|
|
371
|
-
'git',
|
|
372
|
-
['commit', '--quiet', '-m', `Add ${module.id} to Official Modules`],
|
|
373
|
-
checkout,
|
|
374
|
-
);
|
|
375
|
-
if (url) {
|
|
376
|
-
await command(
|
|
377
|
-
'fetch',
|
|
378
|
-
'git',
|
|
379
|
-
[
|
|
380
|
-
'fetch',
|
|
381
|
-
'--quiet',
|
|
382
|
-
`https://github.com/${destination}.git`,
|
|
383
|
-
`refs/heads/${branch}`,
|
|
384
|
-
],
|
|
385
|
-
checkout,
|
|
386
|
-
);
|
|
387
|
-
const remoteTree = await command(
|
|
388
|
-
'guardrails',
|
|
389
|
-
'git',
|
|
390
|
-
['rev-parse', 'FETCH_HEAD^{tree}'],
|
|
391
|
-
checkout,
|
|
392
|
-
);
|
|
393
|
-
const reviewedTree = await command(
|
|
394
|
-
'guardrails',
|
|
395
|
-
'git',
|
|
396
|
-
['rev-parse', 'HEAD^{tree}'],
|
|
397
|
-
checkout,
|
|
398
|
-
);
|
|
399
|
-
if (remoteTree !== reviewedTree)
|
|
400
|
-
fail(
|
|
401
|
-
'The existing PR contains different source. Review it before retrying.',
|
|
402
|
-
);
|
|
403
|
-
}
|
|
404
|
-
if (!url) {
|
|
405
|
-
if (push !== 'true') {
|
|
406
|
-
await command(
|
|
407
|
-
'fork',
|
|
408
|
-
'gh',
|
|
409
|
-
['repo', 'fork', REPOSITORY, '--clone=false', '--remote=false'],
|
|
410
|
-
checkout,
|
|
411
|
-
);
|
|
412
|
-
const parent = await command(
|
|
413
|
-
'provider',
|
|
414
|
-
'gh',
|
|
415
|
-
['api', `repos/${destination}`, '--jq', '.parent.full_name'],
|
|
416
|
-
checkout,
|
|
417
|
-
);
|
|
418
|
-
if (parent.toLowerCase() !== REPOSITORY.toLowerCase())
|
|
419
|
-
fail('The destination is not a fork of Official Modules.');
|
|
420
|
-
}
|
|
421
|
-
// A retry after push/PR failure may reuse only byte-identical source.
|
|
422
|
-
const remote = `https://github.com/${destination}.git`;
|
|
423
|
-
const existing = await command(
|
|
424
|
-
'provider',
|
|
425
|
-
'git',
|
|
426
|
-
['ls-remote', '--heads', remote, `refs/heads/${branch}`],
|
|
427
|
-
checkout,
|
|
428
|
-
);
|
|
429
|
-
if (existing) {
|
|
430
|
-
await command(
|
|
431
|
-
'fetch',
|
|
432
|
-
'git',
|
|
433
|
-
['fetch', '--quiet', remote, `refs/heads/${branch}`],
|
|
434
|
-
checkout,
|
|
435
|
-
);
|
|
436
|
-
const before = await command(
|
|
437
|
-
'guardrails',
|
|
438
|
-
'git',
|
|
439
|
-
['rev-parse', 'FETCH_HEAD^{tree}'],
|
|
440
|
-
checkout,
|
|
441
|
-
);
|
|
442
|
-
const after = await command(
|
|
443
|
-
'guardrails',
|
|
444
|
-
'git',
|
|
445
|
-
['rev-parse', 'HEAD^{tree}'],
|
|
446
|
-
checkout,
|
|
447
|
-
);
|
|
448
|
-
if (before !== after)
|
|
449
|
-
fail(
|
|
450
|
-
'The contribution branch has different source. It was preserved; review it before retrying.',
|
|
451
|
-
);
|
|
452
|
-
} else {
|
|
453
|
-
await command(
|
|
454
|
-
'push',
|
|
455
|
-
'git',
|
|
456
|
-
[
|
|
457
|
-
'push',
|
|
458
|
-
'--quiet',
|
|
459
|
-
`--force-with-lease=refs/heads/${branch}:`,
|
|
460
|
-
remote,
|
|
461
|
-
`HEAD:refs/heads/${branch}`,
|
|
462
|
-
],
|
|
463
|
-
checkout,
|
|
464
|
-
);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
const body = join(scratch, 'pr.md');
|
|
468
|
-
await writeFile(
|
|
469
|
-
body,
|
|
470
|
-
`Adds ${module.id}@${manifest.version} from the sandbox.\n\nApproved specification: ${module.targetPath}/spec/module.yaml (SHA256 ${context.session.modules[0]!.specHash}; operator approval at ${context.session.modules[0]!.specApprovedAt}).\nReviewed source revision: ${revision}.\n\nEvidence: all sandbox gates, exact-source auto-review, registry pnpm verify and pnpm release:pack --local passed. See reviews/${module.id}.json. PostgreSQL CI and maintainer review remain required before publication.\n\nNo registry index publication or application activation is performed.\n\n${marker}\n`,
|
|
471
|
-
);
|
|
472
|
-
url = await command(
|
|
473
|
-
'pr',
|
|
474
|
-
'gh',
|
|
475
|
-
[
|
|
476
|
-
'pr',
|
|
477
|
-
'create',
|
|
478
|
-
'--repo',
|
|
479
|
-
REPOSITORY,
|
|
480
|
-
'--base',
|
|
481
|
-
'main',
|
|
482
|
-
'--head',
|
|
483
|
-
push === 'true' ? branch : head,
|
|
484
|
-
'--title',
|
|
485
|
-
`Add ${module.id} to Official Modules`,
|
|
486
|
-
'--body-file',
|
|
487
|
-
body,
|
|
488
|
-
],
|
|
489
|
-
checkout,
|
|
490
|
-
);
|
|
491
|
-
}
|
|
492
|
-
if (
|
|
493
|
-
!/^https:\/\/github\.com\/Flowdular\/official-modules\/pull\/\d+$/i.test(
|
|
494
|
-
url,
|
|
495
|
-
)
|
|
496
|
-
)
|
|
497
|
-
fail('GitHub did not return an Official Modules pull request URL.');
|
|
498
|
-
return {
|
|
499
|
-
moduleId: module.id,
|
|
500
|
-
targetPath: module.targetPath,
|
|
501
|
-
files: copied,
|
|
502
|
-
removed: 0,
|
|
503
|
-
enabled: false,
|
|
504
|
-
gates,
|
|
505
|
-
steps: recorder.steps,
|
|
506
|
-
restartRequired: false,
|
|
507
|
-
branch,
|
|
508
|
-
pullRequestUrl: url,
|
|
509
|
-
};
|
|
510
|
-
} finally {
|
|
511
|
-
active.delete(key);
|
|
512
|
-
if (scratch) await rm(scratch, { recursive: true, force: true });
|
|
513
|
-
}
|
|
514
|
-
},
|
|
515
|
-
};
|
|
516
|
-
}
|