sinapse-ai 7.4.6 → 7.5.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 (29) hide show
  1. package/.claude/CLAUDE.md +10 -7
  2. package/.claude/rules/documentation-first.md +77 -0
  3. package/.claude/rules/mandatory-delegation.md +96 -0
  4. package/.codex/instructions.md +2 -1
  5. package/.sinapse-ai/constitution.md +59 -6
  6. package/.sinapse-ai/core/doctor/checks/constitution-consistency.js +116 -0
  7. package/.sinapse-ai/core/doctor/checks/index.js +10 -2
  8. package/.sinapse-ai/core/doctor/index.js +4 -3
  9. package/.sinapse-ai/core/health-check/checks/project/constitution-consistency.js +157 -0
  10. package/.sinapse-ai/core/health-check/checks/project/index.js +2 -0
  11. package/.sinapse-ai/data/entity-registry.yaml +807 -777
  12. package/.sinapse-ai/data/registry-update-log.jsonl +16 -0
  13. package/.sinapse-ai/development/tasks/dev-develop-story.md +14 -6
  14. package/.sinapse-ai/development/tasks/health-check.yaml +2 -2
  15. package/.sinapse-ai/development/templates/chrome-brain/knowledge-base/claude-in-chrome.md +62 -0
  16. package/.sinapse-ai/install-manifest.yaml +29 -17
  17. package/.sinapse-ai/product/templates/ide-rules/claude-rules.md +10 -6
  18. package/README.en.md +10 -8
  19. package/README.md +10 -8
  20. package/bin/modules/chrome-brain-installer.js +173 -33
  21. package/bin/sinapse.js +8 -0
  22. package/docs/framework/memory-lifecycle.md +1 -1
  23. package/docs/getting-started.md +2 -2
  24. package/docs/guides/user-guide.md +9 -7
  25. package/docs/guides/workflows/xref-phase6-supporting.md +1 -1
  26. package/docs/guides/workflows-guide.md +1 -1
  27. package/package.json +1 -1
  28. package/packages/sinapse-install/src/capabilities/chrome-brain.js +190 -16
  29. package/squads/claude-code-mastery/agents/project-integrator.md +1 -1
