aiki-cli 0.3.2 → 0.3.3

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 +8 -3
  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 +45 -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
@@ -665,8 +665,27 @@ export const ClaimVerification = z.object({
665
665
  calculation_check: z.enum(['PASS', 'FAIL', 'NOT_APPLICABLE']).optional(),
666
666
  missing_evidence: z.array(z.string().min(1)),
667
667
  }).strict();
668
+ /** v6 semantic claim join: S8 may group claims that assert the same proposition in different
669
+ * words (SAME) or directly contradict each other (OPPOSES). `.catch(undefined)` keeps a
670
+ * malformed grouping from ever costing the verification set — groups are a bonus, never a risk. */
671
+ export const ClaimGroup = z.object({
672
+ ids: z.array(z.string().min(1)).min(2).max(8),
673
+ relation: z.enum(['SAME', 'OPPOSES']),
674
+ }).strict();
668
675
  export const ClaimVerificationSet = z.object({
669
676
  verifications: z.array(ClaimVerification),
677
+ claim_groups: z.array(ClaimGroup).max(12).optional().catch(undefined),
678
+ }).strict();
679
+ // ── v7 Phase D: targeted auto-mode challenge delta ─────────────────────────
680
+ export const ChallengeDelta = z.object({
681
+ claimId: z.string().min(1),
682
+ response: z.enum(['CONFIRM', 'COUNTER', 'NARROW', 'REPLACE', 'UNRESOLVED']),
683
+ reasoning: z.string().min(1),
684
+ newEvidenceIds: z.array(z.string().min(1)),
685
+ changedDecisionImpact: z.string().min(1),
686
+ }).strict();
687
+ export const ChallengeDeltaSet = z.object({
688
+ deltas: z.array(ChallengeDelta).max(3),
670
689
  }).strict();
671
690
  // ── R5: bounded, append-only rebuttal events ───────────────────────────────
672
691
  const RebuttalResponseBase = z.object({
@@ -1008,6 +1027,16 @@ export const QuickDecisionModel = z.object({
1008
1027
  // ── RunMeta (§15, §16) ──────────────────────────────────────────────────────
1009
1028
  //
1010
1029
  // Written by the artifact writer; assembled by the engine's RunCtx (T5). Internal → not strict.
1030
+ /** Per-call token accounting. `estimated:true` = local chars/4 estimate, never blended
1031
+ * silently with provider-reported numbers. */
1032
+ export const NormalizedUsageSchema = z.object({
1033
+ inputTokens: z.number().int().nonnegative().optional(),
1034
+ outputTokens: z.number().int().nonnegative().optional(),
1035
+ cacheReadTokens: z.number().int().nonnegative().optional(),
1036
+ cacheWriteTokens: z.number().int().nonnegative().optional(),
1037
+ estimated: z.boolean(),
1038
+ reportedCostUsd: z.number().nonnegative().optional(),
1039
+ });
1011
1040
  /** One provider call's accounting entry (§15 "per-call timings"). */
1012
1041
  export const CallRecord = z.object({
1013
1042
  provider: ProviderIdSchema,
@@ -1015,6 +1044,7 @@ export const CallRecord = z.object({
1015
1044
  category: z.enum(['discovery', 'verification', 'repair', 'planning']).optional(),
1016
1045
  durationMs: z.number().nonnegative(),
1017
1046
  error: z.enum(['NOT_FOUND', 'AUTH', 'QUOTA', 'TIMEOUT', 'BAD_OUTPUT', 'CRASH']).optional(),
1047
+ usage: NormalizedUsageSchema.optional(),
1018
1048
  });
1019
1049
  /** How read-only was actually enforced per provider (§15, §19). Mirrors providers ReadOnlyFlag. */
1020
1050
  const ReadOnlyFlagSchema = z.enum(['plan', 'sandbox', 'none']);
@@ -1042,6 +1072,20 @@ export const RunMeta = z.object({
1042
1072
  repair: z.number().int().nonnegative(),
1043
1073
  planning: z.number().int().nonnegative(),
1044
1074
  }).optional(),
1075
+ usage_totals: z.object({
1076
+ inputTokens: z.number().int().nonnegative(),
1077
+ outputTokens: z.number().int().nonnegative(),
1078
+ reportedCalls: z.number().int().nonnegative(),
1079
+ estimatedCalls: z.number().int().nonnegative(),
1080
+ reportedCostUsd: z.number().nonnegative().optional(),
1081
+ }).optional(),
1082
+ // v7 Phase B: present only when the user ran `--mode auto`; records the resolved mode + why.
1083
+ auto_decision: z.object({
1084
+ resolved: z.enum(['quick', 'council']),
1085
+ reasons: z.array(z.string()),
1086
+ fast_path: z.boolean().optional(),
1087
+ escalation_reasons: z.array(z.string().min(1)).optional(),
1088
+ }).optional(),
1045
1089
  exit_status: z.enum(['ok', 'failed', 'aborted', 'partial']),
1046
1090
  aborted: z.boolean(), // §16: Ctrl+C finalizes meta with aborted:true
1047
1091
  // §16 report-header flags; absent = none.
@@ -1051,6 +1095,7 @@ export const RunMeta = z.object({
1051
1095
  'weak_seat',
1052
1096
  'plan_skipped',
1053
1097
  'plan_fallback',
1098
+ 'plan_partial',
1054
1099
  'headless_intent',
1055
1100
  'verification_skipped',
1056
1101
  'research_ungrounded',