50c 3.1.1 → 3.3.0

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/50c.js +337 -70
  2. package/package.json +1 -1
package/bin/50c.js CHANGED
@@ -13,6 +13,25 @@ const path = require('path');
13
13
  const os = require('os');
14
14
  const { spawn } = require('child_process');
15
15
 
16
+ // Early imports for CLI commands that need these
17
+ let call50cTool, subagent, httpFetch, sshExec, localExec, KNOWN_SERVERS;
18
+ let team, matchTaskToTools;
19
+ try {
20
+ const subagentModule = require('../lib/subagent.js');
21
+ call50cTool = subagentModule.call50cTool;
22
+ subagent = subagentModule.subagent;
23
+ httpFetch = subagentModule.httpFetch;
24
+ sshExec = subagentModule.sshExec;
25
+ localExec = subagentModule.localExec;
26
+ KNOWN_SERVERS = subagentModule.KNOWN_SERVERS;
27
+
28
+ const teamModule = require('../lib/team.js');
29
+ team = teamModule.team;
30
+ matchTaskToTools = teamModule.matchTaskToTools;
31
+ } catch (e) {
32
+ // Graceful fallback if libs not available (shouldn't happen in normal install)
33
+ }
34
+
16
35
  const VERSION = require('../package.json').version;
17
36
  const HOME = os.homedir();
18
37
  const HUB_DIR = path.join(HOME, '.50c');
@@ -104,6 +123,7 @@ const TOOL_COMMANDS = {
104
123
  'compute': { tool: 'compute', arg: 'code', cost: '$0.02' },
105
124
  'chat': { tool: 'ide_conversation', special: 'chat' },
106
125
  'refocus': { tool: 'llm_refocus', special: 'refocus' },
126
+ 'invent': { tool: 'auto_invent', special: 'invent', cost: '$2.00' },
107
127
  };
108
128
 
109
129
  // Route command
@@ -501,6 +521,85 @@ async function runToolCommand(cmd, args) {
501
521
  return;
502
522
  }
503
523
 