@@ -347,14 +347,19 @@ function writeJson(filePath, data) {
347
347
  * Preserves all existing hooks — only replaces entries with matching matchers.
348
348
  */
349
349
  function mergeHooks() {
350
+ const binDir = getBinDir(detectOS());
351
+ const ensureCmd = path.join(binDir, 'chrome-ensure').replace(/\\/g, '/');
352
+ const logCmd = path.join(binDir, 'chrome-brain-log').replace(/\\/g, '/');
350
353
  const newHooks = {
351
354
  PreToolUse: [
352
- { matcher: 'mcp__chrome-devtools__*', hooks: [{ type: 'command', command: 'chrome-ensure' }] },
353
- { matcher: 'mcp__claude-in-chrome__*', hooks: [{ type: 'command', command: 'chrome-ensure' }] },
355
+ { matcher: 'mcp__chrome-devtools__*', hooks: [{ type: 'command', command: ensureCmd }] },
356
+ { matcher: 'mcp__claude-in-chrome__*', hooks: [{ type: 'command', command: ensureCmd }] },
357
+ { matcher: 'mcp__dev-browser__*', hooks: [{ type: 'command', command: ensureCmd }] },
354
358
  ],
355
359
  PostToolUse: [
356
- { matcher: 'mcp__chrome-devtools__*', hooks: [{ type: 'command', command: 'chrome-brain-log' }] },
357
- { matcher: 'mcp__claude-in-chrome__*', hooks: [{ type: 'command', command: 'chrome-brain-log' }] },
360
+ { matcher: 'mcp__chrome-devtools__*', hooks: [{ type: 'command', command: logCmd }] },
361
+ { matcher: 'mcp__claude-in-chrome__*', hooks: [{ type: 'command', command: logCmd }] },
362
+ { matcher: 'mcp__dev-browser__*', hooks: [{ type: 'command', command: logCmd }] },
358
363
  ],
359
364
  };
360
365
 
@@ -375,14 +380,20 @@ function mergeHooks() {
375
380
  }
376
381
 
377
382
  /**
378
- * Adds Chrome DevTools MCP server to ~/.claude.json.
383
+ * Adds Chrome DevTools and dev-browser MCP servers to ~/.claude.json.
384
+ * Does NOT add claude-in-chrome — that extension manages its own MCP registration.
385
+ *
386
+ * @param {Object} osInfo - OS detection result from detectOS()
387
+ * @returns {string[]} List of errors (empty on success)
379
388
  */
380
389
  function mergeMcpConfig(osInfo) {
381
390
  const config = readJsonSafe(CLAUDE_JSON);
382
391
  if (!config.mcpServers) {
383
392
  config.mcpServers = {};
384
393
  }
394
+ const errors = [];
385
395
 
396
+ // --- Chrome DevTools MCP ---
386
397
  if (osInfo.type === OS_TYPE.WINDOWS) {
387
398
  config.mcpServers['chrome-devtools'] = {
388
399
  command: 'cmd',
@@ -395,7 +406,36 @@ function mergeMcpConfig(osInfo) {
395
406
  };
396
407
  }
397
408
 
409
+ // --- dev-browser MCP (Story 7.4.2) ---
410
+ // Install dev-browser globally first
411
+ try {
412
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
413
+ execSync(`${npmCmd} install -g dev-browser`, { stdio: 'pipe', timeout: 120000 });
414
+ LOG.ok('dev-browser installed globally');
415
+ } catch (err) {
416
+ const msg = `dev-browser global install failed: ${err.message}. Manual install: npm install -g dev-browser`;
417
+ LOG.warn(msg);
418
+ errors.push('dev-browser-install');
419
+ // Do NOT throw — continue with rest of install
420
+ }
421
+
422
+ // Add dev-browser MCP entry regardless (user may install manually later)
423
+ if (osInfo.type === OS_TYPE.WINDOWS) {
424
+ config.mcpServers['dev-browser'] = {
425
+ command: 'cmd',
426
+ args: ['/c', 'dev-browser', '--connect'],
427
+ env: { CDP_URL: 'http://127.0.0.1:9222' },
428
+ };
429
+ } else {
430
+ config.mcpServers['dev-browser'] = {
431
+ command: 'dev-browser',
432
+ args: ['--connect'],
433
+ env: { CDP_URL: 'http://127.0.0.1:9222' },
434
+ };
435
+ }
436
+
398
437
  writeJson(CLAUDE_JSON, config);
438
+ return errors;
399
439
  }
400
440
 
401
441
  // ---------------------------------------------------------------------------
@@ -511,6 +551,21 @@ Quando encontrar barreira:
511
551
 
512
552
  ---
513
553
 
554
+ ## Browser Automation Tool Selection
555
+
556
+ | Task | Preferred Tool | Why |
557
+ |------|---------------|-----|
558
+ | Navigate, click, fill form | chrome-devtools-mcp (CDP) | Fastest, direct browser control |
559
+ | Screenshot, Lighthouse audit | chrome-devtools-mcp (CDP) | Built-in |
560
+ | Scraping with JS logic | dev-browser (Playwright) | evaluate(), full DOM access |
561
+ | Batch / loops / headless | dev-browser (Playwright) | Headless mode supported |
562
+ | Cross-origin iframes | dev-browser or CDP Input events | CDP has InputEvent.dispatch |
563
+ | Visual fallback, coordinates | claude-in-chrome extension | Screen-level computer use |
564
+
565
+ **Priority:** CDP > dev-browser > claude-in-chrome
566
+
567
+ ---
568
+
514
569
  ## Learnings Log
515
570
 
516
571
  > Secao atualizada automaticamente quando NSN Mode resolve problemas novos.
@@ -518,6 +573,76 @@ Quando encontrar barreira:
518
573
  `;
519
574
  }
520
575
 
576
+ /**
577
+ * Returns the content for the claude-in-chrome KB file.
578
+ * Provides setup instructions since the extension cannot be auto-installed.
579
+ */
580
+ function getClaudeInChromeKbContent() {
581
+ return `# claude-in-chrome — Chrome Extension for Visual Browser Interaction
582
+
583
+ > Manual install required. This extension cannot be auto-installed via CLI.
584
+
585
+ ---
586
+
587
+ ## What It Does
588
+
589
+ claude-in-chrome is a Chrome extension that acts as an MCP server directly from
590
+ within Chrome. It exposes browser automation tools via a local WebSocket, enabling
591
+ screen-level visual interaction (computer use) as a fallback when CDP and Playwright
592
+ cannot handle a task (e.g., complex visual layouts, canvas elements, iframes).
593
+
594
+ ---
595
+
596
+ ## Installation
597
+
598
+ 1. Open Chrome and navigate to the Chrome Web Store
599
+ 2. Search for "claude-in-chrome" or visit:
600
+ https://chromewebstore.google.com/detail/claude-in-chrome
601
+ 3. Click "Add to Chrome" and confirm
602
+ 4. The extension icon should appear in the Chrome toolbar
603
+ 5. Click the extension icon and follow the setup wizard
604
+
605
+ ---
606
+
607
+ ## MCP Configuration
608
+
609
+ The extension manages its own MCP registration automatically after install.
610
+ **Do NOT** manually add a "claude-in-chrome" entry to ~/.claude.json.
611
+
612
+ If the extension is installed and Chrome is running with debug port 9222,
613
+ claude-in-chrome tools will be available to Claude Code automatically.
614
+
615
+ ---
616
+
617
+ ## When to Use
618
+
619
+ | Scenario | Use claude-in-chrome? |
620
+ |----------|----------------------|
621
+ | CDP tools handle the task | No — use chrome-devtools-mcp |
622
+ | Playwright can scrape/interact | No — use dev-browser |
623
+ | Complex visual layout, canvas, WebGL | Yes |
624
+ | Cross-origin iframe interaction | Maybe — try CDP Input events first |
625
+ | Screen coordinate-based interaction | Yes |
626
+
627
+ **Priority:** CDP > dev-browser > claude-in-chrome (visual fallback only)
628
+
629
+ ---
630
+
631
+ ## Troubleshooting
632
+
633
+ - **Extension not showing tools:** Ensure Chrome is running with --remote-debugging-port=9222
634
+ - **Tools timeout:** Restart Chrome via chrome-debug script, then reload extension
635
+ - **Extension disabled:** Check chrome://extensions and re-enable
636
+
637
+ ---
638
+
639
+ ## Reference
640
+
641
+ - Master KB: ~/.sinapse/sinapse/knowledge-base/chrome-brain.md
642
+ - Chrome Brain auto-activation rule: ~/.sinapse/.claude/rules/chrome-brain-autoload.md
643
+ `;
644
+ }
645
+
521
646
  function getSquadIntegrationContent(squadName) {
522
647
  const footer = `## Tools Disponiveis
523
648
 
@@ -662,15 +787,20 @@ function installChromeBrain(options = {}) {
662
787
  }
663
788
  }
664
789
 
665
- // --- Step 4: MCP config ---
790
+ // --- Step 4: MCP config (chrome-devtools + dev-browser) ---
666
791
  if (!skipMcp) {
667
- LOG.step('Step 4 — Adding Chrome DevTools MCP to ~/.claude.json...');
792
+ LOG.step('Step 4 — Adding Chrome DevTools + dev-browser MCP to ~/.claude.json...');
668
793
  try {
669
794
  if (dryRun) {
670
- LOG.info('[DRY-RUN] Would merge MCP config');
795
+ LOG.info('[DRY-RUN] Would merge MCP config (chrome-devtools + dev-browser)');
671
796
  } else {
672
- mergeMcpConfig(osInfo);
673
- LOG.ok('Chrome DevTools MCP added to ~/.claude.json');
797
+ const mcpErrors = mergeMcpConfig(osInfo);
798
+ if (mcpErrors.length > 0) {
799
+ for (const e of mcpErrors) {
800
+ errors.push(e);
801
+ }
802
+ }
803
+ LOG.ok('Chrome DevTools + dev-browser MCP added to ~/.claude.json');
674
804
  }
675
805
  } catch (err) {
676
806
  const msg = `Failed to merge MCP config: ${err.message}`;
@@ -693,6 +823,11 @@ function installChromeBrain(options = {}) {
693
823
  content: getMasterKbContent(),
694
824
  label: 'master KB chrome-brain.md',
695
825
  },
826
+ {
827
+ path: path.join(SINAPSE_DIR, 'sinapse', 'knowledge-base', 'claude-in-chrome.md'),
828
+ content: getClaudeInChromeKbContent(),
829
+ label: 'claude-in-chrome.md KB',
830
+ },
696
831
  ];
697
832
 
698
833
  // Squad integration files
@@ -721,6 +856,15 @@ function installChromeBrain(options = {}) {
721
856
  }
722
857
  }
723
858
 
859
+ // --- claude-in-chrome instructions (Story 7.4.2) ---
860
+ if (!_quiet && !dryRun) {
861
+ LOG.step('Manual step required: claude-in-chrome extension');
862
+ LOG.info('Install the claude-in-chrome Chrome extension from the Chrome Web Store:');
863
+ LOG.info(' https://chromewebstore.google.com/detail/claude-in-chrome');
864
+ LOG.info('The extension manages its own MCP registration — no CLI config needed.');
865
+ LOG.info('See KB: ~/.sinapse/sinapse/knowledge-base/claude-in-chrome.md');
866
+ }
867
+
724
868
  // --- Step 6: Validate ---
725
869
  LOG.step('Step 6 — Validating installation...');
726
870
  if (!dryRun) {
@@ -789,6 +933,7 @@ function uninstallChromeBrain(options = {}) {
789
933
  const chromeMatchers = new Set([
790
934
  'mcp__chrome-devtools__*',
791
935
  'mcp__claude-in-chrome__*',
936
+ 'mcp__dev-browser__*',
792
937
  ]);
793
938
  let changed = false;
794
939
  for (const hookType of ['PreToolUse', 'PostToolUse']) {
@@ -816,16 +961,24 @@ function uninstallChromeBrain(options = {}) {
816
961
  errors.push(`Failed to clean hooks: ${err.message}`);
817
962
  }
818
963
 
819
- // --- Remove MCP from claude.json ---
964
+ // --- Remove MCP from claude.json (chrome-devtools + dev-browser) ---
820
965
  try {
821
966
  const config = readJsonSafe(CLAUDE_JSON);
822
- if (config.mcpServers && config.mcpServers['chrome-devtools']) {
967
+ let mcpChanged = false;
968
+ if (config.mcpServers) {
969
+ for (const key of ['chrome-devtools', 'dev-browser']) {
970
+ if (config.mcpServers[key]) {
971
+ delete config.mcpServers[key];
972
+ mcpChanged = true;
973
+ }
974
+ }
975
+ }
976
+ if (mcpChanged) {
823
977
  if (dryRun) {
824
- LOG.info('[DRY-RUN] Would remove chrome-devtools from ~/.claude.json');
978
+ LOG.info('[DRY-RUN] Would remove chrome-devtools + dev-browser from ~/.claude.json');
825
979
  } else {
826
- delete config.mcpServers['chrome-devtools'];
827
980
  writeJson(CLAUDE_JSON, config);
828
- LOG.ok('Removed chrome-devtools MCP from ~/.claude.json');
981
+ LOG.ok('Removed chrome-devtools + dev-browser MCP from ~/.claude.json');
829
982
  }
830
983
  removed.push(CLAUDE_JSON);
831
984
  }
@@ -838,6 +991,7 @@ function uninstallChromeBrain(options = {}) {
838
991
  const kbPaths = [
839
992
  path.join(SINAPSE_DIR, '.claude', 'rules', 'chrome-brain-autoload.md'),
840
993
  path.join(SINAPSE_DIR, 'sinapse', 'knowledge-base', 'chrome-brain.md'),
994
+ path.join(SINAPSE_DIR, 'sinapse', 'knowledge-base', 'claude-in-chrome.md'),
841
995
  ];
842
996
  for (const squad of SQUAD_NAMES) {
843
997
  kbPaths.push(path.join(SINAPSE_DIR, squad, 'knowledge-base', 'chrome-brain-integration.md'));
@@ -908,15 +1062,27 @@ function getChromeBrainStatus() {
908
1062
  // not configured
909
1063
  }
910
1064
 
911
- // Check MCP
1065
+ // Check MCP (chrome-devtools + dev-browser)
912
1066
  let mcpConfigured = false;
1067
+ let devBrowserMcpConfigured = false;
913
1068
  try {
914
1069
  const config = readJsonSafe(CLAUDE_JSON);
915
1070
  mcpConfigured = !!config.mcpServers?.['chrome-devtools'];
1071
+ devBrowserMcpConfigured = !!config.mcpServers?.['dev-browser'];
916
1072
  } catch {
917
1073
  // not configured
918
1074
  }
919
1075
 
1076
+ // Check dev-browser global install
1077
+ let devBrowserInstalled = false;
1078
+ try {
1079
+ const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';
1080
+ execSync(`${npmCmd} list -g dev-browser`, { stdio: 'pipe', timeout: 10000 });
1081
+ devBrowserInstalled = true;
1082
+ } catch {
1083
+ // not installed globally
1084
+ }
1085
+
920
1086
  // Check rule
921
1087
  const ruleInstalled = fs.existsSync(
922
1088
  path.join(SINAPSE_DIR, '.claude', 'rules', 'chrome-brain-autoload.md'),
@@ -927,6 +1093,11 @@ function getChromeBrainStatus() {
927
1093
  path.join(SINAPSE_DIR, 'sinapse', 'knowledge-base', 'chrome-brain.md'),
928
1094
  );
929
1095
 
1096
+ // Check claude-in-chrome KB
1097
+ const claudeInChromeKbInstalled = fs.existsSync(
1098
+ path.join(SINAPSE_DIR, 'sinapse', 'knowledge-base', 'claude-in-chrome.md'),
1099
+ );
1100
+
930
1101
  // Count squad KBs
931
1102
  let squadKbCount = 0;
932
1103
  for (const squad of SQUAD_NAMES) {
@@ -940,8 +1111,11 @@ function getChromeBrainStatus() {
940
1111
  scriptsInstalled,
941
1112
  hooksConfigured,
942
1113
  mcpConfigured,
1114
+ devBrowserInstalled,
1115
+ devBrowserMcpConfigured,
943
1116
  ruleInstalled,
944
1117
  masterKbInstalled,
1118
+ claudeInChromeKbInstalled,
945
1119
  squadKbComplete: squadKbCount === SQUAD_NAMES.length,
946
1120
  };
947
1121
 
@@ -130,7 +130,7 @@ persona:
130
130
  # === SINAPSE Integration Principles ===
131
131
  - "L1-L4 Boundary Respect -- Framework core (L1) is immutable. Templates (L2) are extend-only. Project config (L3) is mutable with exceptions. Project runtime (L4) is where work happens."
132
132
  - "Task-First Architecture -- Workflows are composed by tasks connected, not by agents connected. Each task defines inputs, outputs, pre/post-conditions."
133
- - "Constitutional Compliance -- Every integration respects SINAPSE Constitution. CLI First, Agent Authority, Story-Driven Development, No Invention, Quality First."
133
+ - "Constitutional Compliance -- Every integration respects SINAPSE Constitution. CLI First, Agent Authority, Documentation-First Development, No Invention, Quality First, Mandatory Delegation."
134
134
 
135
135
  responsibility_boundaries:
136
136
  primary_scope: