aiki-cli 0.3.2 → 0.3.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.
Files changed (48) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +64 -4
  3. package/dist/bench/idea-v3-bench.js +104 -5
  4. package/dist/bench/idea-v3-rating.js +158 -3
  5. package/dist/cli/bench.js +5 -5
  6. package/dist/cli/index.js +12 -2
  7. package/dist/cli/resume.js +20 -0
  8. package/dist/cli/run.js +75 -4
  9. package/dist/cli/serve.js +48 -0
  10. package/dist/config/config.js +7 -2
  11. package/dist/council/view.js +13 -4
  12. package/dist/orchestration/auto-profile.js +97 -0
  13. package/dist/orchestration/claim-groups.js +56 -0
  14. package/dist/orchestration/context.js +66 -3
  15. package/dist/orchestration/decision-dossier.js +42 -10
  16. package/dist/orchestration/decision-graph.js +2 -2
  17. package/dist/orchestration/engine.js +8 -4
  18. package/dist/orchestration/evidence-origin.js +17 -0
  19. package/dist/orchestration/jsonStage.js +47 -5
  20. package/dist/orchestration/modes.js +4 -2
  21. package/dist/orchestration/preflight.js +19 -0
  22. package/dist/orchestration/quick-analysis.js +31 -6
  23. package/dist/orchestration/sanitize-paths.js +10 -0
  24. package/dist/orchestration/stages/s10-render.js +31 -7
  25. package/dist/orchestration/stages/s4-analyze.js +7 -1
  26. package/dist/orchestration/stages/s4b-challenge.js +97 -0
  27. package/dist/orchestration/stages/s5-drift.js +13 -3
  28. package/dist/orchestration/stages/s8-verify.js +44 -7
  29. package/dist/orchestration/stages/s9-judge.js +20 -5
  30. package/dist/orchestration/stages/s9b-plan.js +44 -15
  31. package/dist/orchestration/url-sources.js +21 -0
  32. package/dist/providers/adapter-core.js +1 -1
  33. package/dist/providers/claude.js +18 -0
  34. package/dist/schemas/index.js +46 -0
  35. package/dist/serve/flight-deck.js +830 -0
  36. package/dist/serve/followup.js +50 -0
  37. package/dist/serve/frames.js +168 -0
  38. package/dist/serve/gates.js +72 -0
  39. package/dist/serve/projections.js +283 -0
  40. package/dist/serve/server.js +219 -0
  41. package/dist/serve/threads.js +145 -0
  42. package/dist/serve-ui/Five.png +0 -0
  43. package/dist/serve-ui/app.js +820 -0
  44. package/dist/serve-ui/index.html +171 -0
  45. package/dist/serve-ui/workspace.css +662 -0
  46. package/dist/storage/runs.js +2 -1
  47. package/dist/workflows/idea-refinement.js +94 -16
  48. package/package.json +2 -2