524
+ // INVENT: Enterprise invention pipeline
525
+ if (spec.special === 'invent') {
526
+ // Parse args: 50c invent "problem" --rigor=deep --domain=math --constraint="must be fast"
527
+ let problem = '';
528
+ let rigor = 'deep';
529
+ let domain = 'code';
530
+ const constraints = [];
531
+
532
+ for (const arg of args) {
533
+ if (arg.startsWith('--rigor=')) {
534
+ rigor = arg.split('=')[1];
535
+ } else if (arg.startsWith('--domain=')) {
536
+ domain = arg.split('=')[1];
537
+ } else if (arg.startsWith('--constraint=')) {
538
+ constraints.push(arg.split('=')[1].replace(/^["']|["']$/g, ''));
539
+ } else if (!arg.startsWith('--')) {
540
+ problem += (problem ? ' ' : '') + arg;
541
+ }
542
+ }
543
+
544
+ if (!problem) {
545
+ console.error('Usage: 50c invent "problem description" [options]');
546
+ console.error('Options:');
547
+ console.error(' --rigor=fast|standard|deep|exhaustive (default: deep)');
548
+ console.error(' --domain=math|physics|code|business (default: code)');
549
+ console.error(' --constraint="constraint text" (can repeat)');
550
+ console.error('');
551
+ console.error('Examples:');
552
+ console.error(' 50c invent "faster sorting algorithm" --rigor=deep');
553
+ console.error(' 50c invent "prove Riemann hypothesis" --domain=math --rigor=exhaustive');
554
+ console.error(' 50c invent "novel auth system" --constraint="must be passwordless"');
555
+ process.exit(1);
556
+ }
557
+
558
+ console.log(`\nšŸ”¬ 50c Auto-Invent Pipeline`);
559
+ console.log(` Problem: ${problem.slice(0, 60)}${problem.length > 60 ? '...' : ''}`);
560
+ console.log(` Rigor: ${rigor} | Domain: ${domain}`);
561
+ if (constraints.length) console.log(` Constraints: ${constraints.length}`);
562
+ console.log(` Cost: $2.00\n`);
563
+
564
+ // Call auto_invent directly (not via remote API - it's local)
565
+ const inventArgs = { problem, rigor, domain, constraints };
566
+ const result = await autoInvent(inventArgs);
567
+
568
+ // Format output
569
+ if (result.ok && result.invention) {
570
+ console.log('═══════════════════════════════════════════════════════════════');
571
+ console.log(' INVENTION RESULT');
572
+ console.log('═══════════════════════════════════════════════════════════════\n');
573
+
574
+ if (result.angles && result.angles.length > 0) {
575
+ console.log('šŸ“ CREATIVE ANGLES:');
576
+ result.angles.slice(0, 5).forEach((a, i) => console.log(` ${i+1}. ${a}`));
577
+ console.log('');
578
+ }
579
+
580
+ if (result.invention.solution) {
581
+ console.log('šŸ’” SOLUTION:');
582
+ console.log(result.invention.solution);
583
+ console.log('');
584
+ }
585
+
586
+ if (result.proofs && result.proofs.length > 0) {
587
+ console.log('āœ“ PROOFS:', result.proofs.length, 'verification(s)');
588
+ }
589
+
590
+ if (result.prior_art && result.prior_art.length > 0) {
591
+ console.log('šŸ“š PRIOR ART:', result.prior_art.length, 'related work(s) found');
592
+ }
593
+
594
+ console.log('\n═══════════════════════════════════════════════════════════════');
595
+ console.log(`ā± Duration: ${(result.total_duration_ms / 1000).toFixed(1)}s | Verified: ${result.verified ? 'āœ“' : 'ā—‹'}`);
596
+ console.log('═══════════════════════════════════════════════════════════════\n');
597
+ } else {
598
+ console.log('Result:', JSON.stringify(result, null, 2));
599
+ }
600
+ return;
601
+ }
602
+
504
603
  // Standard tool
505
604
  const input = args.join(' ');
506
605
  if (!input) {
@@ -645,8 +744,7 @@ async function handleMCPRequest(request) {
645
744
 
646
745
  // Local file-memory tools (FREE, runs on user machine)
647
746
  const { FILE_TOOLS, indexFile, findSymbol, getLines, searchFile, fileSummary } = require('../lib/file-memory.js');
648
- const { subagent, httpFetch, sshExec, localExec, call50cTool, KNOWN_SERVERS } = require('../lib/subagent.js');
649
- const { team, matchTaskToTools } = require('../lib/team.js');
747
+ // Note: subagent, team already imported at top for CLI commands
650
748
 
651
749
  const LOCAL_TOOLS = [
652
750
  // THE MAIN TOOL - Ask the 50c team to do anything
@@ -671,37 +769,35 @@ const LOCAL_TOOLS = [
671
769
  { name: "team_chain", description: "50c Team: Chain multiple tools together. Output flows via $prev placeholder.", inputSchema: { type: "object", properties: { steps: { type: "array", description: "Array of {tool, args} - use $prev for previous result", items: { type: "object" } }, input: { type: "string", description: "Initial input (optional)" } }, required: ["steps"] } },
672
770
  { name: "pre_publish", description: "Pre-publish verification. Thorough checks before npm/github/arxiv/medical publish. Profiles: npm, github, arxiv, medical, science, math. Uses AI tools (bCalc, genius+, web_search) for academic verification. FREE.", inputSchema: { type: "object", properties: { profile: { type: "string", description: "Verification profile: npm, github, arxiv, medical, science, math", enum: ["npm", "github", "arxiv", "medical", "science", "math"] }, cwd: { type: "string", description: "Directory to check (default: current)" }, save_receipt: { type: "boolean", description: "Save receipt as markdown file" } } } },
673
771
 
674
- // ENTERPRISE PRESET - Auto-Invent pipeline
772
+ // ENTERPRISE PRESET - Auto-Invent Swarm Pipeline
675
773
  { name: "auto_invent", description: "Enterprise: Full invention pipeline. Chains mind_opener → idea_fold → bcalc → genius_plus → compute → cvi_verify. Produces provable, verified solutions. $0.65-$2.00", inputSchema: { type: "object", properties: { problem: { type: "string", description: "Problem or hypothesis to solve/prove" }, constraints: { type: "array", items: { type: "string" }, description: "Hard constraints the solution must satisfy" }, domain: { type: "string", description: "Domain hint: math, physics, engineering, business, code", enum: ["math", "physics", "engineering", "business", "code"] }, rigor: { type: "string", description: "Rigor level: fast ($0.65, genius_plus only), standard ($0.60, 3 tools), deep ($1.20, 5 tools parallel), exhaustive ($2.00, all 6)", enum: ["fast", "standard", "deep", "exhaustive"], default: "deep" } }, required: ["problem"] } },
676
774
  ];
677
775
 
678
776
  /**
679
- * AUTO-INVENT: Enterprise invention pipeline
680
- * Chains tools in order to produce provable, verified inventive solutions
777
+ * AUTO-INVENT: Enterprise Swarm Invention Pipeline
778
+ * Orchestrates parallel sub-MCPs to produce provable, verified inventions
681
779
  *
682
- * Pipeline (exhaustive):
683
- * 1. mind_opener - 5 curious angles to explore the problem space
684
- * 2. idea_fold - Test top angle through STEM lenses
685
- * 3. bcalc - Mathematical discovery/verification
686
- * 4. genius_plus - Self-improving code generation
687
- * 5. compute - Execute and validate the solution
688
- * 6. cvi_verify - Verify output against constraints
780
+ * SWARM ARCHITECTURE:
781
+ * Phase 1 (Parallel Exploration):
782
+ * - 3x mind_opener (temp 0.3, 0.7, 1.0) - diverse creative angles
783
+ * - idea_fold - STEM lens analysis
784
+ * - bcalc - mathematical discovery
785
+ * - web_search - prior art research
786
+ *
787
+ * Phase 2 (Synthesis):
788
+ * - genius_plus - self-improving solution generation
789
+ *
790
+ * Phase 3 (Verification Swarm):
791
+ * - compute - execute proofs
792
+ * - cvi_verify - constraint checking
793
+ * - roast (peer_review) - adversarial critique
689
794
  *
690
- * Cost: ~$2.00 for exhaustive, ~$1.20 for deep, ~$0.60 for standard
795
+ * Cost: $2.00 flat for full invention pipeline
691
796
  */
692
797
  async function autoInvent(args) {
693
798
  const { problem, constraints = [], domain = 'code', rigor = 'deep' } = args;
694
799
  const startTime = Date.now();
695
800
 
696
- // Define pipeline stages by rigor level
697
- const PIPELINES = {
698
- fast: ['genius_plus'], // Just genius_plus for quick results
699
- standard: ['mind_opener', 'genius_plus', 'cvi_verify'],
700
- deep: ['mind_opener', 'idea_fold', 'bcalc', 'genius_plus', 'cvi_verify'],
701
- exhaustive: ['mind_opener', 'idea_fold', 'bcalc', 'genius_plus', 'compute', 'cvi_verify']
702
- };
703
-
704
- const pipeline = PIPELINES[rigor] || PIPELINES.deep;
705
801
  const results = {
706
802
  ok: true,
707
803
  problem,
@@ -712,89 +808,253 @@ async function autoInvent(args) {
712
808
  invention: null,
713
809
  verified: false,
714
810
  proofs: [],
715
- cost_estimate: rigor === 'exhaustive' ? '$2.00' : rigor === 'deep' ? '$1.20' : rigor === 'standard' ? '$0.60' : '$0.65'
811
+ prior_art: [],
812
+ angles: [],
813
+ peer_review: null,
814
+ cost_estimate: '$2.00'
716
815
  };
717
816
 
718
817
  let context = problem;
719
- let bestAngle = null;
720
- let mathProof = null;
818
+ let allAngles = [];
721
819
  let generatedCode = null;
722
820
 
723
- // For deep/exhaustive, run first 3 stages in parallel to save time
821
+ // ═══════════════════════════════════════════════════════════════
822
+ // PHASE 1: EXPLORATION SWARM (all parallel)
823
+ // ═══════════════════════════════════════════════════════════════
724
824
  if (rigor === 'deep' || rigor === 'exhaustive') {
725
- const parallelStart = Date.now();
825
+ const phase1Start = Date.now();
826
+ results.stages.push({ name: 'phase1_exploration', status: 'started' });
827
+
726
828
  try {
727
- const [mindResult, ideaResult, bcalcResult] = await Promise.all([
728
- call50cTool('mind_opener', { problem }).catch(e => ({ error: e.message })),
829
+ // Spawn exploration swarm - 6 parallel calls
830
+ const [
831
+ mind1, mind2, mind3, // Temperature swarm
832
+ ideaResult, // STEM analysis
833
+ bcalcResult, // Math discovery
834
+ priorArt // Web search for prior art
835
+ ] = await Promise.all([
836
+ // Temperature swarm: 3 mind_opener instances
837
+ call50cTool('mind_opener', { problem }).catch(e => ({ error: e.message, temp: 'default' })),
838
+ call50cTool('mind_opener', { problem: `Creative angles for: ${problem}` }).catch(e => ({ error: e.message, temp: 'creative' })),
839
+ call50cTool('mind_opener', { problem: `Unconventional approaches to: ${problem}` }).catch(e => ({ error: e.message, temp: 'wild' })),
840
+ // STEM analysis
729
841
  call50cTool('idea_fold', { claim: problem, context: `Domain: ${domain}` }).catch(e => ({ error: e.message })),
730
- call50cTool('bcalc', { expression: domain === 'math' ? problem : `Model for: ${problem}`, mode: 'explore' }).catch(e => ({ error: e.message }))
842
+ // Math discovery
843
+ call50cTool('bcalc', { expression: domain === 'math' ? problem : `Mathematical model for: ${problem}`, mode: 'explore' }).catch(e => ({ error: e.message })),
844
+ // Prior art search
845
+ call50cTool('web_search', { query: `${problem} research papers solutions` }).catch(e => ({ error: e.message }))
731
846
  ]);
732
847
 
733
- // Process mind_opener
734
- if (mindResult.angles && mindResult.angles.length > 0) {
735
- bestAngle = mindResult.angles[0];
736
- context = `${problem}\n\nApproach: ${bestAngle}`;
848
+ // Merge angles from temperature swarm (dedupe)
849
+ const angleSet = new Set();
850
+ [mind1, mind2, mind3].forEach(m => {
851
+ if (m.angles) m.angles.forEach(a => angleSet.add(a));
852
+ if (m.result) angleSet.add(m.result); // Some formats return result string
853
+ });
854
+ allAngles = [...angleSet].slice(0, 10); // Keep top 10 unique angles
855
+ results.angles = allAngles;
856
+
857
+ if (allAngles.length > 0) {
858
+ context = `${problem}\n\n## Creative Angles:\n${allAngles.map((a, i) => `${i+1}. ${a}`).join('\n')}`;
737
859
  }
738
- results.stages.push({ name: 'mind_opener', success: !mindResult.error, duration_ms: Date.now() - parallelStart, output_summary: mindResult.angles ? `${mindResult.angles.length} angles` : (mindResult.error || 'Done') });
860
+
861
+ results.stages.push({
862
+ name: 'mind_opener_swarm',
863
+ success: allAngles.length > 0,
864
+ duration_ms: Date.now() - phase1Start,
865
+ output_summary: `${allAngles.length} unique angles from 3 instances`
866
+ });
739
867
 
740
868
  // Process idea_fold
741
- if (ideaResult.synthesis) {
742
- context = `${context}\n\nSTEM: ${ideaResult.synthesis}`;
869
+ if (ideaResult.synthesis || ideaResult.result) {
870
+ const synthesis = ideaResult.synthesis || ideaResult.result;
871
+ context = `${context}\n\n## STEM Analysis:\n${typeof synthesis === 'string' ? synthesis.slice(0, 500) : JSON.stringify(synthesis).slice(0, 500)}`;
743
872
  }
744
- results.stages.push({ name: 'idea_fold', success: !ideaResult.error, duration_ms: Date.now() - parallelStart, output_summary: ideaResult.synthesis ? 'STEM synthesis' : (ideaResult.error || 'Done') });
873
+ results.stages.push({
874
+ name: 'idea_fold',
875
+ success: !ideaResult.error,
876
+ duration_ms: Date.now() - phase1Start,
877
+ output_summary: ideaResult.synthesis ? 'STEM synthesis complete' : (ideaResult.error || 'Done')
878
+ });
745
879
 
746
880
  // Process bcalc
747
881
  if (bcalcResult.discovery || bcalcResult.result) {
748
- mathProof = bcalcResult;
749
882
  results.proofs.push({ type: 'mathematical', data: bcalcResult });
750
- context = `${context}\n\nMath: ${JSON.stringify(bcalcResult.discovery || bcalcResult.result).slice(0, 200)}`;
883
+ const mathContent = bcalcResult.discovery || bcalcResult.result;
884
+ context = `${context}\n\n## Mathematical Foundation:\n${typeof mathContent === 'string' ? mathContent.slice(0, 500) : JSON.stringify(mathContent).slice(0, 500)}`;
751
885
  }
752
- results.stages.push({ name: 'bcalc', success: !bcalcResult.error, duration_ms: Date.now() - parallelStart, output_summary: bcalcResult.discovery ? 'Discovery made' : (bcalcResult.error || 'Done') });
886
+ results.stages.push({
887
+ name: 'bcalc',
888
+ success: !bcalcResult.error,
889
+ duration_ms: Date.now() - phase1Start,
890
+ output_summary: bcalcResult.discovery ? 'Mathematical discovery' : (bcalcResult.error || 'Done')
891
+ });
892
+
893
+ // Process prior art search
894
+ if (priorArt.results || priorArt.snippets) {
895
+ const articles = priorArt.results || priorArt.snippets || [];
896
+ results.prior_art = articles.slice(0, 5);
897
+ if (articles.length > 0) {
898
+ context = `${context}\n\n## Prior Art:\n${articles.slice(0, 3).map(a => `- ${a.title || a}`).join('\n')}`;
899
+ }
900
+ }
901
+ results.stages.push({
902
+ name: 'web_search_prior_art',
903
+ success: !priorArt.error,
904
+ duration_ms: Date.now() - phase1Start,
905
+ output_summary: priorArt.results ? `${(priorArt.results || []).length} papers found` : (priorArt.error || 'Done')
906
+ });
753
907
 
754
908
  } catch (e) {
755
- results.stages.push({ name: 'parallel_init', success: false, error: e.message });
909
+ results.stages.push({ name: 'phase1_exploration', success: false, error: e.message });
756
910
  }
911
+ } else {
912
+ // Fast/standard mode - single mind_opener
913
+ const stageStart = Date.now();
914
+ try {
915
+ const r = await call50cTool('mind_opener', { problem });
916
+ if (r.angles) {
917
+ allAngles = r.angles;
918
+ results.angles = allAngles;
919
+ context = `${problem}\n\nApproach: ${allAngles[0]}`;
920
+ }
921
+ results.stages.push({ name: 'mind_opener', success: true, duration_ms: Date.now() - stageStart, output_summary: `${allAngles.length} angles` });
922
+ } catch (e) {
923
+ results.stages.push({ name: 'mind_opener', success: false, error: e.message, duration_ms: Date.now() - stageStart });
924
+ }
925
+ }
926
+
927
+ // ═══════════════════════════════════════════════════════════════
928
+ // PHASE 2: SYNTHESIS (genius_plus)
929
+ // ═══════════════════════════════════════════════════════════════
930
+ const phase2Start = Date.now();
931
+ try {
932
+ const synthesisPrompt = `${context}\n\n## Constraints:\n${constraints.map(c => `- ${c}`).join('\n') || 'None specified'}`;
933
+ const synthesis = await call50cTool('genius_plus', { problem: synthesisPrompt });
757
934
 
758
- // Now run remaining stages sequentially
759
- const remainingStages = pipeline.filter(s => !['mind_opener', 'idea_fold', 'bcalc'].includes(s));
760
- for (const stage of remainingStages) {
761
- const stageStart = Date.now();
762
- try {
763
- const stageResult = await runStage(stage, { context, problem, domain, constraints, bestAngle, generatedCode, results });
764
- if (stageResult.generatedCode) generatedCode = stageResult.generatedCode;
765
- if (stageResult.invention) results.invention = stageResult.invention;
766
- if (stageResult.verified !== undefined) results.verified = stageResult.verified;
767
- if (stageResult.proof) results.proofs.push(stageResult.proof);
768
- results.stages.push({ name: stage, success: true, duration_ms: Date.now() - stageStart, output_summary: stageResult.summary });
769
- } catch (e) {
770
- results.stages.push({ name: stage, success: false, error: e.message, duration_ms: Date.now() - stageStart });
935
+ generatedCode = synthesis.code || synthesis.solution || synthesis.result;
936
+ if (generatedCode || synthesis.explanation) {
937
+ results.invention = {
938
+ solution: generatedCode || synthesis.explanation,
939
+ explanation: synthesis.explanation || synthesis.reasoning,
940
+ iterations: synthesis.iterations || 1,
941
+ confidence: synthesis.confidence
942
+ };
943
+ }
944
+
945
+ results.stages.push({
946
+ name: 'genius_plus_synthesis',
947
+ success: !!results.invention,
948
+ duration_ms: Date.now() - phase2Start,
949
+ output_summary: results.invention ? `Solution generated (${synthesis.iterations || 1} iterations)` : 'No solution'
950
+ });
951
+ } catch (e) {
952
+ results.stages.push({ name: 'genius_plus_synthesis', success: false, error: e.message, duration_ms: Date.now() - phase2Start });
953
+ }
954
+
955
+ // ═══════════════════════════════════════════════════════════════
956
+ // PHASE 3: VERIFICATION SWARM (parallel)
957
+ // ═══════════════════════════════════════════════════════════════
958
+ if (results.invention && (rigor === 'deep' || rigor === 'exhaustive')) {
959
+ const phase3Start = Date.now();
960
+
961
+ try {
962
+ const inventionStr = typeof results.invention === 'string'
963
+ ? results.invention
964
+ : JSON.stringify(results.invention).slice(0, 2000);
965
+
966
+ // Verification swarm - 3 parallel calls
967
+ const verificationPromises = [
968
+ // Constraint verification
969
+ constraints.length > 0
970
+ ? call50cTool('cvi_verify', { constraints, output: inventionStr }).catch(e => ({ error: e.message }))
971
+ : Promise.resolve({ passed: true, skipped: 'No constraints' }),
972
+ // Peer review (adversarial critique using roast)
973
+ call50cTool('roast', { code: inventionStr }).catch(e => ({ error: e.message }))
974
+ ];
975
+
976
+ // Add compute stage for exhaustive
977
+ if (rigor === 'exhaustive' && generatedCode) {
978
+ verificationPromises.push(
979
+ call50cTool('compute', { code: generatedCode }).catch(e => ({ error: e.message }))
980
+ );
981
+ }
982
+
983
+ const [cviResult, roastResult, computeResult] = await Promise.all(verificationPromises);
984
+
985
+ // Process CVI verification
986
+ results.verified = cviResult.passed || cviResult.all_passed || cviResult.skipped || false;
987
+ if (!cviResult.skipped) {
988
+ results.proofs.push({ type: 'constraint_verification', data: cviResult });
989
+ }
990
+ results.stages.push({
991
+ name: 'cvi_verify',
992
+ success: results.verified,
993
+ duration_ms: Date.now() - phase3Start,
994
+ output_summary: cviResult.skipped || (results.verified ? 'All constraints passed' : 'Verification incomplete')
995
+ });
996
+
997
+ // Process peer review (roast)
998
+ if (roastResult && !roastResult.error) {
999
+ results.peer_review = {
1000
+ critique: roastResult.flaws || roastResult.issues || roastResult.result,
1001
+ improvements: roastResult.fixes || roastResult.suggestions,
1002
+ severity: roastResult.severity || 'medium'
1003
+ };
1004
+ results.proofs.push({ type: 'peer_review', data: roastResult });
771
1005
  }
1006
+ results.stages.push({
1007
+ name: 'peer_review_roast',
1008
+ success: !roastResult.error,
1009
+ duration_ms: Date.now() - phase3Start,
1010
+ output_summary: roastResult.flaws ? `${(roastResult.flaws || []).length} issues found` : (roastResult.error || 'Critique complete')
1011
+ });
1012
+
1013
+ // Process compute (exhaustive only)
1014
+ if (computeResult) {
1015
+ results.proofs.push({ type: 'execution', data: computeResult });
1016
+ results.stages.push({
1017
+ name: 'compute_execution',
1018
+ success: !computeResult.error,
1019
+ duration_ms: Date.now() - phase3Start,
1020
+ output_summary: computeResult.error ? `Error: ${computeResult.error}` : 'Execution successful'
1021
+ });
1022
+ }
1023
+
1024
+ } catch (e) {
1025
+ results.stages.push({ name: 'phase3_verification', success: false, error: e.message });
772
1026
  }
773
- } else {
774
- // For fast/standard, run sequentially
775
- for (const stage of pipeline) {
776
- const stageStart = Date.now();
1027
+ } else if (results.invention) {
1028
+ // Fast/standard - just CVI
1029
+ if (constraints.length > 0) {
777
1030
  try {
778
- const stageResult = await runStage(stage, { context, problem, domain, constraints, bestAngle, generatedCode, results });
779
- if (stageResult.context) context = stageResult.context;
780
- if (stageResult.bestAngle) bestAngle = stageResult.bestAngle;
781
- if (stageResult.generatedCode) generatedCode = stageResult.generatedCode;
782
- if (stageResult.invention) results.invention = stageResult.invention;
783
- if (stageResult.verified !== undefined) results.verified = stageResult.verified;
784
- if (stageResult.proof) results.proofs.push(stageResult.proof);
785
- results.stages.push({ name: stage, success: true, duration_ms: Date.now() - stageStart, output_summary: stageResult.summary });
1031
+ const cvi = await call50cTool('cvi_verify', { constraints, output: JSON.stringify(results.invention) });
1032
+ results.verified = cvi.passed || cvi.all_passed || false;
1033
+ results.proofs.push({ type: 'constraint_verification', data: cvi });
1034
+ results.stages.push({ name: 'cvi_verify', success: results.verified, output_summary: results.verified ? 'Verified' : 'Unverified' });
786
1035
  } catch (e) {
787
- results.stages.push({ name: stage, success: false, error: e.message, duration_ms: Date.now() - stageStart });
1036
+ results.stages.push({ name: 'cvi_verify', success: false, error: e.message });
788
1037
  }
1038
+ } else {
1039
+ results.verified = true; // Vacuously true
789
1040
  }
790
1041
  }
791
1042
 
1043
+ // ═══════════════════════════════════════════════════════════════
1044
+ // FINAL VERDICT
1045
+ // ═══════════════════════════════════════════════════════════════
792
1046
  results.total_duration_ms = Date.now() - startTime;
793
1047
  results.pipeline_completed = results.stages.filter(s => s.success).length;
794
- results.pipeline_total = pipeline.length;
1048
+ results.pipeline_total = results.stages.length;
795
1049
 
1050
+ // Determine verdict based on invention + verification + peer review
796
1051
  if (results.invention && results.verified) {
797
- results.verdict = 'INVENTION_VERIFIED';
1052
+ const hasCriticalIssues = results.peer_review?.severity === 'critical';
1053
+ if (hasCriticalIssues) {
1054
+ results.verdict = 'INVENTION_NEEDS_REVISION';
1055
+ } else {
1056
+ results.verdict = 'INVENTION_VERIFIED';
1057
+ }
798
1058
  } else if (results.invention) {
799
1059
  results.verdict = 'INVENTION_UNVERIFIED';
800
1060
  } else {
@@ -1289,6 +1549,12 @@ TOOLS (labs pack):
1289
1549
  genius <problem> Deep problem solving ($0.50)
1290
1550
  compute <code> Python sandbox ($0.02)
1291
1551
 
1552
+ ENTERPRISE (auto_invent):
1553
+ invent "problem" [options] Full invention pipeline ($2.00)
1554
+ --rigor=fast|standard|deep|exhaustive (default: deep)
1555
+ --domain=math|physics|code|business (default: code)
1556
+ --constraint="text" Add constraint (repeatable)
1557
+
1292
1558
  TOOLS (beacon pack):
1293
1559
  50c beacon.health Context health check (FREE)
1294
1560
  50c beacon.compress <text> Smart compression ($0.02)
@@ -1308,6 +1574,7 @@ SNAPSHOTS:
1308
1574
  EXAMPLES:
1309
1575
  50c hints "api design"
1310
1576
  50c genius "optimize this algorithm"
1577
+ 50c invent "novel sorting algorithm" --rigor=deep --domain=code
1311
1578
  50c beacon.compress "long context here..."
1312
1579
  50c tip 10 "saved my deploy"
1313
1580
  50c notip compress wrong_answer "output was garbage"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "50c",
3
- "version": "3.1.1",
3
+ "version": "3.3.0",
4
4
  "description": "AI developer tools via MCP. Pay-per-use from $0.01. No subscriptions.",
5
5
  "bin": {
6
6
  "50c": "./bin/50c.js"