Skip to content

Commit 5756ae0

Browse files
feat(scenarios): the gallery export writes each app as a trial package (listing text, facet, sample data); the check refuses an app with no sample data (#35430)
Fixes #35132 Clause-②: yes Metadata-protocol: none ## 维护者速读 - 改了什么:应用市场画廊导出的每个应用,现在都带上场景卡的中英文标题和简介、业务职能分类,以及卡上的种子数据(作为安装时的示例数据)。画廊检查会拒绝没有示例数据的应用。 - 为什么改:目标是「客户可以从应用市场中下载安装试用」。之前导出的应用装上后是空的,名字是 `Demoasset`,也没有分类。 - 风险与回滚:风险低。只改导出副本和检查,不碰运行时,不碰被评分的构建。回滚就是还原这个 PR。用旧版导出器写出的画廊目录,在下一次刷新重新导出之前,新检查会报 `app-sample-data`;检查只读不写,不会删除任何应用。 - 先看:`packages/qa/scenarios/src/export/trial-package.ts`(`withSampleData` 对 AI 写的配置做的 AST 拼接,以及四种拒绝情况)→ `src/export/check.ts`(`checkSampleData`)→ `src/export/exporter.ts`(`trialPackageSource` 的调用点)。 - 两分钟验证:`pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 test/export`,预期 4 个文件、132 个测试全部通过。 - 需要你做的:无,席位落地。 ## What changes The gallery exporter (`packages/qa/scenarios/src/export/`) now writes each app's `source/` as a package a customer can install and try. It does this after scoring, into the export copy only. The run's own project is never written. - `objectstack.manifest.json`: `displayName` and `description` are the card's English title and `prompt.short`. The Chinese pair goes under `translations.zh`. `businessFunctions` is the card's own list. The build's other keys are kept. - `src/sample-data.json`: the card's seed rows as stack `data:` datasets. There is one dataset per object, named `demoCODE_object`, with `externalId: 'id'` and rows as the card states them. A `run.userHandleFields` field is left out, and the app README names it. - `objectstack.config.ts`: gets one import line and `data: gallerySampleData` as the first property of the default-exported `defineStack({ … })` literal. The edit is a TypeScript AST splice, and every other byte stays as the AI wrote it. Four cases are refused with a located reason, never guessed: there is no such literal, the literal already declares `data:` or spreads a value, a seeded object is missing from the build, or the build already wrote the file. - `export-gallery --check` has a new finding, `app-sample-data`. It reports a missing `source/src/sample-data.json`, a file that is not a non-empty list of `SeedSchema`-valid datasets each with a record, or a config that does not import it. - `typescript` moves from devDependencies to dependencies. It was already in the install closure through `@objectstack/lint`. The exporter loads it with a dynamic `import()`, so `export-gallery --check` (`dist/export-check.js`) never loads it. - Not written, per the seat's re-split on the card: `installModes`, `solutionType: 'template'`, and the check's installModes refusal. These moved to #35266, which is blocked by #35157. With `installModes: ['unmanaged']`, `defineStack` refuses an app carrying `plugins` or `capability` items (`packages/spec/src/stack.zod.ts:2843`). ## Tests All at head `30a918ccf0`. - `test/export/exporter.test.ts` has a new top-level describe, "the trial package". It pins the manifest's four keys with the build's keys kept. It pins the sample data: namespaced, keyed on `id`, crm's `account.owner` left out. It pins the config edit: one import, `data` first, and the rest byte-identical to the authored file. It checks that the run's project is untouched and that the README line is present. It also covers a scaffold-shaped config, a config with no import line, six refused config shapes, three refused sources, one refusal through `exportGallery` (no app directory written), and `sampleDataOf` over every card in the library. - `test/export/check.test.ts`: the exporter's own output is still clean. There are four `app-sample-data` cases, and the code roster is updated. <details><summary>Readings: package suite, typecheck, ablations</summary> - `os-verify-lock … vitest run --maxWorkers=2` (whole `@objectstack/scenarios` suite): `Test Files 40 passed (40)`, `Tests 1199 passed (1199)`, `VERDICT command-exit 0`. - `pnpm --filter @objectstack/scenarios typecheck`: exit 0. - Ablation 1: `ablation-replace.mjs` deleted the `checkSampleData(dir, app, add);` call (anchor 1 → 0, blob 0d9fd6d → 0c9d9b17). Result: `Tests 4 failed | 37 passed (41)`, which is exactly the four sample-data cases. Restored blob 0d9fd6d equals the HEAD blob, and `git diff HEAD` is empty. - Ablation 2: the `trialPackageSource` call was replaced with the authored files as they are (blob 7b14425 → 16986a84). Result: `Tests 32 failed | 67 passed (99)` across exporter and check suites. Among them are the layout test, the trial-package export test and the `data:` refusal export test; the check's clean tree goes red, as do the other cases that copy it. Restored blob 7b14425 equals HEAD. </details> ## Acceptance notes - Measured, as the seat asked: the exported source still passes `objectstack validate` with the new keys, on a managed stack. A probe project used the blank scaffold's `objectstack.config.ts` verbatim (connector plugins included), the recorded `travel_expense` build's 7 objects, and `trialPackageSource` output with 757 rows. `os validate` printed `✓ Validation passed`, exit 0. The control project without the trial edits also exited 0. A negative leg, with one dataset renamed to `demotravel_nope`, exited 1 with `Seed data references object 'demotravel_nope' which is not defined in objects.`, so the validator reads the imported JSON. The probe dropped the three `state_machine` validations from the probe objects in both projects. Without that, both projects failed identically on `state-machine-no-initial-states`, an author-time rule unrelated to `data:`. The probe projects were deleted. - Measured, as the seat asked: no app the exporter emits on refresh is refused or deleted by the new refusals. The check pin "the exporter's own output … has no finding" runs the new check over this exporter's output. The exporter's new refusals cannot fire on the gallery's apps as far as in-repo evidence reaches. Every one of the 9 cards seeds only objects in its `expect.objects`, and the recorded `travel_expense` build declares all 7 seeded objects. That build artifact carries no `data`, and the probe's scaffold config shape takes the edit. For `asset_lifecycle`, 6973237961 added `data:` to the gallery source by hand, and 559 rows (the card's full count) inserted with 0 errors, so the source had no `data:` of its own. The gallery repository itself is not readable from this session, so its other listed apps were not checked directly. A tree written by the earlier exporter has no sample-data file, so the check reports each of its apps until the next refresh re-exports it. The check writes nothing. - `order_to_cash`'s English title is 131 characters. `PackageSchema.displayName` allows at most 128, and its `objectstack.manifest.json` fails `TemplateManifestSchema` (measured). The exporter writes it anyway rather than refuse the app (a refusal would delete a listed app). This is reported to the seat as a decision; see the report. - The scaffold's `objectstack.manifest.json` keeps `readmePath: 'README.md'`, but the exporter never copies the scaffold README into `source/`. `os package publish` reads `readmePath` and exits 1 when the file is missing (`publish.ts:883`, read, not run). carrier: #35134. - `manifest.name` in the config (the in-app package name, e.g. `Demoasset`) is unchanged: the listing name is `objectstack.manifest.json` `displayName`. carrier: #35134. - Sample rows carry the card's own dates (its `asOf`), not the run date's rebase. - Public surface of `@objectstack/scenarios/export`: new exports `sampleDataOf`, `listingManifest`, `withSampleData`, `trialPackageSource`, `TrialPackageRefusal`, `SAMPLE_DATA_FILE`, `SAMPLE_DATA_SPECIFIER`, `SAMPLE_DATA_BINDING` and the type `SampleDataset`. `FINDING_CODES` gains `app-sample-data`, so the check accepts less. There is one new runtime dependency, `typescript`. ## Verification <details><summary>Gates (local subset, head 30a918c)</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 75 families. All 75 ran: `✓ dispatch-gates --ran: 75 derived famil(ies) accounted for — 75 run, 0 NOT-MEASURED (a DERIVED zero …)`. - `pnpm check:cross-package-test-inputs` was red on a first draft, which read the blank scaffold config from `create-objectstack`. The pin now uses an inline scaffold-shaped fixture, and the gate exits 0 (`OK: 32 package(s) read outside themselves, all declared …`). - `pnpm check:dts-closure` and `pnpm check:dual-build-cjs-loads` both exited 1 once in the sweep, naming only `@objectstack/organizations`'s `dist/index.d.ts` (a package this diff does not touch) while its `dist/` was being rewritten. On re-run both exited 0: `260/260 declared declaration file(s) present`, and `124 published require entry point(s) … load`. - `node scripts/check-platform-checklist.mjs --changed-from origin/main`: exit 0, 0 anchored files. - `node scripts/pm/overlap-check.mjs`: `VERDICT clean exit 0` (origin/main, #35129 and #34223 merge cleanly). - The repo-wide lint and the full CI battery are left to CI. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Q4EjjNq58cmHeqckjZkTFE)_ <!-- signed: repo:objectstack#6 · hotlong · session_01Q4EjjNq58cmHeqckjZkTFE --> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 96a1f2b commit 5756ae0

11 files changed

Lines changed: 541 additions & 15 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
feat(scenarios): the gallery export writes each app as a package a customer can install and try (listing text, business-function facet, sample data), and the gallery check refuses an app with no sample data
6+
7+
Clause-②: yes
8+
Metadata-protocol: none
9+
10+
The exporter now adds three things to each app's `source/`. It adds them after the run is scored, so the AI's build is never graded on them, and it never writes them into the run's own project.
11+
12+
- `objectstack.manifest.json` gets the card's listing text and facet. `displayName` and `description` are the card's English title and one-sentence requirement. The Chinese pair goes under `translations.zh`. `businessFunctions` is the card's own list, primary first. The build's other keys are kept.
13+
- `src/sample-data.json` holds the card's seed rows as stack `data:` datasets: one per object, named with the app's namespace, keyed on the card's row id (`externalId: 'id'`). Lookup values name row ids of the same load. A user-handle field (`run.userHandleFields`) is left out of every row, because its value names a user of the run's own environment, and the app README says which field was left out.
14+
- `objectstack.config.ts` gets one import line and `data: gallerySampleData` as the first property of its default-exported `defineStack({ … })` literal. Every other byte stays as the AI wrote it. The export is refused, with the reason, in four cases: the default export is not such a literal, the literal already declares `data:` or spreads a value, a seeded object is missing from the build, or the build already wrote `src/sample-data.json`.
15+
16+
Measured on `travel_expense`: the blank scaffold's `objectstack.config.ts`, with the recorded build's objects and the 757 seed rows added this way, passes `objectstack validate`. A dataset naming an object the build lacks is refused there ("Seed data references object … which is not defined in objects"), which shows the validator reads the imported file.
17+
18+
`export-gallery --check` has a new finding, `app-sample-data`. It reports an app whose `source/` has no `src/sample-data.json`, a file that is not a non-empty list of datasets the spec's `SeedSchema` accepts (each with at least one record), or a `source/objectstack.config.ts` that does not import it. A gallery tree written by an earlier exporter has no sample-data file, so the check reports each of its apps until the next refresh exports them again. The check writes nothing and deletes no app.
19+
20+
`installModes` and `solutionType` are not written yet: `installModes: ['unmanaged']` makes `defineStack` refuse an app that carries code `plugins` or `capability` items, which an app on the standard scaffold does. `typescript` moves from a dev dependency to a dependency. The exporter loads it, with a dynamic import, only when it edits a config.

‎packages/qa/scenarios/README.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,14 @@ that version, it prints one `skip: …` line and exits 0, having run nothing. It
720720
1. runs every card the gallery may show (origin `generic`, tier `starter` or `delivery`; `--debut`: the first of them
721721
by id) with `run-scenarios --modes scratch --packages published --create-version <version>`, so the apps are built
722722
on exactly that release, the turns recorded;
723-
2. exports with screenshots into the checkout (`export-gallery`'s rules: only a run that passed every half);
723+
2. exports with screenshots into the checkout (`export-gallery`'s rules: only a run that passed every half). Each
724+
app's `source/` is written as a package a customer installs to try, after scoring so the build is never graded on
725+
it (`src/export/trial-package.ts`): `objectstack.manifest.json` carries the card's English title and one-sentence
726+
requirement as `displayName` and `description`, the Chinese pair under `translations.zh`, and the card's
727+
`businessFunctions`; `src/sample-data.json` carries the card's seed rows as stack `data:` datasets (namespaced
728+
objects, `externalId: 'id'`, a user-handle field left out), which `objectstack.config.ts` imports into its `data:`.
729+
`installModes` and `solutionType` are not written: `installModes: ['unmanaged']` makes `defineStack` refuse an app
730+
that carries code `plugins` or `capability` items, which an app on the standard scaffold does;
724731
3. creates the branch `export/<version>`, commits `apps/` and `index.json` under the checkout's own git identity, and
725732
prints the branch, the commit and a ready PR body.
726733

@@ -786,7 +793,9 @@ The check a PR on objectstack-ai/gallery must pass before it is merged (`src/exp
786793
layout), so the two cannot drift. It prints one `CODE PATH: MESSAGE` line per finding and exits 1 on any, 0 on a clean
787794
tree: `index.json` that does not validate (absent is an empty gallery); an entry without a complete `apps/<id>/`
788795
(README, run record, scorecard and transcript in JSON and Markdown, `source/objectstack.config.ts`, at least one
789-
screenshot, every listed screenshot on disk and none unlisted); a directory under `apps/` no entry lists; a
796+
screenshot, every listed screenshot on disk and none unlisted); an app whose package arrives with no sample data (no
797+
`source/src/sample-data.json`, one that is not a non-empty list of stack `data:` datasets the spec's `SeedSchema`
798+
accepts, each with a record, or a `source/objectstack.config.ts` that does not import it); a directory under `apps/` no entry lists; a
790799
`framework.version` that is not a stable release published for `@objectstack/cli` (read with `npm view … versions`,
791800
only when the index lists an app); and anywhere in the tree a `.env*` name, a `node_modules` directory, a symbolic link
792801
or a text file naming a local absolute path.

‎packages/qa/scenarios/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,11 @@
7878
"@objectstack/plugin-sharing": "workspace:*",
7979
"@objectstack/spec": "workspace:*",
8080
"playwright-core": "1.63.0",
81+
"typescript": "^6.0.3",
8182
"zod": "^4.6.6"
8283
},
8384
"devDependencies": {
8485
"@types/node": "^26.6.5",
85-
"typescript": "^6.0.3",
8686
"vitest": "^4.1.11"
8787
},
8888
"keywords": [

‎packages/qa/scenarios/src/export/check.ts‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
* the README, the run record, the scorecard and the
2121
* transcript (JSON and Markdown each), and a `source/` tree
2222
* holding `objectstack.config.ts`.
23+
* app-sample-data an entry's package arrives with no sample data: its
24+
* `source/` holds no {@link SAMPLE_DATA_FILE}, the file is
25+
* not a non-empty list of stack `data:` datasets (each
26+
* valid against the spec's `SeedSchema`, each with at
27+
* least one record), or `source/objectstack.config.ts`
28+
* does not import it ({@link SAMPLE_DATA_SPECIFIER}).
2329
* app-screenshots an entry lists no screenshot, a listed screenshot is not
2430
* on disk, or `screenshots/` holds a file the entry does
2531
* not list.
@@ -49,13 +55,16 @@ import { execFileSync } from 'node:child_process';
4955
import { existsSync, lstatSync, readdirSync, readFileSync } from 'node:fs';
5056
import { join } from 'node:path';
5157

52-
import { APP_LAYOUT, FRAMEWORK_PACKAGE, STABLE_VERSION } from './contract.js';
58+
import { SeedSchema } from '@objectstack/spec/data';
59+
60+
import { APP_LAYOUT, FRAMEWORK_PACKAGE, SAMPLE_DATA_FILE, SAMPLE_DATA_SPECIFIER, STABLE_VERSION } from './contract.js';
5361
import { GalleryIndexSchema, type GalleryApp } from './manifest.js';
5462

5563
export const FINDING_CODES = [
5664
'index-json',
5765
'app-missing',
5866
'app-incomplete',
67+
'app-sample-data',
5968
'app-screenshots',
6069
'app-unlisted',
6170
'framework-version',
@@ -162,6 +171,7 @@ export function checkGallery(dir: string, opts: CheckOptions): GalleryFinding[]
162171
if (!isFile(join(root, APP_LAYOUT.source, SOURCE_REQUIRED))) {
163172
add('app-incomplete', `${rel}/${APP_LAYOUT.source}`, `a complete app directory holds its metadata source, ${APP_LAYOUT.source}/${SOURCE_REQUIRED} at least, and this one does not`);
164173
}
174+
checkSampleData(dir, app, add);
165175
checkScreenshots(dir, app, add);
166176
}
167177
const v = app.framework.version;
@@ -181,6 +191,41 @@ export function checkGallery(dir: string, opts: CheckOptions): GalleryFinding[]
181191
return findings;
182192
}
183193

194+
/** The sample data a trial package arrives with: present, a valid non-empty dataset list, and read by the config. */
195+
function checkSampleData(dir: string, app: GalleryApp, add: AddFinding): void {
196+
const source = `apps/${app.id}/${APP_LAYOUT.source}`;
197+
const config = join(dir, source, SOURCE_REQUIRED);
198+
if (!isFile(config)) return; // an incomplete source is `app-incomplete` already
199+
const rel = `${source}/${SAMPLE_DATA_FILE}`;
200+
const file = join(dir, rel);
201+
if (!isFile(file)) {
202+
add('app-sample-data', rel, `a gallery app is a package a customer installs to try, and it arrives with the card's seed rows as its sample data in ${APP_LAYOUT.source}/${SAMPLE_DATA_FILE}; this one has none`);
203+
return;
204+
}
205+
let raw: unknown;
206+
try {
207+
raw = JSON.parse(readFileSync(file, 'utf8'));
208+
} catch (e) {
209+
add('app-sample-data', rel, `not JSON: ${e instanceof Error ? e.message : String(e)}`);
210+
return;
211+
}
212+
if (!Array.isArray(raw) || raw.length === 0) {
213+
add('app-sample-data', rel, 'the sample data is a non-empty list of stack `data:` datasets, and this is not one');
214+
return;
215+
}
216+
raw.forEach((dataset, i) => {
217+
const parsed = SeedSchema.safeParse(dataset);
218+
if (!parsed.success) {
219+
for (const issue of parsed.error.issues) add('app-sample-data', rel, `[${i}]${issue.path.length ? `.${issue.path.join('.')}` : ''}: ${issue.message}`);
220+
} else if (parsed.data.records.length === 0) {
221+
add('app-sample-data', rel, `[${i}] (\`${parsed.data.object}\`) holds no record`);
222+
}
223+
});
224+
if (!readFileSync(config, 'utf8').includes(`'${SAMPLE_DATA_SPECIFIER}'`)) {
225+
add('app-sample-data', `${source}/${SOURCE_REQUIRED}`, `does not import '${SAMPLE_DATA_SPECIFIER}' into its \`data:\`, so the package installs without its sample data`);
226+
}
227+
}
228+
184229
function checkScreenshots(dir: string, app: GalleryApp, add: AddFinding): void {
185230
const rel = `apps/${app.id}/${APP_LAYOUT.screenshots}`;
186231
if (app.screenshots.length === 0) add('app-screenshots', rel, `index.json lists no screenshot for \`${app.id}\`: an app is shown with its screenshots`);

‎packages/qa/scenarios/src/export/contract.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export const APP_LAYOUT = {
2222
screenshots: 'screenshots',
2323
} as const;
2424

25+
/**
26+
* The trial package's sample data, relative to `apps/<id>/source/`: the card's
27+
* seed rows as stack `data:` datasets (`trial-package.ts`), which the check
28+
* requires (`app-sample-data`).
29+
*/
30+
export const SAMPLE_DATA_FILE = 'src/sample-data.json';
31+
32+
/** How `source/objectstack.config.ts` imports {@link SAMPLE_DATA_FILE}: the specifier, and the name it binds. */
33+
export const SAMPLE_DATA_SPECIFIER = `./${SAMPLE_DATA_FILE}`;
34+
export const SAMPLE_DATA_BINDING = 'gallerySampleData';
35+
2536
/** The package whose npm `latest` is the framework release the gallery follows. */
2637
export const FRAMEWORK_PACKAGE = '@objectstack/cli';
2738

‎packages/qa/scenarios/src/export/exporter.ts‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
* 2. ⛔ the run was on published packages ({@link unpublishedRunRefusal}): a
1313
* `--packages workspace` run is never exported or shown;
1414
* 3. the record passed every half ({@link judgeRecord});
15-
* 4. the run's scratch project is still on disk, with its build;
15+
* 4. the run's scratch project is still on disk, with its build, and its
16+
* source can be made the trial package ({@link trialPackageSource}): its
17+
* config default-exports a `defineStack({ … })` literal that declares no
18+
* `data:` of its own, and the build declares every object the card seeds;
1619
* 5. its transcript joins with the recording ({@link buildTranscript});
1720
* 6. its screenshots were taken, unless the caller turned them off.
1821
*
@@ -22,7 +25,9 @@
2225
*
2326
* apps/<id>/README.md what the app is, the driver that ran it ({@link driverText}), what its authoring cost
2427
* ({@link authorCostText}: stated only when every authoring turn reported a cost), its scorecard, the files
25-
* apps/<id>/source/… the authored metadata source (`source.ts`)
28+
* apps/<id>/source/… the authored metadata source (`source.ts`), as a trial package: the
29+
* card's listing text, facet and sample data added after scoring
30+
* (`trial-package.ts`)
2631
* apps/<id>/run-record.json the run record, the work directories redacted (`workDirsOf`)
2732
* apps/<id>/scorecard.json|.md the per-half scorecard
2833
* apps/<id>/transcript.json|.md the per-persona 问数 transcript
@@ -59,6 +64,7 @@ import { judgeRecord, type PassJudgement } from './pass.js';
5964
import { readRunRecords, redactWorkDir, unpublishedRunRefusal, type RecordFile, type ScenarioRunRecord } from './record.js';
6065
import type { CaptureScreenshots, PlannedShot, SkippedShot } from './screenshots.js';
6166
import { projectFrameworkVersion, readAuthoredSource } from './source.js';
67+
import { SAMPLE_DATA_FILE, trialPackageSource } from './trial-package.js';
6268
import { buildTranscript, mergeRecordings, renderTranscript } from './transcript.js';
6369

6470
/** The files of one exported app, relative to `apps/<id>/` (`contract.ts`, which the check reads too). */
@@ -130,7 +136,7 @@ export function driverText(driver: ScenarioRunRecord['env']['driver']): string {
130136
return named(driver);
131137
}
132138

133-
function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: GalleryApp, judgement: PassJudgement, scorecard: CardScorecard, shots: PlannedShot[], skipped: SkippedShot[]): string {
139+
function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: GalleryApp, judgement: PassJudgement, scorecard: CardScorecard, shots: PlannedShot[], skipped: SkippedShot[], omitted: readonly string[]): string {
134140
const c = scenario.card;
135141
const lines = [
136142
`# ${c.title.en}`,
@@ -144,6 +150,7 @@ function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: G
144150
`- Driver: ${driverText(record.env.driver)}`,
145151
`- Author cost (as the driver reported it): ${authorCostText(scorecard.authorCost)}`,
146152
`- 问数: ${entry.qa.questions} questions, ${entry.qa.turns} persona turns · ${entry.operations} write operations`,
153+
`- Sample data: the card's ${Object.values(c.run.seed).reduce((n, rows) => n + rows.length, 0)} seed rows in ${Object.keys(c.run.seed).length} objects${omitted.length ? `, without ${omitted.map((f) => `\`${f}\``).join(', ')} (a user handle of the run's own environment, left unset)` : ''}`,
147154
'',
148155
'## The requirement',
149156
'',
@@ -158,7 +165,7 @@ function appReadme(scenario: LoadedScenario, record: ScenarioRunRecord, entry: G
158165
'',
159166
'## Files',
160167
'',
161-
`- [\`${APP_LAYOUT.source}/\`](./${APP_LAYOUT.source}/) — the app's metadata source, as the AI wrote it (after the change request)`,
168+
`- [\`${APP_LAYOUT.source}/\`](./${APP_LAYOUT.source}/) — the app's metadata source, as the AI wrote it (after the change request), with the package's listing text in \`objectstack.manifest.json\` and the card's seed rows as its sample data (\`${SAMPLE_DATA_FILE}\`, read into \`data:\`), both added after scoring`,
162169
`- [\`${APP_LAYOUT.transcriptMd}\`](./${APP_LAYOUT.transcriptMd}) — every data question, each persona's answer and its grade ([JSON](./${APP_LAYOUT.transcriptJson}))`,
163170
`- [\`${APP_LAYOUT.scorecardMd}\`](./${APP_LAYOUT.scorecardMd}) — the scorecard ([JSON](./${APP_LAYOUT.scorecardJson}))`,
164171
`- [\`${APP_LAYOUT.runRecord}\`](./${APP_LAYOUT.runRecord}) — the full run record`,
@@ -294,7 +301,10 @@ async function exportOne(
294301
if (!existsSync(projectDir)) throw new Refused([`the run's scratch project is gone: ${projectDir}`]);
295302
const artifact = readArtifact(projectDir);
296303
if (artifact === undefined) throw new Refused([`${projectDir} holds no dist/objectstack.json`]);
297-
const source = readAuthoredSource(projectDir);
304+
const authored = readAuthoredSource(projectDir);
305+
// The trial package's listing text, facet and sample data: added to the exported copy only, after scoring.
306+
const builtObjects = new Set(((artifact as { objects?: Array<{ name?: unknown }> }).objects ?? []).map((o) => o?.name).filter((n): n is string => typeof n === 'string'));
307+
const source = await trialPackageSource(authored.files, card, builtObjects);
298308
const frameworkVersion = projectFrameworkVersion(projectDir);
299309
const redact = <T,>(v: T): T => redactWorkDir(v, workDirsOf(record.evidenceDir, opts.workDir));
300310
const transcript = redact(buildTranscript(scenario, record, turns));
@@ -332,7 +342,7 @@ async function exportOne(
332342
[APP_LAYOUT.scorecardMd, `${renderScorecard(scorecard)}\n`],
333343
[APP_LAYOUT.transcriptJson, json(transcript)],
334344
[APP_LAYOUT.transcriptMd, renderTranscript(transcript, card.title.en)],
335-
[APP_LAYOUT.readme, redact(appReadme(scenario, record, entry, judgement, scorecard, shots, skipped))],
345+
[APP_LAYOUT.readme, redact(appReadme(scenario, record, entry, judgement, scorecard, shots, skipped, source.omitted))],
336346
]);
337347
return { entry, shots, skipped };
338348
}

‎packages/qa/scenarios/src/export/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ export * from './refresh.js';
2020
export * from './screenshots.js';
2121
export * from './source.js';
2222
export * from './transcript.js';
23+
export * from './trial-package.js';

0 commit comments

Comments
 (0)