@@ -481,6 +481,7 @@ function canonicalizeIdeaRoleOutputModel(input) {
481
481
  const evidence = item;
482
482
  return {
483
483
  ...evidence,
484
+ source_kind: canonicalEnum(evidence.source_kind, ['USER', 'PRIMARY', 'SECONDARY', 'MODEL_KNOWLEDGE'], { USER_MATERIAL: 'USER' }), // observed live in a Q1 quick run
484
485
  support: canonicalEnumLeadingToken(evidence.support, ['SUPPORTS', 'CONTRADICTS', 'CONTEXT_ONLY'], { SUPPORT: 'SUPPORTS', OPPOSES: 'CONTRADICTS', OPPOSE: 'CONTRADICTS' }),
485
486
  freshness: canonicalEnum(evidence.freshness, ['CURRENT', 'DATED', 'UNKNOWN']),
486
487
  };
@@ -665,8 +666,27 @@ export const ClaimVerification = z.object({
665
666
  calculation_check: z.enum(['PASS', 'FAIL', 'NOT_APPLICABLE']).optional(),
666
667
  missing_evidence: z.array(z.string().min(1)),
667
668
  }).strict();
669
+ /** v6 semantic claim join: S8 may group claims that assert the same proposition in different
670
+ * words (SAME) or directly contradict each other (OPPOSES). `.catch(undefined)` keeps a
671
+ * malformed grouping from ever costing the verification set — groups are a bonus, never a risk. */
672
+ export const ClaimGroup = z.object({
673
+ ids: z.array(z.string().min(1)).min(2).max(8),
674
+ relation: z.enum(['SAME', 'OPPOSES']),
675
+ }).strict();
668
676
  export const ClaimVerificationSet = z.object({
669
677
  verifications: z.array(ClaimVerification),
678
+ claim_groups: z.array(ClaimGroup).max(12).optional().catch(undefined),
679
+ }).strict();
680
+ // ── v7 Phase D: targeted auto-mode challenge delta ─────────────────────────
681
+ export const ChallengeDelta = z.object({
682
+ claimId: z.string().min(1),
683
+ response: z.enum(['CONFIRM', 'COUNTER', 'NARROW', 'REPLACE', 'UNRESOLVED']),
684
+ reasoning: z.string().min(1),
685
+ newEvidenceIds: z.array(z.string().min(1)),
686
+ changedDecisionImpact: z.string().min(1),
687
+ }).strict();
688
+ export const ChallengeDeltaSet = z.object({
689
+ deltas: z.array(ChallengeDelta).max(3),
670
690
  }).strict();
671
691
  // ── R5: bounded, append-only rebuttal events ───────────────────────────────
672
692
  const RebuttalResponseBase = z.object({
@@ -1008,6 +1028,16 @@ export const QuickDecisionModel = z.object({
1008
1028
  // ── RunMeta (§15, §16) ──────────────────────────────────────────────────────
1009
1029
  //
1010
1030
  // Written by the artifact writer; assembled by the engine's RunCtx (T5). Internal → not strict.
1031
+ /** Per-call token accounting. `estimated:true` = local chars/4 estimate, never blended
1032
+ * silently with provider-reported numbers. */
1033
+ export const NormalizedUsageSchema = z.object({
1034
+ inputTokens: z.number().int().nonnegative().optional(),
1035
+ outputTokens: z.number().int().nonnegative().optional(),
1036
+ cacheReadTokens: z.number().int().nonnegative().optional(),
1037
+ cacheWriteTokens: z.number().int().nonnegative().optional(),
1038
+ estimated: z.boolean(),
1039
+ reportedCostUsd: z.number().nonnegative().optional(),
1040
+ });
1011
1041
  /** One provider call's accounting entry (§15 "per-call timings"). */
1012
1042
  export const CallRecord = z.object({
1013
1043
  provider: ProviderIdSchema,
@@ -1015,6 +1045,7 @@ export const CallRecord = z.object({
1015
1045
  category: z.enum(['discovery', 'verification', 'repair', 'planning']).optional(),
1016
1046
  durationMs: z.number().nonnegative(),
1017
1047
  error: z.enum(['NOT_FOUND', 'AUTH', 'QUOTA', 'TIMEOUT', 'BAD_OUTPUT', 'CRASH']).optional(),
1048
+ usage: NormalizedUsageSchema.optional(),
1018
1049
  });
1019
1050
  /** How read-only was actually enforced per provider (§15, §19). Mirrors providers ReadOnlyFlag. */
1020
1051
  const ReadOnlyFlagSchema = z.enum(['plan', 'sandbox', 'none']);
@@ -1042,6 +1073,20 @@ export const RunMeta = z.object({
1042
1073
  repair: z.number().int().nonnegative(),
1043
1074
  planning: z.number().int().nonnegative(),
1044
1075
  }).optional(),
1076
+ usage_totals: z.object({
1077
+ inputTokens: z.number().int().nonnegative(),
1078
+ outputTokens: z.number().int().nonnegative(),
1079
+ reportedCalls: z.number().int().nonnegative(),
1080
+ estimatedCalls: z.number().int().nonnegative(),
1081
+ reportedCostUsd: z.number().nonnegative().optional(),
1082
+ }).optional(),
1083
+ // v7 Phase B: present only when the user ran `--mode auto`; records the resolved mode + why.
1084
+ auto_decision: z.object({
1085
+ resolved: z.enum(['quick', 'council']),
1086
+ reasons: z.array(z.string()),
1087
+ fast_path: z.boolean().optional(),
1088
+ escalation_reasons: z.array(z.string().min(1)).optional(),
1089
+ }).optional(),
1045
1090
  exit_status: z.enum(['ok', 'failed', 'aborted', 'partial']),
1046
1091
  aborted: z.boolean(), // §16: Ctrl+C finalizes meta with aborted:true
1047
1092
  // §16 report-header flags; absent = none.
@@ -1051,6 +1096,7 @@ export const RunMeta = z.object({
1051
1096
  'weak_seat',
1052
1097
  'plan_skipped',
1053
1098
  'plan_fallback',
1099
+ 'plan_partial',
1054
1100
  'headless_intent',
1055
1101
  'verification_skipped',
1056
1102
  'research_ungrounded',