Skip to content

๐Ÿคฏ LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

๐Ÿ”– chore(cli): bump @lobehub/cli to v0.0.44 (#17288)

Arvin Xu78d22e955f73
diff --git a/.agents/skills/agent-testing/SKILL.md b/.agents/skills/agent-testing/SKILL.md
index 7531a064279..95db73a5e86 100644
--- a/.agents/skills/agent-testing/SKILL.md
+++ b/.agents/skills/agent-testing/SKILL.md
@@ -476,7 +476,8 @@ All under `.agents/skills/agent-testing/scripts/`:
| `agent-browser-klm.mjs` | Wrap `agent-browser`, run the real action, and append a GOMS-KLM interaction atom JSONL |
| `agent-browser-klm-analyze.mjs` | Summarize interaction JSONL into `result.json.interactionCost` / markdown cost output |
| `record-gif.sh` | Frame-sequence โ†’ GIF for time-based behavior (streaming, timers, animations) |
-| `report-init.sh` | Scaffold a structured test report (Step 5) |
+| `report-init.sh` | Scaffold a structured test report, grouped by acceptance subject (Step 5) |
+| `fixture.mjs` | Per-check fixture assets: `init-check` / `list` / `compose` an ingest-ready round (Step 5) |
| `check-screen-recording.sh` | Preflight: OS screen-capture works (macOS Screen Recording + display awake) |
| `electron-dev.sh` | Manage Electron dev env (start/stop/status/restart, CDP 9222) |
| `cdp-screenshot.sh` | Electron/Chrome screenshot via RAW CDP (bypasses agent-browser daemon); `--check` preflight |
@@ -531,16 +532,42 @@ Every automated test session ends with a structured, evidence-backed report โ€”
not a chat-only summary. Scaffold it up front and fill it as you test:
```bash
-DIR=$(./.agents/skills/agent-testing/scripts/report-init.sh my-feature "Verify my feature")
+# --subject = the acceptance this run belongs to (Step 6) โ€” pass it up front
+DIR=$(./.agents/skills/agent-testing/scripts/report-init.sh --subject topic:tpc_xxx my-feature "Verify my feature")
# ... test, saving screenshots / CLI transcripts into $DIR/assets/ ...
# fill $DIR/result.json (scenario, context, cases[], summary.conclusion) โ€” the report;
# $DIR/report.md holds only the narrative tail (follow-ups / notes / score)
```
-Reports live in `.records/reports/<timestamp>-<slug>/` (gitignored): `result.json`
-(the structured report โ€” scenario/context/cases/summary), `report.md` (narrative
-tail), `assets/` (evidence). Format spec and evidence rules:
-[references/report.md](./references/report.md).
+Reports live in `.records/reports/<subject-key>/<timestamp>-<slug>/` (gitignored),
+**grouped by acceptance**: one dir per subject (`topic-tpc_xxx`, with an
+`acceptance.json` marker), one subdir per verification run. Each run dir holds
+`result.json` (the structured report โ€” scenario/context/cases/summary),
+`report.md` (narrative tail), `assets/` (evidence). `--subject` also pre-fills
+`result.json.subject` so ingest attaches the run automatically. Format spec and
+evidence rules: [references/report.md](./references/report.md).
+
+#### Fixtures: reusable per-check assets
+
+When a run needs seeded/constructed data (fixture rounds, seed files, probe
+steps), keep those assets per CHECK ITEM โ€” the business check that recurs
+across rounds โ€” under `.records/fixtures/<subject-key>/<check-id>/`
+(`check.json` = plan fragment + case template + future replay `steps`;
+`seed/` = reusable INPUT assets only). The reusability line is inputs vs
+outputs: what a run consumes (files to upload, DB seed fragments, stand-in
+evidence for synthetic ingest rounds) belongs in `seed/`; what a run produces
+(screenshots, transcripts) is tied to that one execution and stays in the round
+dir's `assets/` โ€” never copy it back into the fixture. Compose an ingest-ready
+round from checks instead of hand-writing result.json each time:
+
+```bash
+F=./.agents/skills/agent-testing/scripts/fixture.mjs
+$F init-check --subject topic:tpc_xxx palette-long-list # scaffold, then fill check.json
+$F list --subject topic:tpc_xxx
+DIR=$($F compose --subject topic:tpc_xxx --slug round4 --title "็ฌฌๅ››่ฝฎๅ…จ้‡ๅ›žๅฝ’" \
+ palette-open palette-long-list) # โ†’ report group round dir
+lh verify ingest-report "$DIR" ... # fixture rounds are normal reports
+```
Two hard rules worth front-loading:
diff --git a/.agents/skills/agent-testing/references/common-mistakes.md b/.agents/skills/agent-testing/references/common-mistakes.md
index e0042bd42cf..f1e39fdb7ba 100644
--- a/.agents/skills/agent-testing/references/common-mistakes.md
+++ b/.agents/skills/agent-testing/references/common-mistakes.md
@@ -714,6 +714,7 @@ can operate at workspace scope.
and verification. Give members own-only actions; give owners both own and workspace
variants for every applicable action; use elevated confirmation for destructive
workspace-wide variants; and assert every matrix cell in UI tests and screenshots.
+
## Case 27 โ€” Labeling two steps of a flow as a before/after `comparison` pair
**Wrong approach**: for a case whose evidence is two SEQUENTIAL steps of one flow (the reject
@@ -731,3 +732,24 @@ misleads reviewers about what they are looking at.
**Correct approach**: `comparison` is ONLY for the same surface before vs after a change. For flow
steps, attach plain ordered evidence items (the array preserves order) and give each a caption
naming its step ("step 1 โ€” dialog with region circled", "step 2 โ€” feedback card after submit").
+
+## Case 28 โ€” Publishing the report to the LOCAL instance because the subject "only exists locally"
+
+**Wrong approach**: the run's subject (the task under test) lived only in the local dev DB, so I
+ingested the report into the local instance (`--subject task:<local id>` against `localhost`) and
+delivered `localhost` URLs as the final links โ€” reasoning that a production subject didn't exist and
+that attaching to the actual local task was "semantically perfect".
+
+**Why it's wrong**: the user immediately asked why the report wasn't on production. The publish
+target rule (SKILL Step 6) is not conditional on subject convenience: the deliverable must live on
+`app.lobehub.com`, where links survive teardown and are shareable. A missing production subject is a
+solvable prerequisite, not a reason to downgrade the publish target โ€” the CLI can create one in
+seconds (`lh task create -n "<verification anchor>" -i "..."` โ†’ `--subject task:T-<seq>`). A local
+ingest is fine as an _additional_ demo of the acceptance chaining, but never as the primary
+deliverable.
+
+**Correct approach**: when no production subject exists, create a production anchor entity first
+(task via `lh task create`, or a topic), then run the clean-env production publish
+(`env -u LOBEHUB_SERVER -u LOBE_API_KEY -u LOBEHUB_CLI_API_KEY -u LOBEHUB_CLI_HOME` + the branch's
+own CLI for the canary `--subject` contract). Gotcha hit on the way: bare `--json` on `task create`
+crashes (`fields.split is not a function`) โ€” omit it or pass explicit fields.
diff --git a/.agents/skills/agent-testing/references/probe-mock-patterns.md b/.agents/skills/agent-testing/references/probe-mock-patterns.md
index c2b66cafb85..2f7a562dd2e 100644
--- a/.agents/skills/agent-testing/references/probe-mock-patterns.md
+++ b/.agents/skills/agent-testing/references/probe-mock-patterns.md
@@ -1451,6 +1451,7 @@ posix_spawn '<cmd>'` โ€” NOT node's `spawn <cmd> ENOENT`. Any stderr-text patter
in-process for 30s (`packages/app-config/src/messenger.ts` CACHE\_TTL\_MS) โ€” wait out the TTL
after editing the row before reloading.
- Locale for evidence shots: `window.__LOBE_STORES.global().switchLocale('zh-CN')` then reload.
+
### D21. โœ… WORKS โ€” when `click @ref` reports Done but the React onClick never fires, click via `eval` `element.click()`
**Situation**: on a dense list row (acceptance check rows with hover-revealed ActionIcons and
@@ -1496,3 +1497,37 @@ env -u HTTP_PROXY -u HTTPS_PROXY -u http_proxy -u https_proxy -u ALL_PROXY -u al
Symptom fingerprint: every auth POST answers 307 in \~25ms with `application-code` time present, and
the prewarm warning mentions `redirect count exceeded`.
+
+### C12. A globally installed `lh` ingest-report can silently create an ORPHAN verify run (no acceptance attach) when the branch's CLI contract is newer
+
+- **Situation**: publishing/ingesting a report while verifying a branch that extends the verify CLI
+ (e.g. adds `--subject` / acceptance attach). The global `lh` accepted the report, returned a
+ `verifyRunId`, and printed no error โ€” but the run's `acceptance_id` was NULL, so it never appeared
+ on the acceptance page, which reads as "my ingest didn't show up / the page is stale".
+- **Doesn't work**: trusting a green `verifyRunId` from the global CLI as proof of attachment, or
+ passing `--subject` to it (`error: unknown option '--subject'` is the tell that it predates the
+ branch contract).
+- **Works**: run the branch's own CLI from the worktree โ€” `cd apps/cli && bun src/index.ts verify
+ingest-report <dir> --subject topic:<id> โ€ฆ` โ€” and verify attachment in the DB
+ (`select acceptance_id from verify_runs where id='<runId>'`) before driving the UI against it.
+
+### D22. โœ… WORKS โ€” driving the manual-approval intervention chain (ๆ‰นๅ‡† / ๆไบค cards) in web chat
+
+- **Situation**: a real agent turn under the default manual-approval mode stops at an
+ intervention card (`lobe-activator โ†’ ๆฟ€ๆดปๅทฅๅ…ท`, `Task Tools โ†’ createTask`, โ€ฆ) after EVERY tool
+ call. `snapshot -i` does not reliably expose the card's option rows / submit button as refs,
+ and one turn can chain 4โ€“5 sequential interventions โ€” a fixed approve-once script stalls.
+- **Doesn't work**: matching the option row by exact text `ๆ‰นๅ‡†` (the row nests the label; the
+ filtered element list often misses it), or assuming one approval finishes the turn.
+- **Works**: the "approve" option is pre-selected by default, so clicking the card's **ๆไบค**
+ button alone approves. Loop until quiescent: each round, find the LAST visible element whose
+ text includes `ๆไบค` via `eval`, tag it `data-probe`, click through agent-browser (trusted
+ input), then poll `chat().operations` for zero `running` AND no remaining ๆไบค button before
+ declaring the turn done. Log which tool each round approved by grabbing the last visible
+ `โ€ฆ โ†’ โ€ฆ` header text. One creation turn (activate + createTask + setTaskVerify + runTask)
+ took 5 approvals.
+- **Also measured (fixture note)**: a task's verify requirement is visible to the RUNNER agent,
+ which will optimize toward the acceptance criteria (a "200 ๅญ—๏ผŒno code" instruction with a
+ "โ‰ฅ1500 ๅญ— + Python code" requirement produced a 3.5k-char deliverable) โ€” a contradictory-criteria
+ fixture still fails verification, but not for the reason you scripted; assert on the verifier's
+ recorded rationale, not on your intended contradiction.
diff --git a/.agents/skills/agent-testing/references/report.md b/.agents/skills/agent-testing/references/report.md
index 5a123d2b96c..e56e96bd7d4 100644
--- a/.agents/skills/agent-testing/references/report.md
+++ b/.agents/skills/agent-testing/references/report.md
@@ -7,15 +7,35 @@ user (or a reviewer, or a later agent) audits without replaying the session.
## Location & layout
Reports live under `.records/reports/` (gitignored, like all `.records/`
-output):
+output), **grouped by the acceptance they belong to**: one directory per
+subject, one subdirectory per verification run (round). The subject key is the
+ingest subject with `:` โ†’ `-`.
```
-.records/reports/<YYYYMMDD-HHMMSS>-<slug>/
-โ”œโ”€โ”€ report.md # narrative TAIL only (่ทŸ่ฟ› / ๆœฌ่ฝฎ้ชŒ่ฏ / ่ฏ„ๅˆ†) โ€” rendered as the page's "Details"
-โ”œโ”€โ”€ result.json # the structured source: scenario + context + cases + summary.conclusion
-โ””โ”€โ”€ assets/ # evidence: screenshots, HAR files, CLI transcripts
+.records/reports/<subject-key>/ # e.g. topic-tpc_acceptreview001
+โ”œโ”€โ”€ acceptance.json # group marker: subject, title, lastRun
+โ”œโ”€โ”€ <YYYYMMDD-HHMMSS>-<slug>/ # one run = one round on the acceptance
+โ”‚ โ”œโ”€โ”€ report.md # narrative TAIL only (่ทŸ่ฟ› / ๆœฌ่ฝฎ้ชŒ่ฏ / ่ฏ„ๅˆ†) โ€” the page's "Details"
+โ”‚ โ”œโ”€โ”€ result.json # the structured source: scenario + context + cases + summary.conclusion
+โ”‚ โ””โ”€โ”€ assets/ # evidence: screenshots, HAR files, CLI transcripts
+โ””โ”€โ”€ <YYYYMMDD-HHMMSS>-<slug>/ # the next round, and so on
```
+Every run belongs to a subject acceptance (SKILL.md Step 6), so the group is
+known before the round starts โ€” pass it to the scaffold:
+`report-init.sh --subject topic:tpc_xxx <slug> "<title>"`. The scaffold also
+pre-fills `result.json.subject`, so `lh verify ingest-report` attaches the run
+without an explicit `--subject`. Runs scaffolded without `--subject` fall back
+to a flat `.records/reports/<ts>-<slug>/` (legacy layout, still readable by
+`ingest-report` โ€” but new runs should always carry their subject).
+
+Reusable per-check fixture assets live NEXT to the report groups under
+`.records/fixtures/<subject-key>/<check-id>/` โ€” `check.json` plus `seed/`
+(INPUTS a run consumes: files to upload, DB seed fragments, replay steps'
+material). Execution OUTPUTS (screenshots, transcripts) are per-run evidence
+and belong only in the round dir's `assets/`. See `scripts/fixture.mjs` and
+SKILL.md "Fixtures: reusable per-check assets".
+
**`result.json` is the report โ€” `report.md` is just its tail.** The published
verify page (`/verify/<id>`) renders itself from `result.json`: one line of
provenance (PR / branch / commit / date / surfaces), the overall conclusion from
@@ -29,7 +49,7 @@ table โ€” those double up on the page. It carries only the non-duplicate narrati
1. **Scaffold up front** โ€” before running the first test step:
```bash
- DIR=$(./.agents/skills/agent-testing/scripts/report-init.sh < slug > "<title>")
+ DIR=$(./.agents/skills/agent-testing/scripts/report-init.sh --subject topic:tpc_xxx < slug > "<title>")
```
The script creates the directory, pre-fills branch / commit / date in both
diff --git a/.agents/skills/agent-testing/scripts/fixture.mjs b/.agents/skills/agent-testing/scripts/fixture.mjs
new file mode 100755
index 00000000000..0160e1f9671
--- /dev/null
+++ b/.agents/skills/agent-testing/scripts/fixture.mjs
@@ -0,0 +1,200 @@
+#!/usr/bin/env node
+/**
+ * fixture.mjs โ€” reusable per-check fixture assets for agent-testing.
+ *
+ * Fixtures are the durable half of a verification: for each CHECK ITEM (the
+ * business check that recurs across acceptance rounds) we keep one directory
+ * holding its plan fragment, case template, seed inputs, and (optionally)
+ * replayable steps. Rounds are then COMPOSED from checks instead of hand-writing
+ * a fresh result.json every time.
+ *
+ * INPUTS vs OUTPUTS โ€” only inputs are reusable. `seed/` holds what a run
+ * CONSUMES (files to upload, DB seed fragments, config, stand-in evidence for
+ * synthetic ingest rounds). What a run PRODUCES (screenshots, transcripts) is
+ * tied to that one execution and lives only in the round dir's assets/ under
+ * .records/reports/ โ€” never copy it back into the fixture.
+ *
+ * Layout (gitignored, like all .records/ output):
+ * .records/fixtures/<subject-key>/<check-id>/
+ * โ”œโ”€โ”€ check.json # plan fragment + case template (+ steps for future replay)
+ * โ””โ”€โ”€ seed/ # reusable INPUT assets referenced by check.json / steps
+ *
+ * <subject-key> = task-<id> | topic-<id> | document-<id> (subject with ':'โ†’'-'),
+ * matching the report group dirs under .records/reports/.
+ *
+ * Usage:
+ * fixture.mjs init-check --subject topic:tpc_xxx <check-id>
+ * Scaffold .records/fixtures/topic-tpc_xxx/<check-id>/{check.json,seed/}
+ *
+ * fixture.mjs compose --subject topic:tpc_xxx --slug <slug> [--title "..."]
+ * [--focus "..."] [--entry "..."] <check-id> [<check-id>...]
+ * Assemble a report-shaped round dir from the given checks:
+ * .records/reports/topic-tpc_xxx/<ts>-<slug>/ (ready for
+ * `lh verify ingest-report <dir>`). Files referenced by case.evidence
+ * (seed/โ€ฆ) are copied into the round's assets/<check-id>/ and paths
+ * rewritten. Prints the dir path.
+ *
+ * fixture.mjs list --subject topic:tpc_xxx
+ * List the subject's check fixtures.
+ */
+import { execFileSync } from 'node:child_process';
+import { cpSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { basename, dirname, join, resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+// Anchor to the checkout being TESTED (cwd's git toplevel โ€” correct when the
+// main checkout's script is invoked inside a worktree), not the script's own
+// checkout; fall back to script-relative outside any repo.
+const repoRoot = () => {
+ try {
+ return execFileSync('git', ['rev-parse', '--show-toplevel'], { encoding: 'utf8' }).trim();
+ } catch {
+ return resolve(dirname(fileURLToPath(import.meta.url)), '../../../..');
+ }
+};
+const REPO_ROOT = repoRoot();
+
+const fail = (msg) => {
+ console.error(`fixture.mjs: ${msg}`);
+ process.exit(1);
+};
+
+const parseArgs = (argv) => {
+ const opts = {};
+ const positional = [];
+ for (let i = 0; i < argv.length; i++) {
+ const arg = argv[i];
+ if (arg.startsWith('--')) {
+ opts[arg.slice(2)] = argv[++i];
+ } else {
+ positional.push(arg);
+ }
+ }
+ return { opts, positional };
+};
+
+const subjectKey = (subject) => {
+ if (!/^(?:task|topic|document):.+$/.test(subject || '')) {
+ fail(`--subject must be task:<id> | topic:<id> | document:<id>, got '${subject}'`);
+ }
+ return subject.replace(':', '-');
+};
+
+const [command, ...rest] = process.argv.slice(2);
+const { opts, positional } = parseArgs(rest);
+
+if (command === 'init-check') {
+ const key = subjectKey(opts.subject);
+ const checkId = positional[0] || fail('init-check needs a <check-id>');
+ const dir = join(REPO_ROOT, '.records/fixtures', key, checkId);
+ if (existsSync(join(dir, 'check.json'))) fail(`${dir}/check.json already exists`);
+ mkdirSync(join(dir, 'seed'), { recursive: true });
+ const template = {
+ id: checkId,
+ category: '',
+ title: '',
+ verifier: 'agent',
+ method: '',
+ expected: '',
+ requiredEvidence: [],
+ // Case template used by `compose`: the default verdict + observation this
+ // fixture reproduces. Evidence paths point at reusable INPUTS under seed/
+ // (relative to this check dir) โ€” real execution outputs stay in the round.
+ case: { result: 'passed', observation: '', evidence: [] },
+ // Reserved for the JSON-replay runner: deterministic steps that set up and
+ // verify this check without an agent improvising them each round.
+ steps: [],
+ notes: '',
+ };
+ writeFileSync(join(dir, 'check.json'), JSON.stringify(template, null, 2) + '\n');
+ console.log(dir);
+} else if (command === 'list') {
+ const key = subjectKey(opts.subject);
+ const root = join(REPO_ROOT, '.records/fixtures', key);
+ if (!existsSync(root)) fail(`no fixtures under ${root}`);
+ for (const entry of readdirSync(root, { withFileTypes: true })) {
+ if (!entry.isDirectory()) continue;
+ const checkFile = join(root, entry.name, 'check.json');
+ if (!existsSync(checkFile)) continue;
+ const check = JSON.parse(readFileSync(checkFile, 'utf8'));
+ console.log(`${entry.name}\t[${check.category}] ${check.title} โ†’ ${check.case?.result}`);
+ }
+} else if (command === 'compose') {
+ const key = subjectKey(opts.subject);
+ const slug = opts.slug || fail('compose needs --slug');
+ if (positional.length === 0) fail('compose needs at least one <check-id>');
+
+ const fixturesRoot = join(REPO_ROOT, '.records/fixtures', key);
+ const now = new Date();
+ const pad = (n) => String(n).padStart(2, '0');
+ const ts = `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
+ const dir = join(REPO_ROOT, '.records/reports', key, `${ts}-${slug}`);
+ mkdirSync(join(dir, 'assets'), { recursive: true });
+
+ const plan = [];
+ const cases = [];
+ for (const checkId of positional) {
+ const checkDir = join(fixturesRoot, checkId);
+ const checkFile = join(checkDir, 'check.json');
+ if (!existsSync(checkFile)) fail(`missing ${checkFile} (run init-check first)`);
+ const check = JSON.parse(readFileSync(checkFile, 'utf8'));
+
+ plan.push({
+ id: check.id,
+ category: check.category,
+ title: check.title,
+ verifier: check.verifier || 'agent',
+ method: check.method,
+ expected: check.expected,
+ ...(check.requiredEvidence?.length ? { requiredEvidence: check.requiredEvidence } : {}),
+ });
+
+ const evidenceList = [check.case?.evidence ?? []].flat();
+ const evidence = evidenceList.map((entry) => {
+ const src = typeof entry === 'string' ? entry : entry.path;
+ const target = join('assets', check.id, basename(src));
+ mkdirSync(join(dir, 'assets', check.id), { recursive: true });
+ cpSync(join(checkDir, src), join(dir, target));
+ return typeof entry === 'string' ? target : { ...entry, path: target };
+ });
+
+ cases.push({
+ id: check.id,
+ name: check.title,
+ result: check.case?.result ?? 'passed',
+ observation: check.case?.observation ?? '',
+ ...(evidence.length ? { evidence: evidence.length === 1 ? evidence[0] : evidence } : {}),
+ });
+ }
+
+ const passed = cases.filter((c) => c.result === 'passed').length;
+ const failed = cases.filter((c) => c.result === 'failed').length;
+ const blocked = cases.filter((c) => c.result === 'blocked').length;
+ const result = {
+ title: opts.title || slug,
+ scenario: 'coding',
+ subject: opts.subject,
+ context: {
+ focus: opts.focus || '',
+ entry: opts.entry || '',
+ branch: '',
+ commit: '',
+ },
+ surfaces: ['web'],
+ plan,
+ cases,
+ summary: {
+ total: cases.length,
+ passed,
+ failed,
+ blocked,
+ verdict: failed > 0 ? 'fail' : 'pass',
+ conclusion: opts.conclusion || `${passed}/${cases.length} ้€š่ฟ‡`,
+ },
+ };
+ writeFileSync(join(dir, 'result.json'), JSON.stringify(result, null, 2) + '\n');
+ writeFileSync(join(dir, 'report.md'), `${opts.title || slug}\n`);
+ console.log(dir);
+} else {
+ fail(`unknown command '${command}' (init-check | compose | list)`);
+}
diff --git a/.agents/skills/agent-testing/scripts/report-init.sh b/.agents/skills/agent-testing/scripts/report-init.sh
index e64eba26dad..d45a9f40626 100755
--- a/.agents/skills/agent-testing/scripts/report-init.sh
+++ b/.agents/skills/agent-testing/scripts/report-init.sh
@@ -4,25 +4,84 @@
# Format spec and evidence rules: ../references/report.md
#
# Usage:
-# report-init.sh <slug> [title]
+# report-init.sh [--subject <type:id>] <slug> [title]
+#
+# With --subject (task:<id> | topic:<id> | document:<id>) the run is grouped
+# under its acceptance:
+# .records/reports/<type>-<id>/<YYYYMMDD-HHMMSS>-<slug>/
+# and the group dir gets an acceptance.json marker (created once, updatedAt
+# bumped per run). The subject is also pre-filled into result.json so
+# `lh verify ingest-report` attaches the run without an explicit --subject.
+#
+# Without --subject the legacy flat layout is used:
+# .records/reports/<YYYYMMDD-HHMMSS>-<slug>/
+# Every run ultimately needs a subject at ingest time โ€” prefer passing it here.
#
# Prints the report directory path (capture it: DIR=$(report-init.sh my-test)).
set -euo pipefail
-SLUG="${1:?Usage: report-init.sh <slug> [title]}"
+SUBJECT=""
+if [[ "${1:-}" == "--subject" ]]; then
+ SUBJECT="${2:?--subject requires a value like topic:tpc_xxx}"
+ shift 2
+fi
+
+SLUG="${1:?Usage: report-init.sh [--subject <type:id>] <slug> [title]}"
TITLE="${2:-$SLUG}"
-REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd)"
+# Anchor to the checkout being TESTED (cwd's git toplevel โ€” correct when the
+# main checkout's script is invoked inside a worktree); fall back to the
+# script's own checkout outside any repo.
+REPO_ROOT="$(git rev-parse --show-toplevel 2> /dev/null || { cd "$(dirname "${BASH_SOURCE[0]}")/../../../.." && pwd; })"
TS="$(date +%Y%m%d-%H%M%S)"
-DIR="$REPO_ROOT/.records/reports/$TS-$SLUG"
+
+SUBJECT_JSON="null"
+if [[ -n "$SUBJECT" ]]; then
+ if [[ ! "$SUBJECT" =~ ^(task|topic|document):.+$ ]]; then
+ echo "report-init.sh: --subject must be task:<id> | topic:<id> | document:<id>, got '$SUBJECT'" >&2
+ exit 1
+ fi
+ SUBJECT_KEY="${SUBJECT/:/-}"
+ GROUP_DIR="$REPO_ROOT/.records/reports/$SUBJECT_KEY"
+ DIR="$GROUP_DIR/$TS-$SLUG"
+ SUBJECT_JSON="\"$SUBJECT\""
+else
+ DIR="$REPO_ROOT/.records/reports/$TS-$SLUG"
+fi
mkdir -p "$DIR/assets"
BRANCH=$(git -C "$REPO_ROOT" branch --show-current 2> /dev/null || echo "unknown")
COMMIT=$(git -C "$REPO_ROOT" rev-parse --short HEAD 2> /dev/null || echo "unknown")
-DATE_HUMAN=$(date '+%Y-%m-%d %H:%M')
DATE_ISO=$(date '+%Y-%m-%dT%H:%M:%S%z')
+# acceptance.json marks the group dir: what acceptance these runs belong to.
+# Created on the first run; only updatedAt/lastRun move afterwards (the title
+# from the first scaffold wins โ€” it names the acceptance, not the round).
+if [[ -n "$SUBJECT" ]]; then
+ ACCEPTANCE_JSON="$GROUP_DIR/acceptance.json"
+ if [[ ! -f "$ACCEPTANCE_JSON" ]]; then
+ cat > "$ACCEPTANCE_JSON" << EOF
+{
+ "subject": "$SUBJECT",
+ "title": "$TITLE",
+ "createdAt": "$DATE_ISO",
+ "updatedAt": "$DATE_ISO",
+ "lastRun": "$TS-$SLUG"
+}
+EOF
+ else
+ node -e '
+ const fs = require("fs");
+ const [file, ts, iso] = process.argv.slice(1);
+ const data = JSON.parse(fs.readFileSync(file, "utf8"));
+ data.updatedAt = iso;
+ data.lastRun = ts;
+ fs.writeFileSync(file, JSON.stringify(data, null, 2) + "\n");
+ ' "$ACCEPTANCE_JSON" "$TS-$SLUG" "$DATE_ISO"
+ fi
+fi
+
# report.md is rendered as the verify page's "Details" tail โ€” free-form COMMENT.
# The scope (่Œƒๅ›ด), per-case table (็”จไพ‹), overall conclusion, and the score are
# all STRUCTURED on the page now (result.json scenario/context + cases +
@@ -55,6 +114,7 @@ cat > "$DIR/result.json" << EOF
"title": "$TITLE",
"scenario": "coding",
"createdAt": "$DATE_ISO",
+ "subject": $SUBJECT_JSON,
"branch": "$BRANCH",
"commit": "$COMMIT",
"surfaces": [],
diff --git a/apps/cli/man/man1/lh.1 b/apps/cli/man/man1/lh.1
index b1f67c89dcb..0ef0f401991 100644
--- a/apps/cli/man/man1/lh.1
+++ b/apps/cli/man/man1/lh.1
@@ -1,6 +1,6 @@
.\" Code generated by `npm run man:generate`; DO NOT EDIT.
.\" Manual command details come from the Commander command tree.
-.TH LH 1 "" "@lobehub/cli 0.0.43" "User Commands"
+.TH LH 1 "" "@lobehub/cli 0.0.44" "User Commands"
.SH NAME
lh \- LobeHub CLI \- manage and connect to LobeHub services
.SH SYNOPSIS
diff --git a/apps/cli/package.json b/apps/cli/package.json
index 0163bbe6d26..bb3844e9b8c 100644
--- a/apps/cli/package.json
+++ b/apps/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@lobehub/cli",
- "version": "0.0.43",
+ "version": "0.0.44",
"type": "module",
"bin": {
"lh": "./dist/index.js",