@cultured_computer/sight 0.10.3 → 0.10.5

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/CHANGELOG.md CHANGED
@@ -5,6 +5,43 @@ reconstructed from the repository: the `sdk-v*` release tags (dates are tag
5
5
  dates) and the commits between them. Where the history does not say what a
6
6
  version changed for SDK users, the entry says "see git history".
7
7
 
8
+ ## 0.10.5 (2026-12-02)
9
+
10
+ - `sight character show <comparison.json>` prints a trial as one Markdown
11
+ page: the scene change, then for every turn the person's message, the kept
12
+ reply, the candidate reply, each statement's reading on both sides, the
13
+ blocks that were on and the checks that did not pass. Raw text is escaped
14
+ for GitHub and Deepnote, so a trial can be reviewed as a pull request.
15
+ Both `runs/comparisons/` and the documented manual `comparisons/` path find
16
+ their run evidence. Missing evidence says `not recorded`, distinct from a
17
+ recorded empty list; categorical and boolean reads need no numeric fields;
18
+ and zero-turn attempts are not counted as turns.
19
+ - `sight character show <run-dir>` prints the person's message above each
20
+ reply and lists turns in the order of the situations file, then numerically
21
+ by repeat and turn index. The `attempts` in `--json` follow the same order.
22
+ - `sight --version` prints the package version.
23
+
24
+ ## 0.10.4 (2026-12-02)
25
+
26
+ - `sight character trial` validates before any reply is made: a
27
+ `checks.json` that does not parse, or names a situation or turn that does
28
+ not exist, is refused, and the service is asked about the candidate scene
29
+ (a dry-run save) before the kept version runs again.
30
+ - Run settings live in `workbench.json` under `execution` and a flag
31
+ overrides one run: `model`, `temperature`, `maxOutputTokens`,
32
+ `reasoningEffort`, `fallback`, `reader`, `repeats`, `modelSeed`,
33
+ `moveSeed`. `init` writes `repeats`, `modelSeed` and `moveSeed` as 1 and
34
+ takes `--designer <id>[,<id>]`. A setting that does not read is refused
35
+ as `invalid_workbench`.
36
+ - `sight character show <run-dir>` prints, under each reply, every read
37
+ (score over bar, before or after the reply, met, unmet or no reading) and
38
+ the blocks that were on and off. `--json` adds `readTotals`.
39
+ - A run warns once, on stderr and in its manifest, when the model was not
40
+ sent the requested temperature or seed.
41
+ - Planning the same run again leaves `plan.json` byte-identical.
42
+ - The generated `SKILL.md` is a shorter command reference with one example
43
+ of each check kind.
44
+
8
45
  ## 0.10.3 (2026-12-02)
9
46
 
10
47
  - New `sight character` lab authoring loop: initialize, check, preflight,
package/README.md CHANGED
@@ -244,6 +244,7 @@ environment variables. Secrets are read from the environment, never from a flag.
244
244
  | `sight account create` | Redeems a one-time token and saves the key to `~/.config/sight/machine.json` (mode `0600`) | `SIGHT_PROVISION_TOKEN` |
245
245
  | `sight openrouter connect --budget <usd> [--house-trial]` | Connects your OpenRouter key (`OPENROUTER_API_KEY`) to the project; `--house-trial` marks it as the operator's key for a demo | A key with `providers:write` |
246
246
  | `sight openrouter status` | Prints the stored connection: status, last four characters, budget | A key with `studio:run` or `providers:write` |
