@aikdna/kdna-studio-cli 0.8.6 → 0.8.7

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.
Files changed (2) hide show
  1. package/bin/kdna-studio.js +41 -16
  2. package/package.json +2 -2
@@ -428,11 +428,20 @@ function cardsFromV1Payload(payload) {
428
428
  pushImportedCard(cards, 'self_check', fields, fields.id || null);
429
429
  }
430
430
  for (const failureMode of (Array.isArray(payload.reasoning?.failure_modes) ? payload.reasoning?.failure_modes : [])) {
431
+ // Bug (#145 follow-up): the prior version dropped three
432
+ // judgment fields (failure_risk, applies_when, does_not_apply_when)
433
+ // when reading failure_modes back out of a v1 asset. A Studio
434
+ // project that round-tripped through `migrate --format v1` lost
435
+ // these fields every time. The fix reads them through, matching
436
+ // the export-side map in kdna-studio-core's buildPayload.
431
437
  pushImportedCard(cards, 'misunderstanding', {
432
438
  wrong: failureMode.mode || failureMode.wrong || '',
433
439
  correct: failureMode.correct || '',
434
440
  key_distinction: failureMode.key_distinction || '',
435
441
  why: failureMode.why || '',
442
+ failure_risk: failureMode.failure_risk || '',
443
+ applies_when: Array.isArray(failureMode.applies_when) ? failureMode.applies_when : [],
444
+ does_not_apply_when: Array.isArray(failureMode.does_not_apply_when) ? failureMode.does_not_apply_when : [],
436
445
  }, failureMode.id || null);
437
446
  }
438
447
  for (const chain of (Array.isArray(payload.reasoning?.reasoning_chains) ? payload.reasoning?.reasoning_chains : [])) {
@@ -1000,6 +1009,15 @@ function importFromFolder(sourceDir, projectDir, projectName, creatorIdentity) {
1000
1009
  const q = typeof sc === 'string' ? sc : sc.question || '';
1001
1010
  importedCards.push(cardApi.createCard('self_check', { question: q }));
1002
1011
  }
1012
+ // Bug (aesthetic round-trip): prior version dropped
1013
+ // `patterns.aesthetics` on import. `cardsFromV1Payload` and
1014
+ // `cardsFromLegacyPayload` both read the field, so a domain
1015
+ // that authored aesthetic cards in either format would lose
1016
+ // them when imported through `create --from-folder`. The fix
1017
+ // adds the missing loop here.
1018
+ for (const aesthetic of (Array.isArray(patterns.aesthetics) ? patterns.aesthetics : [])) {
1019
+ importedCards.push(cardApi.createCard('aesthetic', aesthetic.fields || aesthetic));
1020
+ }
1003
1021
  }
1004
1022
 
1005
1023
  // NEW: import scenarios
@@ -2401,23 +2419,30 @@ async function cmdFeynman(args) {
2401
2419
  // `feynman_text`. The old check was dead code (nothing writes the wrong
2402
2420
  // field) and made this command fail on every card.
2403
2421
  //
2404
- // Bug (#62 + #68): the prior error message pointed at "the feynman
2405
- // authoring command", which does not exist in this CLI. The right
2406
- // path is either:
2407
- // - kdna-studio feynman <project> <card-id> (evaluate an existing
2408
- // restatement; what the caller is already running)
2409
- // - kdna-studio card update <project> <card-id> --field feynman_restatement='<json>'
2410
- // (set the restatement manually)
2411
- // The fix makes the second path explicit and gives a working
2412
- // example. Bug #62 (the field is never populated) is fixed in
2413
- // feynman.js: a no-restatement card now auto-generates one
2414
- // before the LLM call, so the bare `kdna-studio feynman` command
2415
- // works end-to-end.
2422
+ // Bug (#62 + #68 follow-up): the prior `if (!card.feynman_restatement)
2423
+ // fail(...)` block rejected every card that had no human-written
2424
+ // restatement, even when the AI evaluator in feynman.js was
2425
+ // prepared to auto-synthesise one. A caller without a configured
2426
+ // LLM (no `KDNA_API_KEY`, no `kdna-studio llm config`) would
2427
+ // get a `fail` instead of a structured note. The fix removes the
2428
+ // guard: a missing restatement is now handed off to the evaluator
2429
+ // (which either asks the LLM to evaluate a synthesised one or,
2430
+ // without an LLM, returns a structured `synthesised_restatement`
2431
+ // for the caller to use as a starting point). The error message
2432
+ // is kept as a secondary path: only if the evaluator itself fails
2433
+ // does the command exit non-zero, and only then with a clear
2434
+ // pointer to the manual `card update` path.
2435
+ //
2436
+ // We do still need a restatement-shaped object to feed the
2437
+ // evaluator, so we synthesise one in-memory when the card has
2438
+ // none. This does NOT persist the synthesised restatement to the
2439
+ // project (so the user still has to opt in via `card update` to
2440
+ // keep one across runs), but it lets the no-LLM path return a
2441
+ // useful result instead of a hard fail.
2416
2442
  if (!card.feynman_restatement) {
2417
- fail(
2418
- `Card ${cardId} has no Feynman restatement. Set it manually:\n` +
2419
- ` kdna-studio card update <project> ${cardId} --field feynman_restatement='{"text":"<your plain-language restatement>"}'`,
2420
- );
2443
+ const synthesised = ai.feynman.synthFeynmanRestatement(card.fields || {});
2444
+ card.feynman_restatement = { text: synthesised, synthesised: true };
2445
+ console.warn(`No feynman_restatement on ${cardId}; using synthesised:\n "${synthesised}"`);
2421
2446
  }
2422
2447
 
2423
2448
  console.log(`Evaluating Feynman restatement for card: ${cardId}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aikdna/kdna-studio-cli",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "description": "Official KDNA Studio command-line authoring entry for creating, reviewing, compiling, and exporting .kdna judgment assets through the KDNA toolchain.",
5
5
  "type": "commonjs",
6
6
  "bin": {
@@ -39,7 +39,7 @@
39
39
  "node": ">=18"
40
40
  },
41
41
  "dependencies": {
42
- "@aikdna/kdna-studio-core": "^1.7.5",
42
+ "@aikdna/kdna-studio-core": "^1.7.6",
43
43
  "ajv": "^8.20.0",
44
44
  "ajv-formats": "^3.0.1",
45
45
  "cbor-x": "^1.6.4"