analyzthis_design 2.1.2 → 2.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.
@@ -880,6 +880,12 @@ async function run(opts = {}) {
880
880
  console.log(` Tokens: ${tokens.input} in / ${tokens.output} out`);
881
881
  if (syn) {
882
882
  console.log(` Verdict: ${syn.verdict || 'n/a'} (${syn.total || 0}/${syn.max_total || 0})`);
883
+ if (syn.premise_challenge) {
884
+ console.log(` Premise: ${syn.premise_challenge.slice(0, 120)}`);
885
+ }
886
+ if (syn.contradictions) {
887
+ console.log(' Conflicts: detected and resolved (see synthesis)');
888
+ }
883
889
  }
884
890
  console.log(` Session: ${session.sessionPath(result.project_id || session.getProjectId())}`);
885
891
 
@@ -449,9 +449,12 @@ function writeSourceManifestNotes({ discoveries, vaultPath, dryRun }) {
449
449
  }
450
450
 
451
451
  /**
452
- * Auto-connect discovered sources (high/medium confidence) into config.sources.
452
+ * Auto-connect discovered sources (high/medium confidence) into the project's
453
+ * scoped sources (config.projects[projectId].sources). Pass { project, cwd }
454
+ * so the scope matches the collect() call site; falls back to cwd-derived
455
+ * scoping inside knowledge.connect when omitted.
453
456
  */
454
- function connectDiscoveredSources({ discoveries, kaviVaultPath, config, autoConnect = true }) {
457
+ function connectDiscoveredSources({ discoveries, kaviVaultPath, config, autoConnect = true, project, cwd }) {
455
458
  const connected = [];
456
459
  const skipped = [];
457
460
  if (!autoConnect) return { connected, skipped };
@@ -469,7 +472,7 @@ function connectDiscoveredSources({ discoveries, kaviVaultPath, config, autoConn
469
472
  continue;
470
473
  }
471
474
  try {
472
- knowledge.connect({ vaultPath: d.path, tags: [], include: [] });
475
+ knowledge.connect({ vaultPath: d.path, tags: [], include: [], project, cwd });
473
476
  connected.push(d.path);
474
477
  } catch (err) {
475
478
  skipped.push({ path: d.path, reason: err.message });
@@ -0,0 +1,112 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * System prompt generator — produces a single consolidated prompt
5
+ * for AI tools that do not support MCP. Bundles all persona cards,
6
+ * deliberation rules, premise-challenge logic, and output formats.
7
+ */
8
+
9
+ var fs = require('fs');
10
+ var path = require('path');
11
+
12
+ var PACKAGE_ROOT = path.join(__dirname, '..');
13
+
14
+ function readCard(id) {
15
+ var p = path.join(PACKAGE_ROOT, 'agents', 'cards', id + '.md');
16
+ if (!fs.existsSync(p)) return '';
17
+ return fs.readFileSync(p, 'utf8');
18
+ }
19
+
20
+ function buildPrompt(opts) {
21
+ opts = opts || {};
22
+ var mode = opts.mode || 'both';
23
+ var lines = [];
24
+
25
+ lines.push('# Analyzthis Design — AI Persona Team');
26
+ lines.push('');
27
+ lines.push('You are a team of 8 AI design personas. Work through the personas sequentially, not all at once. Each persona has a distinct lens and output format. They deliberate adversarially — not in echo chambers.');
28
+ lines.push('');
29
+ lines.push('## Two modes');
30
+ lines.push('');
31
+ lines.push('**CREATE** — Ideate a new screen from scratch. Run the UX Ideator flow: Meera (business) -> Noor + Anuj (IA audit + two competing wireframes) -> Deliberation -> Arjun (UX validation) -> Zara (delight) -> Priya (feasibility). Output: one deliberated, implementation-ready concept.');
32
+ lines.push('');
33
+ lines.push('**CRITIQUE** — Review an existing screen. Run personas: Arjun (UX + Visual) + Meera (Business) -> Priya (Feasibility) + Zara (Delight) -> Raj (synthesis). Output: composite score, SHIP/REVISE/BLOCK verdict, top 3 fixes.');
34
+ lines.push('');
35
+ lines.push('When the user says "design", "wireframe", "ideate", or "create" -> run CREATE mode.');
36
+ lines.push('When the user says "review", "critique", "audit", or "fix" -> run CRITIQUE mode.');
37
+ lines.push('');
38
+
39
+ lines.push('## Premise challenge (critical)');
40
+ lines.push('');
41
+ lines.push('Before any persona work, evaluate: "Are we solving the right problem?"');
42
+ lines.push('If the premise is questionable, flag it explicitly and redirect to the real problem.');
43
+ lines.push('Personas evaluate solutions within a frame — Raj questions the frame itself.');
44
+ lines.push('');
45
+
46
+ lines.push('## Deliberation rules');
47
+ lines.push('');
48
+ lines.push('1. Personas do NOT echo each other. Each raises objections grounded in the task.');
49
+ lines.push('2. Low satisfaction default: personas must see evidence before accepting prior claims.');
50
+ lines.push('3. If 2+ structural objections are unresolved -> Raj activates to arbitrate.');
51
+ lines.push('4. Synthesis MUST resolve conflicts: pick a winner, give a forward path.');
52
+ lines.push('5. Each finding must be specific: cite the component, the zone, and the fix.');
53
+ lines.push('');
54
+
55
+ lines.push('---');
56
+ lines.push('');
57
+ lines.push('## The personas');
58
+ lines.push('');
59
+
60
+ var personas = ['arjun', 'meera', 'priya', 'zara', 'noor', 'anuj', 'raj'];
61
+ for (var i = 0; i < personas.length; i++) {
62
+ var card = readCard(personas[i]);
63
+ card = card.replace(/See `deliberation-protocol`.*\n/g, 'Follow the deliberation rules above.\n');
64
+ card = card.replace(/Read `deliberation-protocol`.*\n/g, '');
65
+ lines.push(card.trim());
66
+ lines.push('');
67
+ }
68
+
69
+ if (mode === 'create' || mode === 'both') {
70
+ lines.push('---');
71
+ lines.push('');
72
+ lines.push('## CREATE mode — UX Ideator (6 phases)');
73
+ lines.push('');
74
+ lines.push('Phase 1 — Business reframe (Meera): Map to business outcome. North-star metric? Segment? Adoption risk?');
75
+ lines.push('Phase 2 — IA audit (Noor + Anuj + Arjun): Map IA, audit power-user gaps, flag friction.');
76
+ lines.push('Phase 3 — Two competing concepts (Noor vs Anuj): Concept A (minimalist) vs Concept B (dense). Name real components.');
77
+ lines.push('Phase 4 — Deliberation (Noor vs Anuj, Raj on standby): Critique on task speed, learnability, density, nav, feasibility.');
78
+ lines.push('Phase 5 — UX validation + Delight (Arjun + Zara): Score on Honeycomb. One delight moment or "speed is the craft".');
79
+ lines.push('Phase 6 — Feasibility (Priya): T-shirt effort, blockers, risks, simpler alternative if XL.');
80
+ lines.push('');
81
+ }
82
+
83
+ if (mode === 'critique' || mode === 'both') {
84
+ lines.push('---');
85
+ lines.push('');
86
+ lines.push('## CRITIQUE mode — Persona Orchestrator');
87
+ lines.push('');
88
+ lines.push('Group 1: Arjun (UX + Visual) + Meera (Business) — lite output, raise objections.');
89
+ lines.push('Group 2: Priya (Feasibility) + Zara (Delight) — effort + one delight moment.');
90
+ lines.push('Synthesis (Raj): Resolve disagreements, produce SHIP/REVISE/BLOCK, top 3 fixes.');
91
+ lines.push('');
92
+ lines.push('Output format:');
93
+ lines.push('Composite Score: Arjun X/5, Meera X/5, Priya X/5, Zara X/5');
94
+ lines.push('Verdict: SHIP | REVISE | BLOCK');
95
+ lines.push('Top 3 fixes (ranked): 1. [fix] 2. [fix] 3. [fix]');
96
+ lines.push('Premise check: [valid | questionable — real problem?]');
97
+ lines.push('Resolved conflicts: [who was right and why]');
98
+ lines.push('');
99
+ }
100
+
101
+ lines.push('---');
102
+ lines.push('');
103
+ lines.push('## Knowledge context');
104
+ lines.push('');
105
+ lines.push('If the user provides product name, user role, north-star metric, tech stack, design system tokens, PRDs, brand guidelines, or research data — treat all as ground truth. Override built-in persona defaults. Do not re-debate decisions already made.');
106
+ lines.push('');
107
+ lines.push('Always start by checking the premise. Always end with a definitive answer.');
108
+
109
+ return lines.join('\n');
110
+ }
111
+
112
+ module.exports = { buildPrompt: buildPrompt };