247
+ | `sight character <verb>` | Builds one character by hand on two lab profiles: `init`, `check`, `trial`, `show`, `note`, `keep`, `revert`. See [The character loop](https://sight.cultured.computer/docs/cli#the-character-loop) | A lab key with `profiles:write` |
247
248
  | `sight connect <relay-url> --invite <code>` | See [Connect your room](https://sight.cultured.computer/docs/connect-your-room) | An invite code |
248
249
 
249
250
  Every flag: [CLI](https://sight.cultured.computer/docs/cli).
package/dist/cli.js CHANGED
@@ -370,9 +370,9 @@ async function sendImport(plan, options, deps) {
370
370
  }
371
371
 
372
372
  // src/character/index.ts
373
- import { existsSync as existsSync2, readdirSync, readFileSync } from "fs";
373
+ import { existsSync as existsSync2, readdirSync, readFileSync, statSync } from "fs";
374
374
  import { homedir } from "os";
375
- import { dirname as dirname5, isAbsolute, join as join8, relative } from "path";
375
+ import { dirname as dirname5, isAbsolute, join as join8, relative, resolve } from "path";
376
376
 
377
377
  // src/field.ts
378
378
  var DEFAULT_FIELD_ENDPOINT = "https://api.cultured.computer";
@@ -1126,7 +1126,7 @@ async function locked(filePath, operation, timeoutMs) {
1126
1126
  if (Date.now() >= deadline) {
1127
1127
  throw new CharacterAnnotationError("locked", `annotation file is locked: ${filePath}`, { cause: error });
1128
1128
  }
1129
- await new Promise((resolve) => setTimeout(resolve, 25));
1129
+ await new Promise((resolve2) => setTimeout(resolve2, 25));
1130
1130
  }
1131
1131
  }
1132
1132
  try {
@@ -2181,7 +2181,7 @@ async function withFileLocks(paths, operation) {
2181
2181
  if (!object3(error) || error["code"] !== "EEXIST") throw error;
2182
2182
  if (await removeLockOfDeadProcess(lockPath)) continue;
2183
2183
  if (Date.now() >= deadline) throw new CharacterDecisionError("locked", `evidence file is locked: ${path}`, { cause: error });
2184
- await new Promise((resolve) => setTimeout(resolve, 25));
2184
+ await new Promise((resolve2) => setTimeout(resolve2, 25));
2185
2185
  }
2186
2186
  }
2187
2187
  await handle.close();
@@ -2585,7 +2585,7 @@ function defaultNow() {
2585
2585
  return /* @__PURE__ */ new Date();
2586
2586
  }
2587
2587
  async function defaultSleep(milliseconds) {
2588
- await new Promise((resolve) => setTimeout(resolve, milliseconds));
2588
+ await new Promise((resolve2) => setTimeout(resolve2, milliseconds));
2589
2589
  }
2590
2590
  function parseJson(raw, label) {
2591
2591
  try {
@@ -3099,6 +3099,21 @@ function assertSessionPins(context, attempt, session, throughTurn, captures) {
3099
3099
  }
3100
3100
  }
3101
3101
  }
3102
+ function warnUnsentSettings(context, attempt, captures) {
3103
+ const add = (warning) => {
3104
+ if (!context.warnings.includes(warning)) context.warnings.push(warning);
3105
+ };
3106
+ for (const capture of captures) {
3107
+ const original = capture ? runFrame(capture.frames) : null;
3108
+ if (!original) continue;
3109
+ if (original["temperature"] === null) {
3110
+ add(`temperature ${context.spec.configuration.runtime.temperature} was not sent: ${context.spec.configuration.runtime.model} takes no temperature`);
3111
+ }
3112
+ if (original["seed"] === null && seedForAttempt(context.spec.modelSeed, attempt.repeat) !== void 0) {
3113
+ add(`the model seed was not sent: ${context.spec.configuration.runtime.model} takes no seed`);
3114
+ }
3115
+ }
3116
+ }
3102
3117
  function pendingProjectionTurn(session, throughTurn) {
3103
3118
  if (!Array.isArray(session.turns)) return null;
3104
3119
  for (let index = 0; index <= throughTurn; index += 1) {
@@ -3119,6 +3134,7 @@ async function projectSession(context, attempt, throughTurn) {
3119
3134
  const pending = pendingProjectionTurn(session, throughTurn);
3120
3135
  if (pending === null) {
3121
3136
  assertSessionPins(context, attempt, session, throughTurn, captures);
3137
+ warnUnsentSettings(context, attempt, captures);
3122
3138
  await writeMember(context, sessionPath(attempt.attemptId), session);
3123
3139
  attempt.status = "running";
3124
3140
  attempt.reason = void 0;
@@ -3968,187 +3984,185 @@ function skillDocument(humanAnnotatorIds2, candidate) {
3968
3984
  const designers = humanAnnotatorIds2.map((id) => `\`${id}\``).join(", ");
3969
3985
  return `# Character workbench
3970
3986
 
3971
- This directory holds one canonical character document, \`character.scene.json\`.
3972
- Its readable views and diffs are generated; do not turn them into another
3973
- source of truth.
3974
-
3975
- ## The headless loop
3976
-
3977
- Run these commands from the workbench directory. Every \`--json\` answer is one
3978
- noninteractive envelope. Use the real Sight command; do not replace it with a
3979
- private runtime or a model judge.
3987
+ One character lives in \`character.scene.json\`. Run every command from this
3988
+ directory with the real \`sight\` command. \`--json\` answers one line,
3989
+ \`{"ok":true,"result":...}\` or \`{"ok":false,"error":{"code","message","details"}}\`
3990
+ with exit 1. Progress and warnings go to stderr.
3980
3991
 
3981
3992
  The configured human designers are ${designers}. Examples use \`${designer}\` as
3982
3993
  the actor; use another configured id when that person is the actual designer.
3983
3994
 
3984
- 1. Show, diff and authoritatively dry-run the complete scene:
3995
+ ## The loop
3985
3996
 
3986
- - \`sight character show character.scene.json --json\`
3987
- - \`sight character show runs/<run-id> --situation ordinary-hello --repeat 1 --turn 0 --json\`
3988
- - \`sight character diff runs/<parent-run-id>/scene.json character.scene.json --json\`
3989
- - \`sight character check character.scene.json --profile ${candidate} --json\` stores nothing.
3990
-
3991
- Run evidence show returns the raw capture and normalized reply, reads, block
3992
- verdicts, state and transitions. A selected missing turn is shown as missing,
3993
- never as a pass, fail or zero.
3997
+ 1. Run the first trial before any edit. The scene as it stands becomes the
3998
+ kept version, and both sides run the same scene, which shows how much the
3999
+ model varies on its own.
3994
4000
 
3995
- 2. Preflight, then freeze exact scene and situation bytes into evidence:
4001
+ \`sight character trial --actor ${designer} --reason "Baseline, same scene on both sides." --json\`
3996
4002
 
3997
- - \`sight character preflight character.scene.json --situations situations/climb.json --profile ${candidate} --runs runs --json\`
3998
- - \`sight character run character.scene.json --situations situations/climb.json --profile ${candidate} --runs runs --json\`
3999
- - \`sight character run character.scene.json --situations situations/climb.json --profile ${candidate} --dry-run --json\`
4003
+ 2. Change one thing in \`character.scene.json\`. Look at it, then ask the
4004
+ service whether it reads (nothing is stored):
4000
4005
 
4001
- Preflight and \`run --dry-run\` make no PUT or provider call and need no
4002
- credential. Every run writes \`plan.json\` and prints planned conversations,
4003
- turns and model-call floor to stderr before any PUT or provider call. The
4004
- run freezes the scene, situations, effective configuration, stable
4005
- conversation identities and per-turn request ids. \`--repeats\`,
4006
- \`--model-seed\` and \`--move-seed\` are explicit. Warning thresholds only
4007
- warn. Only \`--stop-after-conversations\` or \`--stop-after-turns\` stops a
4008
- planned run early. An explicit stop closes the fully captured conversation,
4009
- leaves the run incomplete and exits nonzero. Confirmation situations are
4010
- refused before client work.
4011
- Failed, unknown, incomplete, service-limited, configuration-changed and
4012
- evidence-incomplete outcomes exit nonzero with stable error codes. A new run
4013
- refuses an unfinished profile session before its PUT. The configured API host
4014
- is frozen into run identity and lock scope. Turn receipts are stored locally
4015
- without provider-attempt hydration or sealed evidence export.
4016
-
4017
- 3. If a run is incomplete, inspect its manifest and resume the same directory:
4006
+ - \`sight character show character.scene.json --json\`
4007
+ - \`sight character diff runs/<parent-run-id>/scene.json character.scene.json --json\`
4008
+ - \`sight character check character.scene.json --profile ${candidate} --json\`
4018
4009
 
4019
- \`sight character resume runs/<run-id> --json\`
4010
+ 3. Plan the trial, then run it:
4020
4011
 
4021
- Resume first refuses torn or uncertain local evidence. It recovers the exact
4022
- identified receipt before any new admission and rechecks the live profile
4023
- configuration. Unknown or missing evidence is never a pass, fail or zero.
4012
+ - \`sight character trial --dry-run --json\`
4013
+ - \`sight character trial --actor ${designer} --reason "Review the raw evidence together." --json\`
4024
4014
 
4025
- 4. Compare the raw evidence and store it with deterministic code annotations:
4015
+ The kept version is read from disk. It runs again only when the situations
4016
+ or the run settings changed, or its evidence is not on this machine;
4017
+ \`parentRunReasons\` and stderr say which. The actor, \`checks.json\` and the
4018
+ candidate scene are validated before any reply is made.
4026
4019
 
4027
- \`sight character compare runs/<parent-run-id> runs/<candidate-run-id> --checks checks.json --notes annotations/notes.jsonl --out comparisons/by-hand.json --json\`
4020
+ 4. Read the trial. The first command prints one Markdown page with the scene
4021
+ change and, for every turn, the person's message and both replies; save it
4022
+ as \`reviews/<name>.md\` for the designer to read:
4028
4023
 
4029
- The comparison shows reads, block verdicts, state, transitions and replies
4030
- side by side. It has no winner, aggregate character score or automatic keep.
4031
- A first divergence is withheld across an earlier evidence gap. The comparison
4032
- file and each run's \`annotations/checks.jsonl\` are written atomically;
4033
- repeating the same comparison is idempotent and conflicting ids are refused.
4024
+ - \`sight character show <comparison-path>\`
4025
+ - \`sight character show runs/<candidate-run-id>\`
4026
+ - \`sight character show runs/<run-id> --situation ordinary-hello --repeat 1 --turn 0 --json\`
4034
4027
 
4035
- 5. Add and read typed human or agent notes:
4028
+ 5. Write what you saw, then decide:
4036
4029
 
4037
- - \`sight character note run:<candidate-run-id> --run runs/<candidate-run-id> --actor ${designer} --text "I reviewed the candidate run evidence and support this voice change." --tags behavioral,voice,uptake --json\`
4030
+ - \`sight character note run:<candidate-run-id> --run runs/<candidate-run-id> --actor ${designer} --text "I reviewed the candidate run evidence and support this voice change." --tags behavioral,voice --json\`
4038
4031
  - \`sight character notes --target run:<candidate-run-id> --json\`
4039
-
4040
- Run, turn and block notes bind to the exact stored evidence digest. This
4041
- run-scoped human note is the example to cite by id in the behavioral keep.
4042
- Supported targets are turn, conversation, run, version, block, situation,
4043
- note and decision. Agent notes require \`--agent\` and are marked as model
4044
- annotations, not human judgments. Without \`--agent\` the actor must be one
4045
- of the configured human designers; any other id is refused. Corrections use
4046
- \`--replaces <note-id>\`. \`notes\` also returns a supervision count: notes and
4047
- decisions by the configured designers only, a corrected note counted once,
4048
- a repeated decision counted once.
4049
-
4050
- 6. Execute a trial, then choose the next local working parent:
4051
-
4052
- - \`sight character trial --actor ${designer} --reason "Review the raw evidence together." --json\`
4053
- - \`sight character trial --dry-run --json\`
4054
4032
  - \`sight character keep <comparison-path> --actor ${designer} --mode behavioral --reason "Keep this voice change." --note <designer-note-id> --json\`
4055
4033
  - \`sight character revert <comparison-path> --actor ${designer} --mode mechanical --reason "Leave the current parent in place." --json\`
4056
4034
 
4057
4035
  \`<comparison-path>\` is \`comparison.path\` in the trial's answer, under
4058
4036
  \`runs/comparisons/\`.
4059
4037
 
4060
- Run the first trial before editing \`character.scene.json\`, so the scene as
4061
- it stands becomes the parent; or pass \`--parent-scene <file>\` to name the
4062
- parent yourself. Change one thing per trial.
4038
+ - Keep makes the candidate the kept version. It copies the
4039
+ kept scene to \`character.scene.json\` only when that file still holds
4040
+ the parent's text or is missing.
4041
+ - Revert leaves the kept version as it is and puts
4042
+ the parent's text back into \`character.scene.json\` when the file still
4043
+ holds exactly the rejected candidate. The rejected scene stays in
4044
+ \`runs/<candidate-run-id>/scene.json\`.
4045
+ - A file edited since the trial is left alone both times; \`scene.action\`
4046
+ in the answer says what happened.
4047
+ - Without \`--agent\` the actor must be one of the configured human designers.
4048
+ Correct a note with \`--replaces <note-id>\`.
4049
+
4050
+ ## Reading a run
4051
+
4052
+ \`show runs/<run-id>\` prints each turn like this:
4053
+
4054
+ \`\`\`text
4055
+ ordinary-hello/1/0: walking
4056
+ > <the person's message>
4057
+ <the reply>
4058
+ read before 0.9/0.5 met <statement>
4059
+ read after - no reading <statement>
4060
+ on: character-floor, hard-day
4061
+ off: next-step
4062
+ \`\`\`
4063
+
4064
+ - \`read\`: score over bar, and whether the statement was read before or after
4065
+ the reply. Categorical and boolean reads show \`met\` or \`unmet\` without a
4066
+ score. A statement read after the reply acts on the next turn.
4067
+ - \`no reading\`: the reader returned no number. The block stays off and a
4068
+ check on that statement is \`unmeasured\`, never a pass.
4069
+ - \`not recorded\` means reads or blocks were not captured; \`none\` means the
4070
+ captured list is empty. They are different evidence.
4071
+ - \`on\` and \`off\` are block ids. A statement scheduled \`once\` keeps its block
4072
+ on after it is met.
4073
+ - A live model varies between two runs of the same scene, so a comparison's
4074
+ \`firstDivergence\` is always the first turn. Read the rows.
4075
+ - One sample cannot rank two versions. For a question about behaviour set
4076
+ \`execution.repeats\` to 3 or more and keep it there.
4077
+ - Write one behaviour per statement. A statement that scores near its bar on
4078
+ unrelated messages needs rewording.
4079
+
4080
+ ## Run settings
4081
+
4082
+ Set in \`workbench.json\` under \`execution\`; the flag of the same name
4083
+ overrides one run. Changing any of them makes the next trial run the kept
4084
+ version again with the same settings.
4063
4085
 
4064
- Trial checks the actor, mode and reason, then plans both sides before any
4065
- call. It reuses the kept version's stored evidence when that evidence is on
4066
- this machine and was made with the same situations and the same run settings
4067
- (repeats, model, temperature, reader, endpoint, seeds, stop). Otherwise it
4068
- runs the parent again from the kept run's frozen \`scene.json\` and says why
4069
- in \`parentRunReasons\` and on stderr. It then runs or resumes the candidate,
4070
- compares them and only then records a decision. \`trial --dry-run\` stops
4071
- after the plans. Decisions cite comparison evidence, parent, candidate,
4072
- alternatives, actor, reason and note ids.
4086
+ | \`execution\` key | Flag | What it sets |
4087
+ | --- | --- | --- |
4088
+ | \`model\` | \`--model\` | The reply model, as \`vendor/model\` |
4089
+ | \`temperature\` | \`--temperature\` | Not sent to a model that takes none; the run warns |
4090
+ | \`maxOutputTokens\` | \`--max-output-tokens\` | The reply's output limit |
4091
+ | \`reasoningEffort\` | \`--reasoning-effort\` | ${FIELD_REASONING_EFFORTS.join(", ")} |
4092
+ | \`fallback\` | \`--fallback\` | A second model when the first fails |
4093
+ | \`reader\` | \`--reader-model\` | The model that reads detector statements |
4094
+ | \`repeats\` | \`--repeats\` | Conversations per situation |
4095
+ | \`modelSeed\` | \`--model-seed\` | The reply seed; not sent to a model that takes none |
4096
+ | \`moveSeed\` | \`--move-seed\` | The seed for sampled examples |
4073
4097
 
4074
- Keep points \`workbench.workingParent\` at the candidate run. It copies the
4075
- kept scene to \`character.scene.json\` only when that file still holds the
4076
- parent's text or is missing; a file edited since the trial is left as it is
4077
- and the answer says so. Revert leaves the working parent unchanged and puts
4078
- the parent's text back into \`character.scene.json\` when the file still
4079
- holds exactly the rejected candidate; a file edited since is left as it is.
4080
- The rejected scene stays in \`runs/<candidate-run-id>/scene.json\`. Both
4081
- answers carry \`scene.action\`. Neither moves a remote profile pointer or
4082
- changes a deployment.
4098
+ \`warnAt\` counts only warn. \`--stop-after-conversations\` and
4099
+ \`--stop-after-turns\` stop a run early, and \`resume\` cannot finish a run
4100
+ stopped that way.
4083
4101
 
4084
- The generated \`.gitignore\` keeps each run's \`manifest.json\` and
4085
- \`scene.json\` in git and leaves the rest of the evidence local. In a fresh
4086
- clone a trial therefore runs the kept version again before comparing. A
4087
- run directory that came from another machine is never written over: the
4088
- same run made here is recorded beside it with the replicate id
4089
- \`rerun-of-<run-id>\`.
4102
+ ## Checks
4090
4103
 
4091
- 7. Optionally generate an always-on scene control on demand:
4104
+ \`checks.json\` is optional. Each check names a situation and a turn and gives
4105
+ \`pass\`, \`fail\` or \`unmeasured\`. One of each kind:
4092
4106
 
4093
- \`sight character controls scene character.scene.json --out comparisons/scene-controls.json --scene-out comparisons/always-on.scene.json --json\`
4107
+ \`\`\`json
4108
+ {
4109
+ "format": "${CHECK_SET_FORMAT}",
4110
+ "checks": [
4111
+ { "id": "starts-listening", "situation": "ordinary-hello", "turn": 0, "kind": "step", "step": "listening" },
4112
+ { "id": "floor-on", "situation": "ordinary-hello", "turn": 0, "kind": "block", "blockId": "character-floor", "entered": true },
4113
+ { "id": "hard-day-clean", "situation": "ordinary-hello", "turn": 0, "kind": "sentence", "sentence": "<statement or read id>", "flagged": false },
4114
+ { "id": "still-listening", "situation": "ordinary-hello", "turn": 1, "kind": "state", "name": "moment", "value": "listening" }
4115
+ ]
4116
+ }
4117
+ \`\`\`
4094
4118
 
4095
- This local generator writes a second scene in which authored text that sits
4096
- behind a detector condition or a step condition is always on, with the same
4097
- words. \`--scene-out\` writes that scene alone. Run it as the candidate of a
4098
- trial (\`sight character trial comparisons/always-on.scene.json ...\`) or with
4099
- \`run\`, on the same situations, to see whether a change comes from the
4100
- condition or only from the words; then revert, so it never becomes the
4101
- working parent. Text it cannot move honestly is refused with the block named:
4102
- \`moves\` blocks, interpolated values, blocks with several conditions or
4103
- another condition kind, and conditional text that also sets state. The
4104
- generator runs no model, compares nothing and chooses no winner. Writing
4105
- the same file twice is a no-op.
4119
+ ## Single runs and the always-on scene
4106
4120
 
4107
- ## Files and contracts
4121
+ - \`sight character preflight character.scene.json --situations situations/climb.json --profile ${candidate} --runs runs --json\`
4122
+ - \`sight character run character.scene.json --situations situations/climb.json --profile ${candidate} --runs runs --json\`
4123
+ - \`sight character resume runs/<run-id> --json\` finishes an interrupted run without repeating a turn already made.
4124
+ - \`sight character compare runs/<parent-run-id> runs/<candidate-run-id> --checks checks.json --notes annotations/notes.jsonl --out comparisons/by-hand.json --json\`
4125
+ - \`sight character show comparisons/by-hand.json\` reads that manual comparison with its run evidence under \`runs/\`.
4126
+ - \`sight character controls scene character.scene.json --out comparisons/scene-controls.json --scene-out comparisons/always-on.scene.json --json\`
4108
4127
 
4109
- \`situations/climb.json\` is \`character-situations/v0.1\`. Each situation keeps
4110
- the \`moment-trace/v2\` shape and adds a stable id, family, split, provenance
4111
- and free tags. \`opening\` is constructed dialogue history only: it replays no
4112
- detector reads, clocks, latches or state transitions. Every line in \`served\`
4113
- goes through the real engine in order. Put state-establishing prefixes in
4114
- \`served\`, never in \`opening\`; \`servedPrefix\` optionally counts those leading
4115
- lines. Unknown format marks are refused.
4128
+ The always-on scene has the same words, but text behind a detector condition or a step condition is always on.
4129
+ Run it as a trial candidate (\`sight character trial comparisons/always-on.scene.json ...\`)
4130
+ to see whether a change comes from the condition or only from the words, then
4131
+ revert it. Blocks it cannot convert are refused by name.
4116
4132
 
4117
- \`checks.json\` is optional and provisional. It supports only turn-level
4118
- expectations: step, block entered or silent, sentence flagged or clean, and
4119
- state. Each check applies only to its declared situation and turn. Checks
4120
- produce pass, fail, unmeasured or errored rows, never a character score or a
4121
- keep decision. No check file executes code. Code rows carry check-set,
4122
- check-runner and comparison implementation versions.
4133
+ ## Files
4123
4134
 
4124
- Annotations are append-only JSONL records with a typed \`target\`, \`name\`,
4125
- \`annotator\`, and at least one of \`label\`, \`score\` or \`explanation\`. A
4126
- correction is a new row whose \`metadata.replaces\` names the old row. Code check
4127
- rows carry \`metadata.checkSetHash\` and \`metadata.checkRunnerVersion\`. Human
4128
- annotations come from a person; an agent writes model annotations and marks them
4129
- as such. A model judgment is not a human label.
4135
+ | File | Holds |
4136
+ | --- | --- |
4137
+ | \`workbench.json\` | Lab profiles, run settings, designers, agent permissions, the kept version |
4138
+ | \`character.scene.json\` | The working scene |
4139
+ | \`situations/climb.json\` | Scripted conversations. Every \`served\` line goes through the real engine; \`opening\` is history only |
4140
+ | \`checks.json\` | Optional expectations |
4141
+ | \`annotations/notes.jsonl\` | Notes, append only |
4142
+ | \`climb.jsonl\` | Trial, keep and revert records, append only |
4143
+ | \`runs/<run-id>/\` | One run: plan, scene, situations, turns, manifest |
4144
+ | \`runs/comparisons/\` | Comparisons written by \`trial\` |
4130
4145
 
4131
- ## Decision and credential boundaries
4146
+ The generated \`.gitignore\` commits each run's \`manifest.json\` and
4147
+ \`scene.json\` and keeps the rest local. In a fresh clone a trial runs the kept
4148
+ version again, recorded beside the original as \`rerun-of-<run-id>\`.
4132
4149
 
4133
- Use only the isolated parent and candidate lab profiles named in
4134
- \`workbench.json\`. Never target production or read production credentials from
4135
- the agent environment.
4150
+ ## Who decides
4136
4151
 
4137
- The configured human designers decide behavioral keeps and supply the cited
4138
- run-scoped human note bound to the kept run. Agent keeps and reverts are
4139
- mechanical and exploratory only. They also require complete comparison evidence
4140
- and explicit \`workbench.agent.mechanicalKeep\` or
4141
- \`workbench.agent.mechanicalRevert\` permission. An agent cannot make a behavioral
4142
- keep. No command here picks a winner or claims a validated improvement.
4152
+ - A behavioral keep is a configured human designer's, and cites that
4153
+ designer's run-scoped human note bound to the kept run.
4154
+ - An agent passes \`--agent\`. Its notes are model annotations. It may keep or
4155
+ revert only in mechanical mode, and only when \`agent.mechanicalKeep\` or
4156
+ \`agent.mechanicalRevert\` in \`workbench.json\` allows it.
4157
+ - No command picks a winner or computes a score.
4158
+ - Use only the lab profiles named in \`workbench.json\`. Never target production
4159
+ or read production credentials from the agent environment.
4160
+ - A conversation left in an unknown state blocks its profile until the
4161
+ service's idle limit.
4143
4162
 
4144
4163
  Production go-live is not an agent command. A person reviews the frozen scene,
4145
4164
  then uses the existing Field scene PUT (\`profiles.putScene\`) with a production
4146
- key and the current profile etag as \`If-Match\`. That person owns the production
4147
- write and any rollback; this workbench supplies neither a credential nor a
4148
- production deployment command.
4149
-
4150
- Service limits are reported, not treated as behavioral failures. Warning counts
4151
- in \`workbench.json\` warn only; they are not budgets and stop nothing.
4165
+ key and the current profile etag as \`If-Match\`.
4152
4166
  `;
4153
4167
  }
4154
4168
  function workbenchDocument(model, parent, candidate, parentProfile, candidateProfile, humanAnnotatorIds2) {
@@ -4162,6 +4176,9 @@ function workbenchDocument(model, parent, candidate, parentProfile, candidatePro
4162
4176
  model,
4163
4177
  temperature: parentProfile.runtime?.temperature ?? 0.7,
4164
4178
  reader: parentProfile.runtime?.readerModel ?? null,
4179
+ repeats: 1,
4180
+ modelSeed: 1,
4181
+ moveSeed: 1,
4165
4182
  replyCheck: "off",
4166
4183
  readsPosture: parentEndpoint.readsPosture,
4167
4184
  closingLine: parentEndpoint.closingLine,
@@ -4549,9 +4566,9 @@ function buildSceneControls(input) {
4549
4566
 
4550
4567
  // src/character/index.ts
4551
4568
  var CHARACTER_USAGE = [
4552
- "sight character init <dir> [--model <vendor/model>] [--parent <profile>] [--candidate <profile>] [--api <base>] [--json]",
4569
+ "sight character init <dir> [--model <vendor/model>] [--designer <id>[,<id>]] [--parent <profile>] [--candidate <profile>] [--api <base>] [--json]",
4553
4570
  "sight character check <scene.json> --profile <profile> [--if-match <etag>] [settings overrides] [--api <base>] [--json]",
4554
- "sight character show <scene.json|run-dir> [--situation <id>] [--repeat <n>] [--turn <n>] [--json]",
4571
+ "sight character show <scene.json|run-dir|comparison.json> [--situation <id>] [--repeat <n>] [--turn <n>] [--json]",
4555
4572
  "sight character diff <parent.scene.json> <working.scene.json> [--json]",
4556
4573
  "sight character run <scene.json> --situations <situations.json> --profile <profile> [--replicate-id <id>] [--dry-run] [--runs <dir>] [settings overrides] [--api <base>] [--json]",
4557
4574
  "sight character preflight <scene.json> --situations <situations.json> --profile <profile> [--replicate-id <id>] [--runs <dir>] [settings overrides] [--json]",
@@ -4559,10 +4576,14 @@ var CHARACTER_USAGE = [
4559
4576
  "sight character compare <parent-run-dir> <candidate-run-dir> [--parent-parent] [--checks <checks.json>] [--notes <notes.jsonl>] [--out <comparison.json>] [--json]",
4560
4577
  "sight character note <kind:id> --actor <id> --text <note> [--run <run-dir>] [--agent] [--json]",
4561
4578
  "sight character notes [--target <kind:id>] [--name <name>] [--tag <tag>] [--json]",
4562
- "sight character trial [scene.json] --actor <id> --reason <reason> [--parent-scene <scene.json>] [--replicate-id <id>] [--dry-run] [--json]",
4579
+ "sight character trial [scene.json] --actor <id> --reason <reason> [--parent-scene <scene.json>] [--replicate-id <id>] [--dry-run] [settings overrides] [--json]",
4563
4580
  "sight character keep <comparison.json> --actor <id> --reason <reason> [--mode behavioral|mechanical] [--note <id>] [--agent] [--json]",
4564
4581
  "sight character revert <comparison.json> --actor <id> --reason <reason> [--mode behavioral|mechanical] [--note <id>] [--agent] [--json]",
4565
- "sight character controls scene <scene.json> --out <controls.json> [--scene-out <always-on.scene.json>] [--json]"
4582
+ "sight character controls scene <scene.json> --out <controls.json> [--scene-out <always-on.scene.json>] [--json]",
4583
+ "",
4584
+ "settings overrides (run, preflight, trial); each defaults to execution.<name> in workbench.json:",
4585
+ " --model <vendor/model> --temperature <n> --max-output-tokens <n> --reasoning-effort <level> --fallback <vendor/model>",
4586
+ " --reader-model <id|null> --repeats <n> --model-seed <n> --move-seed <n>"
4566
4587
  ].join("\n");
4567
4588
  var CharacterCommandError = class extends Error {
4568
4589
  code;
@@ -4610,7 +4631,7 @@ var TRIAL_VALUE_FLAGS = [
4610
4631
  "--out"
4611
4632
  ];
4612
4633
  var VALUE_FLAGS = {
4613
- init: /* @__PURE__ */ new Set(["--api", "--model", "--parent", "--candidate"]),
4634
+ init: /* @__PURE__ */ new Set(["--api", "--model", "--parent", "--candidate", "--designer"]),
4614
4635
  check: /* @__PURE__ */ new Set([
4615
4636
  "--api",
4616
4637
  "--profile",
@@ -4849,8 +4870,38 @@ function readWorkbench(parsed) {
4849
4870
  if (value["format"] !== "character-workbench/v0.1" || !profiles || !execution || !agent || typeof profiles["parent"] !== "string" || typeof profiles["candidate"] !== "string" || humanAnnotatorIds2 !== void 0 && (!Array.isArray(humanAnnotatorIds2) || humanAnnotatorIds2.length === 0 || !humanAnnotatorIds2.every((id) => typeof id === "string" && id.trim().length > 0) || new Set(humanAnnotatorIds2).size !== humanAnnotatorIds2.length)) {
4850
4871
  throw new CharacterCommandError("invalid_workbench", `${path} is not a character-workbench/v0.1 document`);
4851
4872
  }
4873
+ const problems = executionProblems(execution);
4874
+ if (problems.length > 0) {
4875
+ throw new CharacterCommandError("invalid_workbench", `${path} has run settings that do not read`, problems);
4876
+ }
4852
4877
  return { directory, document: value };
4853
4878
  }
4879
+ function executionProblems(execution) {
4880
+ const problems = [];
4881
+ const present = (key) => execution[key] !== void 0;
4882
+ const integer = (key, min) => {
4883
+ if (present(key) && (!Number.isSafeInteger(execution[key]) || execution[key] < min)) {
4884
+ problems.push(`execution.${key} is an integer of at least ${min}`);
4885
+ }
4886
+ };
4887
+ if (present("model") && (typeof execution["model"] !== "string" || execution["model"].trim().length === 0)) {
4888
+ problems.push("execution.model is a non-empty string");
4889
+ }
4890
+ if (present("temperature") && (typeof execution["temperature"] !== "number" || !Number.isFinite(execution["temperature"]))) {
4891
+ problems.push("execution.temperature is a number");
4892
+ }
4893
+ if (present("reasoningEffort") && !FIELD_REASONING_EFFORTS.includes(execution["reasoningEffort"])) {
4894
+ problems.push(`execution.reasoningEffort is one of ${FIELD_REASONING_EFFORTS.join(", ")}`);
4895
+ }
4896
+ if (present("fallback") && execution["fallback"] !== null && typeof execution["fallback"] !== "string") {
4897
+ problems.push("execution.fallback is a model id or null");
4898
+ }
4899
+ integer("maxOutputTokens", 0);
4900
+ integer("repeats", 1);
4901
+ integer("modelSeed", 0);
4902
+ integer("moveSeed", 0);
4903
+ return problems;
4904
+ }
4854
4905
  function humanAnnotatorIds(workbench) {
4855
4906
  return workbench?.document.humanAnnotatorIds;
4856
4907
  }
@@ -4902,15 +4953,16 @@ async function prepareRun(parsed, workbench, profile, scenePath, dryRun) {
4902
4953
  const situations = readFileSync(situationsPath, "utf8");
4903
4954
  const situationSet = parseSituationSet(JSON.parse(situations));
4904
4955
  const execution = workbench?.document.execution;
4905
- const reasoningEffort2 = parsed.values.get("--reasoning-effort");
4906
- if (reasoningEffort2 !== void 0 && !FIELD_REASONING_EFFORTS.includes(reasoningEffort2)) {
4956
+ const reasoningFlag = parsed.values.get("--reasoning-effort");
4957
+ if (reasoningFlag !== void 0 && !FIELD_REASONING_EFFORTS.includes(reasoningFlag)) {
4907
4958
  throw new CharacterCommandError("invalid_arguments", `--reasoning-effort is one of ${FIELD_REASONING_EFFORTS.join(", ")}`);
4908
4959
  }
4960
+ const reasoningEffort2 = reasoningFlag ?? execution?.reasoningEffort;
4909
4961
  const model = parsed.values.get("--model") ?? execution?.model;
4910
4962
  const temperature = numberFlag(parsed, "--temperature") ?? execution?.temperature;
4911
- const maxOutputTokens = nonNegativeFlag(parsed, "--max-output-tokens");
4963
+ const maxOutputTokens = nonNegativeFlag(parsed, "--max-output-tokens") ?? execution?.maxOutputTokens;
4912
4964
  const readerModel = parsed.values.has("--reader-model") ? parsed.values.get("--reader-model") === "null" ? null : parsed.values.get("--reader-model") : execution?.reader;
4913
- const fallback = parsed.values.get("--fallback");
4965
+ const fallback = parsed.values.get("--fallback") ?? execution?.fallback ?? void 0;
4914
4966
  const revealsState = booleanValue(parsed, "--reveals-state") ?? execution?.revealsState ?? true;
4915
4967
  const afterConversations = nonNegativeFlag(parsed, "--stop-after-conversations");
4916
4968
  const afterTurns = nonNegativeFlag(parsed, "--stop-after-turns");
@@ -4918,7 +4970,7 @@ async function prepareRun(parsed, workbench, profile, scenePath, dryRun) {
4918
4970
  ...afterConversations !== void 0 ? { afterConversations } : {},
4919
4971
  ...afterTurns !== void 0 ? { afterTurns } : {}
4920
4972
  };
4921
- const repeats = numberFlag(parsed, "--repeats", true) ?? 1;
4973
+ const repeats = numberFlag(parsed, "--repeats", true) ?? execution?.repeats ?? 1;
4922
4974
  if (repeats < 1) throw new CharacterCommandError("invalid_arguments", "--repeats is a positive integer");
4923
4975
  const runtime = {
4924
4976
  ...model !== void 0 ? { model } : {},
@@ -4936,8 +4988,8 @@ async function prepareRun(parsed, workbench, profile, scenePath, dryRun) {
4936
4988
  ...nonNegativeFlag(parsed, "--turns-per-conversation") !== void 0 ? { turnsPerConversation: nonNegativeFlag(parsed, "--turns-per-conversation") } : {},
4937
4989
  ...nonNegativeFlag(parsed, "--conversations-per-day") !== void 0 ? { conversationsPerDay: nonNegativeFlag(parsed, "--conversations-per-day") } : {}
4938
4990
  };
4939
- const modelSeed = numberFlag(parsed, "--model-seed", true);
4940
- const moveSeed = numberFlag(parsed, "--move-seed", true);
4991
+ const modelSeed = numberFlag(parsed, "--model-seed", true) ?? execution?.modelSeed;
4992
+ const moveSeed = numberFlag(parsed, "--move-seed", true) ?? execution?.moveSeed;
4941
4993
  let replicateId2 = parsed.values.get("--replicate-id");
4942
4994
  if (replicateId2 !== void 0 && (replicateId2.trim().length === 0 || replicateId2.length > 200)) {
4943
4995
  throw new CharacterCommandError("invalid_arguments", "--replicate-id needs a non-empty value of at most 200 characters");
@@ -4974,13 +5026,19 @@ async function prepareRun(parsed, workbench, profile, scenePath, dryRun) {
4974
5026
  modelCallsFloor: situationSet.situations.reduce((total, situation) => total + situation.served.length, 0) * repeats
4975
5027
  };
4976
5028
  const planPath = join8(runDir, "plan.json");
5029
+ let createdAt = (/* @__PURE__ */ new Date()).toISOString();
5030
+ try {
5031
+ const prior = JSON.parse(readFileSync(planPath, "utf8"));
5032
+ if (prior.runId === runId && typeof prior.createdAt === "string") createdAt = prior.createdAt;
5033
+ } catch {
5034
+ }
4977
5035
  const plan = {
4978
5036
  schema: "character-run-plan/v0.1",
4979
5037
  status: "planned",
4980
5038
  dryRun,
4981
5039
  runnerContract: CHARACTER_RUNNER_CONTRACT,
4982
5040
  runnerVersion: "character-cli/v0.2",
4983
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
5041
+ createdAt,
4984
5042
  runId,
4985
5043
  runDir,
4986
5044
  planPath,
@@ -5028,6 +5086,9 @@ function assertRunEvidence(result2) {
5028
5086
  attempts: result2.attempts
5029
5087
  });
5030
5088
  }
5089
+ function printRunWarnings(result2) {
5090
+ for (const warning of result2.warnings) console.error(`warning ${result2.runId}: ${warning}`);
5091
+ }
5031
5092
  async function executePrepared(parsed, prepared) {
5032
5093
  const result2 = await runCharacter({
5033
5094
  ...prepared.options,
@@ -5054,6 +5115,7 @@ plan: ${prepared.plan.planPath}`
5054
5115
  };
5055
5116
  }
5056
5117
  const result2 = await executePrepared(parsed, prepared);
5118
+ printRunWarnings(result2);
5057
5119
  return {
5058
5120
  result: { ...result2, plan: prepared.plan },
5059
5121
  rendered: `run ${result2.runId}: ${result2.status}
@@ -5124,9 +5186,227 @@ function finalizeCheckIds(comparison, generated, existing) {
5124
5186
  }
5125
5187
  return generated.map((annotation) => replacements.get(annotation.id));
5126
5188
  }
5189
+ function readOutcome(read) {
5190
+ if (typeof read["score"] === "number" && typeof read["bar"] === "number") return read["score"] >= read["bar"] ? "met" : "unmet";
5191
+ if (read["value"] === "flagged" || read["value"] === "clean") return read["value"] === "flagged" ? "met" : "unmet";
5192
+ if (typeof read["flagged"] === "boolean") return read["flagged"] ? "met" : "unmet";
5193
+ return "none";
5194
+ }
5195
+ function renderTurnMechanics(turn, totals) {
5196
+ const lines = [];
5197
+ if (turn.reads === null) lines.push(" reads: not recorded");
5198
+ else if (turn.reads.length === 0) lines.push(" reads: none");
5199
+ for (const raw of turn.reads ?? []) {
5200
+ if (raw === null || typeof raw !== "object") continue;
5201
+ const read = raw;
5202
+ const outcome = readOutcome(read);
5203
+ totals[outcome] += 1;
5204
+ const phase = read["phase"] === "pre" ? "before" : read["phase"] === "post" ? "after " : " ";
5205
+ const score = typeof read["score"] === "number" ? String(read["score"]) : "-";
5206
+ const bar = typeof read["bar"] === "number" ? `/${read["bar"]}` : "";
5207
+ lines.push(` read ${phase} ${`${score}${bar}`.padEnd(9)} ${(outcome === "none" ? "no reading" : outcome).padEnd(10)} ${String(read["statement"] ?? read["id"] ?? "")}`);
5208
+ }
5209
+ if (turn.blocks === null) lines.push(" blocks: not recorded");
5210
+ else {
5211
+ const blocks2 = turn.blocks;
5212
+ const ids = (fired) => blocks2.filter((block) => block.fired === fired).map((block) => block.id).join(", ") || "none";
5213
+ lines.push(` on: ${ids(true)}`, ` off: ${ids(false)}`);
5214
+ }
5215
+ return lines.join("\n");
5216
+ }
5217
+ function personLine(capture) {
5218
+ const conversation = capture !== null && typeof capture === "object" ? capture.conversation : void 0;
5219
+ if (!Array.isArray(conversation)) return void 0;
5220
+ for (let index = conversation.length - 1; index >= 0; index -= 1) {
5221
+ const entry = conversation[index];
5222
+ if (entry !== null && typeof entry === "object" && entry.role === "person" && typeof entry.text === "string") return entry.text;
5223
+ }
5224
+ return void 0;
5225
+ }
5226
+ function quoted(text) {
5227
+ return text.split("\n").map((line) => line === "" ? ">" : `> ${line}`).join("\n");
5228
+ }
5229
+ function situationList2(value) {
5230
+ const list = Array.isArray(value) ? value : value !== null && typeof value === "object" && Array.isArray(value.situations) ? value.situations : [];
5231
+ return list.flatMap((entry) => {
5232
+ if (entry === null || typeof entry !== "object") return [];
5233
+ const { id, served } = entry;
5234
+ return typeof id === "string" ? [{ id, served: Array.isArray(served) ? served.filter((line) => typeof line === "string") : [] }] : [];
5235
+ });
5236
+ }
5237
+ function bySituationThenRepeat(situations) {
5238
+ const position = new Map(situationList2(situations).map((situation, index) => [situation.id, index]));
5239
+ const place = (id) => position.get(id) ?? Number.MAX_SAFE_INTEGER;
5240
+ return (left, right) => place(left.situationId) - place(right.situationId) || left.situationId.localeCompare(right.situationId) || Number(left.repeat) - Number(right.repeat) || String(left.repeat).localeCompare(String(right.repeat));
5241
+ }
5242
+ function readComparisonFile(path) {
5243
+ try {
5244
+ if (!statSync(path).isFile()) return void 0;
5245
+ const value = JSON.parse(readFileSync(path, "utf8"));
5246
+ return value !== null && typeof value === "object" && !Array.isArray(value) && String(value.schema ?? "").startsWith("character-comparison/") ? value : void 0;
5247
+ } catch {
5248
+ return void 0;
5249
+ }
5250
+ }
5251
+ function markdownText(text) {
5252
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
5253
+ }
5254
+ function markdownTableText(text) {
5255
+ return markdownText(text).replace(/\|/g, "\\|");
5256
+ }
5257
+ function quotedMarkdown(text) {
5258
+ return quoted(markdownText(text));
5259
+ }
5260
+ function comparisonRunDirectory(roots, runId) {
5261
+ if (runId.length === 0 || runId === "." || runId === ".." || runId.includes("/") || runId.includes("\\")) return null;
5262
+ let unidentified = null;
5263
+ for (const root of roots) {
5264
+ const directory = join8(root, runId);
5265
+ try {
5266
+ if (!statSync(directory).isDirectory()) continue;
5267
+ const identityFiles = ["spec.json", "manifest.json"].map((file) => join8(directory, file)).filter((file) => existsSync2(file));
5268
+ if (identityFiles.length === 0) {
5269
+ unidentified ??= directory;
5270
+ continue;
5271
+ }
5272
+ const identities = identityFiles.map((file) => JSON.parse(readFileSync(file, "utf8")));
5273
+ if (identities.every((identity) => identity.runId === runId)) return directory;
5274
+ } catch {
5275
+ }
5276
+ }
5277
+ return unidentified;
5278
+ }
5279
+ function showComparison(parsed, path, comparison) {
5280
+ const runId = (key) => String(comparison[key]?.runId ?? "");
5281
+ const comparisonDirectory = dirname5(resolve(path));
5282
+ const roots = [.../* @__PURE__ */ new Set([dirname5(comparisonDirectory), join8(dirname5(comparisonDirectory), "runs")])];
5283
+ const parentDir = comparisonRunDirectory(roots, runId("parent"));
5284
+ const candidateDir = comparisonRunDirectory(roots, runId("candidate"));
5285
+ const json = (file) => {
5286
+ try {
5287
+ return JSON.parse(readFileSync(file, "utf8"));
5288
+ } catch {
5289
+ return void 0;
5290
+ }
5291
+ };
5292
+ const situations = (candidateDir === null ? void 0 : json(join8(candidateDir, "situations.json"))) ?? (parentDir === null ? void 0 : json(join8(parentDir, "situations.json")));
5293
+ const served = new Map(situationList2(situations).map((situation2) => [situation2.id, situation2.served]));
5294
+ const situation = parsed.values.get("--situation");
5295
+ const repeat = nonNegativeFlag(parsed, "--repeat");
5296
+ const turnIndex = nonNegativeFlag(parsed, "--turn");
5297
+ const order = bySituationThenRepeat(situations);
5298
+ const rows = (Array.isArray(comparison["rows"]) ? comparison["rows"] : []).map((row) => row).filter((row) => (situation === void 0 || row.situationId === situation) && (repeat === void 0 || String(row.repeat) === String(repeat)) && (turnIndex === void 0 || row.turnIndex === turnIndex)).sort((left, right) => order(left, right) || (left.turnIndex ?? -1) - (right.turnIndex ?? -1));
5299
+ if (rows.length === 0) throw new CharacterCommandError("target_not_found", "no comparison rows match the selectors");
5300
+ const turnCount = rows.filter((row) => row.turnIndex !== null).length;
5301
+ const zeroTurnAttempts = rows.length - turnCount;
5302
+ const words = (text) => text === void 0 ? 0 : text.split(/\s+/).filter(Boolean).length;
5303
+ const cell = (read, evidence2) => {
5304
+ if (read === void 0) return evidence2 == null ? "not recorded" : "none";
5305
+ const outcome = readOutcome(read);
5306
+ if (outcome === "none") return "no reading";
5307
+ if (typeof read["score"] === "number" && typeof read["bar"] === "number") return `${read["score"]}/${read["bar"]} ${outcome}`;
5308
+ return outcome;
5309
+ };
5310
+ const reply = (label, side) => side.reply === void 0 ? [`**${label}:** no reply (${markdownText(side.status ?? "missing")})`, ""] : [`**${label}** (${words(side.reply)} words):`, "", quotedMarkdown(side.reply), ""];
5311
+ const on = (side) => side.blocks == null ? "not recorded" : side.blocks.filter((block) => block.fired).map((block) => block.id).join(", ") || "none";
5312
+ const evidence = [`${turnCount} ${turnCount === 1 ? "turn" : "turns"} shown`];
5313
+ if (zeroTurnAttempts > 0) evidence.push(`${zeroTurnAttempts} zero-turn ${zeroTurnAttempts === 1 ? "attempt" : "attempts"} shown`);
5314
+ const lines = [
5315
+ "# Kept version against candidate",
5316
+ "",
5317
+ `- Kept: \`${markdownText(runId("parent"))}\``,
5318
+ `- Candidate: \`${markdownText(runId("candidate"))}\``,
5319
+ `- Evidence: ${markdownText(String(comparison["status"] ?? "unknown"))}, ${evidence.join(", ")}`,
5320
+ "",
5321
+ "## What changed in the scene",
5322
+ ""
5323
+ ];
5324
+ const sceneSource = (key, directory) => {
5325
+ if (directory === null) return void 0;
5326
+ try {
5327
+ const source = readFileSync(join8(directory, "scene.json"), "utf8");
5328
+ const expected = comparison[key]?.sceneDigest;
5329
+ if (expected !== void 0 && (typeof expected !== "string" || sha256(source) !== expected)) return void 0;
5330
+ return source;
5331
+ } catch {
5332
+ return void 0;
5333
+ }
5334
+ };
5335
+ const parentScene = sceneSource("parent", parentDir);
5336
+ const candidateScene = sceneSource("candidate", candidateDir);
5337
+ if (parentScene === void 0 || candidateScene === void 0) lines.push("The two scenes are not both on this machine. Both available scene files must match the comparison digests.", "");
5338
+ else if (parentScene === candidateScene) lines.push("Nothing. Both sides ran the same scene, so every difference below is the model varying on its own.", "");
5339
+ else lines.push(renderSceneDiff(diffScenes(parseSceneText(parentScene), parseSceneText(candidateScene))).replace(/^## /gm, "### ").trimEnd(), "");
5340
+ for (const row of rows) {
5341
+ const heading = `${markdownText(row.situationId)}, repeat ${markdownText(String(row.repeat))}`;
5342
+ if (row.turnIndex === null) {
5343
+ lines.push(`## ${heading}`, "", "No turns were planned or captured on either side.", "");
5344
+ continue;
5345
+ }
5346
+ lines.push(`## ${heading}, turn ${row.turnIndex}`, "");
5347
+ const person = served.get(row.situationId)?.[row.turnIndex];
5348
+ if (person === void 0) lines.push("**Person:** not recorded", "");
5349
+ else lines.push("**Person:**", "", quotedMarkdown(person), "");
5350
+ lines.push(...reply("Kept", row.parent), ...reply("Candidate", row.candidate));
5351
+ const reads = /* @__PURE__ */ new Map();
5352
+ for (const key of ["parent", "candidate"]) {
5353
+ for (const raw of row[key].reads ?? []) {
5354
+ if (raw === null || typeof raw !== "object") continue;
5355
+ const read = raw;
5356
+ const id = String(read["id"] ?? read["statement"] ?? "");
5357
+ const entry = reads.get(id) ?? {
5358
+ statement: String(read["statement"] ?? id),
5359
+ phase: read["phase"] === "pre" ? "before" : read["phase"] === "post" ? "after" : ""
5360
+ };
5361
+ entry[key] = read;
5362
+ reads.set(id, entry);
5363
+ }
5364
+ }
5365
+ if (reads.size === 0) {
5366
+ const keptReads = row.parent.reads == null ? "not recorded" : "none";
5367
+ const candidateReads = row.candidate.reads == null ? "not recorded" : "none";
5368
+ if (keptReads === candidateReads) lines.push(`Reads, both sides: ${keptReads}`, "");
5369
+ else lines.push(`Reads, kept: ${keptReads}`, "", `Reads, candidate: ${candidateReads}`, "");
5370
+ } else {
5371
+ lines.push("| Statement | Read | Kept | Candidate |", "| --- | --- | --- | --- |");
5372
+ for (const read of reads.values()) {
5373
+ lines.push(`| ${markdownTableText(read.statement)} | ${read.phase} | ${cell(read.parent, row.parent.reads)} | ${cell(read.candidate, row.candidate.reads)} |`);
5374
+ }
5375
+ lines.push("");
5376
+ }
5377
+ const [keptOn, candidateOn] = [on(row.parent), on(row.candidate)];
5378
+ if (keptOn === candidateOn) lines.push(`Blocks on, both sides: ${markdownText(keptOn)}`);
5379
+ else lines.push(`Blocks on, kept: ${markdownText(keptOn)}`, "", `Blocks on, candidate: ${markdownText(candidateOn)}`);
5380
+ const checks = /* @__PURE__ */ new Map();
5381
+ for (const key of ["parent", "candidate"]) {
5382
+ for (const check of row[key].checks ?? []) checks.set(check.name, { ...checks.get(check.name), [key]: check.label ?? "-" });
5383
+ }
5384
+ if (checks.size > 0) {
5385
+ const failing = [...checks].filter(([, labels]) => labels.parent !== "pass" || labels.candidate !== "pass");
5386
+ lines.push("", failing.length === 0 ? `Checks: all ${checks.size} pass on both sides` : `Checks: ${failing.map(([name, labels]) => `\`${markdownText(name)}\` kept ${markdownText(labels.parent ?? "-")}, candidate ${markdownText(labels.candidate ?? "-")}`).join("; ")}`);
5387
+ }
5388
+ lines.push("");
5389
+ }
5390
+ const view = `${lines.join("\n").trimEnd()}
5391
+ `;
5392
+ return {
5393
+ result: {
5394
+ comparisonPath: resolve(path),
5395
+ status: comparison["status"] ?? null,
5396
+ parent: { runId: runId("parent") },
5397
+ candidate: { runId: runId("candidate") },
5398
+ turns: turnCount,
5399
+ zeroTurnAttempts,
5400
+ view
5401
+ },
5402
+ rendered: view.trimEnd()
5403
+ };
5404
+ }
5127
5405
  async function executeShow(parsed) {
5128
- expectPositionals(parsed, 1, "sight character show <scene.json|run-dir> [--situation <id>] [--repeat <n>] [--turn <n>] [--json]");
5406
+ expectPositionals(parsed, 1, "sight character show <scene.json|run-dir|comparison.json> [--situation <id>] [--repeat <n>] [--turn <n>] [--json]");
5129
5407
  const path = parsed.positionals[0];
5408
+ const comparison = readComparisonFile(path);
5409
+ if (comparison !== void 0) return showComparison(parsed, path, comparison);
5130
5410
  if (!existsSync2(join8(path, "spec.json"))) {
5131
5411
  const document = readScene(path);
5132
5412
  const view = renderScene(document);
@@ -5148,14 +5428,14 @@ scene SHA-256: ${sceneDigest}` };
5148
5428
  const allowedHumans = new Set(humanAnnotatorIds(workbench) ?? []);
5149
5429
  const loadedNotes = await Promise.all([...notePaths].map((notesPath) => listAnnotations(notesPath)));
5150
5430
  const humanAnnotations = [...new Map(loadedNotes.flat().concat(evidence.checkAnnotations).filter((annotation) => annotation.annotator.kind === "human" && allowedHumans.has(annotation.annotator.id)).map((annotation) => [annotation.id, annotation])).values()];
5151
- const attempts = evidence.attempts.filter((attempt) => (situation === void 0 || attempt.situationId === situation) && (repeat === void 0 || String(attempt.repeat) === String(repeat)));
5431
+ const attempts = evidence.attempts.filter((attempt) => (situation === void 0 || attempt.situationId === situation) && (repeat === void 0 || String(attempt.repeat) === String(repeat))).sort(bySituationThenRepeat(evidence.situations));
5152
5432
  if (attempts.length === 0) throw new CharacterCommandError("target_not_found", "no run attempts match the selectors");
5153
5433
  const attemptIds = new Set(attempts.map((attempt) => attempt.attemptId));
5154
5434
  const selectedTurns = evidence.turns.filter((turn) => attemptIds.has(turn.attemptId) && (turnIndex === void 0 || turn.turnIndex === turnIndex));
5155
5435
  const rows = attempts.map((attempt) => {
5156
5436
  const conversationId = `${encodeURIComponent(evidence.runId)}/${encodeURIComponent(attempt.attemptId)}`;
5157
5437
  const attemptAnnotations = humanAnnotations.filter((annotation) => annotation.target.kind === "run" && annotation.target.id === evidence.runId || annotation.target.kind === "situation" && annotation.target.id === attempt.situationId || annotation.target.kind === "conversation" && annotation.target.id === conversationId);
5158
- const captures = selectedTurns.filter((turn) => turn.attemptId === attempt.attemptId);
5438
+ const captures = selectedTurns.filter((turn) => turn.attemptId === attempt.attemptId).sort((left, right) => left.turnIndex - right.turnIndex);
5159
5439
  const turns = captures.map((turn) => {
5160
5440
  const normalized = normalizeTurnEvidence(turn.capture, evidence.scene);
5161
5441
  const targetId = `${encodeURIComponent(evidence.runId)}/${encodeURIComponent(attempt.attemptId)}/${turn.turnIndex}`;
@@ -5172,13 +5452,23 @@ scene SHA-256: ${sceneDigest}` };
5172
5452
  }
5173
5453
  return { ...attempt, annotations: attemptAnnotations, turns };
5174
5454
  });
5175
- const rendered = rows.flatMap((attempt) => attempt.turns.map((turn) => {
5176
- const normalized = turn.normalized;
5177
- const notes = turn.annotations.map((annotation) => `
5455
+ const readTotals = { met: 0, unmet: 0, none: 0 };
5456
+ const rendered = rows.flatMap((attempt) => {
5457
+ if (attempt.turns.length === 0) {
5458
+ return [`${attempt.situationId}/${attempt.repeat}: ${attempt.plannedTurns === 0 ? "0 turns planned; no turns recorded" : "no turn evidence"}`];
5459
+ }
5460
+ return attempt.turns.map((turn) => {
5461
+ const normalized = turn.normalized;
5462
+ const notes = turn.annotations.map((annotation) => `
5178
5463
  ${annotation.annotator.id}: ${annotation.explanation ?? annotation.label ?? annotation.name}`).join("");
5179
- return `${attempt.situationId}/${attempt.repeat}/${turn.turnIndex}: ${normalized?.status ?? "missing"}${normalized?.reply === void 0 ? "" : `
5180
- ${normalized.reply}`}${notes}`;
5181
- })).join("\n");
5464
+ const mechanics = normalized === null ? "\n reads: not recorded\n blocks: not recorded" : `
5465
+ ${renderTurnMechanics(normalized, readTotals)}`;
5466
+ const person = personLine(turn.capture);
5467
+ return `${attempt.situationId}/${attempt.repeat}/${turn.turnIndex}: ${normalized?.status ?? "missing"}${person === void 0 ? "" : `
5468
+ ${quoted(person)}`}${normalized?.reply === void 0 ? "" : `
5469
+ ${normalized.reply}`}${mechanics}${notes}`;
5470
+ });
5471
+ }).join("\n");
5182
5472
  return {
5183
5473
  result: {
5184
5474
  runId: evidence.runId,
@@ -5186,17 +5476,22 @@ ${normalized.reply}`}${notes}`;
5186
5476
  situationsDigest: evidence.situationsDigest,
5187
5477
  selectors: { situation: situation ?? null, repeat: repeat ?? null, turn: turnIndex ?? null },
5188
5478
  annotations: humanAnnotations,
5479
+ readTotals,
5189
5480
  attempts: rows
5190
5481
  },
5191
- rendered: rendered || "no turn evidence"
5482
+ rendered: rendered ? `${rendered}
5483
+ reads: ${readTotals.met} met, ${readTotals.unmet} unmet, ${readTotals.none} with no reading` : "no turn evidence"
5192
5484
  };
5193
5485
  }
5194
- async function compareAndPersist(parentDir, candidateDir, checksPath, notesPath, explicitChecks, requestedOutput) {
5195
- await Promise.all([assertCharacterDevelopmentRun(parentDir), assertCharacterDevelopmentRun(candidateDir)]);
5486
+ function readTargetedChecks(checksPath, explicitChecks) {
5196
5487
  if (explicitChecks && !existsSync2(checksPath)) {
5197
5488
  throw new CharacterCommandError("read_failed", `could not read ${checksPath}`);
5198
5489
  }
5199
- const targeted = existsSync2(checksPath) ? parseCheckSet(JSON.parse(readFileSync(checksPath, "utf8"))).checks : void 0;
5490
+ return existsSync2(checksPath) ? parseCheckSet(JSON.parse(readFileSync(checksPath, "utf8"))).checks : void 0;
5491
+ }
5492
+ async function compareAndPersist(parentDir, candidateDir, checksPath, notesPath, explicitChecks, requestedOutput) {
5493
+ const targeted = readTargetedChecks(checksPath, explicitChecks);
5494
+ await Promise.all([assertCharacterDevelopmentRun(parentDir), assertCharacterDevelopmentRun(candidateDir)]);
5200
5495
  const checks = targeted?.map(borrowedCheck);
5201
5496
  const checkSetHash = checks === void 0 ? void 0 : hashCheckSet(checks);
5202
5497
  const annotations = await listAnnotations(notesPath);
@@ -5452,6 +5747,18 @@ async function executeTrial(parsed) {
5452
5747
  assertHumanActor(workbench, parsed.booleans.has("--agent"), requiredValue(parsed, "--actor"), "a trial");
5453
5748
  requiredValue(parsed, "--reason");
5454
5749
  }
5750
+ const checksPath = parsed.values.get("--checks") ?? join8(workbench.directory, "checks.json");
5751
+ const targetedChecks = readTargetedChecks(checksPath, parsed.values.has("--checks"));
5752
+ if (targetedChecks !== void 0 && targetedChecks.length > 0) {
5753
+ const situationsPath = parsed.values.get("--situations") ?? join8(workbench.directory, "situations", "climb.json");
5754
+ const served = new Map(parseSituationSet(JSON.parse(readFileSync(situationsPath, "utf8"))).situations.map((situation) => [situation.id, situation.served.length]));
5755
+ const problems = targetedChecks.flatMap((check, index) => {
5756
+ const turns = served.get(check.situation);
5757
+ if (turns === void 0) return [`checks[${index}]: situation '${check.situation}' is not in ${situationsPath}`];
5758
+ return check.turn < turns ? [] : [`checks[${index}]: turn ${check.turn} is past the ${turns} served turns of '${check.situation}'`];
5759
+ });
5760
+ if (problems.length > 0) throw new CharacterCommandError("invalid_contract", "a character contract does not read", problems);
5761
+ }
5455
5762
  const candidatePrepared = await prepareRun(parsed, workbench, candidateProfile, scenePath, dryRun);
5456
5763
  const previousParent = readWorkingParent(workbench);
5457
5764
  if (previousParent !== null && previousParent.spec !== null) await assertCharacterDevelopmentRun(previousParent.runDir);
@@ -5491,14 +5798,30 @@ async function executeTrial(parsed) {
5491
5798
  };
5492
5799
  return { result: result2, rendered: "trial dry run: no PUT, provider call, comparison or decision" };
5493
5800
  }
5801
+ if (!existsSync2(join8(candidatePrepared.plan.runDir, "spec.json"))) {
5802
+ const { runtime, endpoint } = candidatePrepared.options;
5803
+ await fieldFor(parsed).profiles.putScene(candidateProfile, readFileSync(scenePath, "utf8"), {
5804
+ ...runtime?.model !== void 0 ? { model: runtime.model } : {},
5805
+ ...runtime?.temperature !== void 0 ? { temperature: runtime.temperature } : {},
5806
+ ...runtime?.maxOutputTokens !== void 0 ? { maxOutputTokens: runtime.maxOutputTokens } : {},
5807
+ ...runtime?.reasoningEffort !== void 0 ? { reasoningEffort: runtime.reasoningEffort } : {},
5808
+ ...typeof runtime?.fallback === "string" ? { fallback: runtime.fallback } : {},
5809
+ ...endpoint?.idleMinutes !== void 0 ? { idleMinutes: endpoint.idleMinutes } : {},
5810
+ ...endpoint?.turnsPerConversation !== void 0 ? { turnsPerConversation: endpoint.turnsPerConversation } : {},
5811
+ ...endpoint?.conversationsPerDay !== void 0 ? { conversationsPerDay: endpoint.conversationsPerDay } : {},
5812
+ dryRun: true
5813
+ });
5814
+ }
5494
5815
  const parentResult = parentPrepared !== void 0 ? existsSync2(join8(parentPrepared.plan.runDir, "spec.json")) ? await resumeEvidence(parsed, parentPrepared.plan.runDir, workbench) : await executePrepared(parsed, parentPrepared) : await resumeEvidence(parsed, previousParent.runDir, workbench);
5495
5816
  console.error(`parent ${parentResult.runId}: ${parentResult.status}`);
5817
+ printRunWarnings(parentResult);
5496
5818
  const candidateResult = existsSync2(join8(candidatePrepared.plan.runDir, "spec.json")) ? await resumeEvidence(parsed, candidatePrepared.plan.runDir, workbench) : await executePrepared(parsed, candidatePrepared);
5497
5819
  console.error(`candidate ${candidateResult.runId}: ${candidateResult.status}`);
5820
+ printRunWarnings(candidateResult);
5498
5821
  const compared = await compareAndPersist(
5499
5822
  parentResult.runDir,
5500
5823
  candidateResult.runDir,
5501
- parsed.values.get("--checks") ?? join8(workbench.directory, "checks.json"),
5824
+ checksPath,
5502
5825
  parsed.values.get("--notes") ?? join8(workbench.directory, "annotations", "notes.jsonl"),
5503
5826
  parsed.values.has("--checks"),
5504
5827
  parsed.values.get("--out")
@@ -5725,7 +6048,8 @@ outcome: ${dryRun.outcome}`);
5725
6048
  field: fieldFor(parsed),
5726
6049
  model: parsed.values.get("--model"),
5727
6050
  parent: parsed.values.get("--parent"),
5728
- candidate: parsed.values.get("--candidate")
6051
+ candidate: parsed.values.get("--candidate"),
6052
+ ...parsed.values.has("--designer") ? { humanAnnotatorIds: parsed.values.get("--designer").split(",") } : {}
5729
6053
  });
5730
6054
  printSuccess(output, result2, `initialized ${result2.directory}
5731
6055
  parent: ${result2.profiles.parent.profile}
@@ -5760,6 +6084,7 @@ function usage() {
5760
6084
  " sight openrouter connect --budget <usd> [--house-trial] [--api <base>]",
5761
6085
  " sight openrouter status [--api <base>]",
5762
6086
  " sight connect <relay-url> --invite <code> [--pulse] [--api <base>]",
6087
+ " sight --version",
5763
6088
  ` ${CHARACTER_USAGE.split("\n").join("\n ")}`,
5764
6089
  "",
5765
6090
  "Commands:",
@@ -6398,6 +6723,9 @@ if (command === "connect") {
6398
6723
  importConversations(rest).then(exit);
6399
6724
  } else if (command === "character") {
6400
6725
  character(rest).then(exit);
6726
+ } else if (command === "--version" || command === "-v") {
6727
+ console.log(JSON.parse(readFileSync2(new URL("../package.json", import.meta.url), "utf8")).version);
6728
+ exit(0);
6401
6729
  } else {
6402
6730
  usage();
6403
6731
  exit(command && command !== "--help" && command !== "-h" ? 1 : 0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cultured_computer/sight",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "bin": {
5
5
  "sight": "./dist/cli.js"
6
6
  },