analyzthis_design 2.0.0 → 2.1.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 (69) hide show
  1. package/HOW-TO-USE.md +436 -0
  2. package/README.md +29 -13
  3. package/agents/cards/evolve-check.md +38 -0
  4. package/agents/manifests/evolve-check.json +16 -0
  5. package/dist/HOW-TO-USE.md +15 -3
  6. package/dist/README.md +29 -13
  7. package/dist/agents/cards/evolve-check.md +38 -0
  8. package/dist/agents/manifests/evolve-check.json +16 -0
  9. package/dist/bin/cli.js +1225 -1
  10. package/dist/lib/cache.js +111 -1
  11. package/dist/lib/chunk-executor.js +219 -1
  12. package/dist/lib/chunk-models.js +228 -1
  13. package/dist/lib/chunk-planner.js +328 -1
  14. package/dist/lib/chunk-router.js +66 -1
  15. package/dist/lib/chunk-run.js +199 -1
  16. package/dist/lib/chunk-synthesis.js +176 -1
  17. package/dist/lib/chunk-telemetry.js +88 -1
  18. package/dist/lib/collect.js +858 -1
  19. package/dist/lib/cost.js +119 -1
  20. package/dist/lib/dedup.js +167 -1
  21. package/dist/lib/deliberation.js +721 -1
  22. package/dist/lib/design-spec.js +236 -1
  23. package/dist/lib/evolution-metrics.js +197 -0
  24. package/dist/lib/evolve.js +361 -1
  25. package/dist/lib/export.js +77 -1
  26. package/dist/lib/feedback-submit.js +324 -1
  27. package/dist/lib/feedback.js +182 -1
  28. package/dist/lib/host-llm.js +251 -1
  29. package/dist/lib/install.js +301 -1
  30. package/dist/lib/knowledge.js +384 -1
  31. package/dist/lib/lessons.js +217 -1
  32. package/dist/lib/moodboard.js +563 -1
  33. package/dist/lib/orchestrator/run.js +935 -1
  34. package/dist/lib/outcome.js +193 -1
  35. package/dist/lib/platforms.js +166 -1
  36. package/dist/lib/provider.js +57 -1
  37. package/dist/lib/query-expander.js +83 -1
  38. package/dist/lib/ranker.js +105 -1
  39. package/dist/lib/reference-pack.js +221 -0
  40. package/dist/lib/research.js +143 -1
  41. package/dist/lib/retrieve.js +131 -1
  42. package/dist/lib/session.js +185 -1
  43. package/dist/lib/source-discovery.js +486 -1
  44. package/dist/lib/synthesis.js +155 -1
  45. package/dist/lib/token-gate.js +46 -1
  46. package/dist/skills/design-reference/google-fonts.csv +1924 -1924
  47. package/dist/skills/design-reference/products.csv +162 -162
  48. package/dist/skills/design-reference/schema.json +159 -0
  49. package/dist/skills/design-reference/stacks/angular.csv +1 -1
  50. package/dist/skills/design-reference/stacks/astro.csv +1 -1
  51. package/dist/skills/design-reference/stacks/laravel.csv +2 -2
  52. package/dist/skills/design-reference/stacks/threejs.csv +54 -54
  53. package/dist/skills/design-reference/styles.csv +85 -85
  54. package/dist/skills/design-reference/typography.csv +75 -74
  55. package/dist/skills/design-reference/ui-reasoning.csv +1 -1
  56. package/dist/skills/evolve-check/SKILL.md +106 -0
  57. package/package.json +8 -8
  58. package/scripts/validate-csvs.js +197 -0
  59. package/skills/design-reference/google-fonts.csv +1924 -1924
  60. package/skills/design-reference/products.csv +162 -162
  61. package/skills/design-reference/schema.json +159 -0
  62. package/skills/design-reference/stacks/angular.csv +1 -1
  63. package/skills/design-reference/stacks/astro.csv +1 -1
  64. package/skills/design-reference/stacks/laravel.csv +2 -2
  65. package/skills/design-reference/stacks/threejs.csv +54 -54
  66. package/skills/design-reference/styles.csv +85 -85
  67. package/skills/design-reference/typography.csv +75 -74
  68. package/skills/design-reference/ui-reasoning.csv +1 -1
  69. package/skills/evolve-check/SKILL.md +106 -0
@@ -1,2 +1,186 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';const fs=require('fs'),path=require('path'),os=require('os'),crypto=require('crypto'),cache=require('./cache'),SESSIONS_ROOT=path['join'](os['homedir'](),'.analyzthis_design','sessions');function getProjectId(a=process['cwd']()){const b=path['resolve'](a),c=path['basename'](b)['toLowerCase']()['replace'](/[^a-z0-9-]+/g,'-')['replace'](/^-+|-+$/g,'')||'project',d=crypto['createHash']('sha1')['update'](b)['digest']('hex')['slice'](0x0,0x8);return c+'-'+d;}function sessionDir(a){return path['join'](SESSIONS_ROOT,a);}function sessionPath(a){return path['join'](sessionDir(a),'session-state.json');}function defaultState(a){const b=new Date()['toISOString']();return{'project_id':a,'created_at':b,'updated_at':b,'task_map':[],'figma_node':{'url':'','confirmed':![]},'content_sources':[],'ds_checklist':{'no_invented_hex':null,'no_important_overrides':null,'kit_components_preferred':null,'light_dark_from_tokens_only':null,'contrast_checked_against_wcag':null},'information_hierarchy':{'declared_by':'undeclared','ranking':[]},'routing_decision':{'problem_type':'','experts':[],'reason':''},'persona_outputs':{},'full_prompts':{},'structured_outputs':{},'covered_points':[],'task_type':'','verify_results':{'primary_task':'not_run','screenshots':[],'reason':''},'mode':'assess_only','design_spec':null,'feedback_log':[],'outcome':{'inferred':{},'confirmed':{}},'vault_path':'','last_collect_at':'','deliberation':{'round':0x0,'max_rounds':0x3,'satisfaction_threshold':0.4,'open_objections':[],'round_log':[],'consensus_reached':![],'raj_escalated':![],'mode':'adversarial'},'digest':{'task_map_summary':'','hierarchy_top3':[],'ds_at_risk':[],'experts':[],'prior_scores':{},'mode':'assess_only'},'metrics':{'llm_calls':0x0,'experts_run':[],'input_tokens_est':0x0,'output_tokens_est':0x0,'cache_hits':0x0,'mode':'lite','effort_log':[],'cost_usd':0x0,'deliberation_rounds':0x0,'objections_raised':0x0,'objections_resolved':0x0,'raj_escalations':0x0}};}function init({project:a}={}){const b=a||getProjectId(),c=sessionDir(b);fs['mkdirSync'](c,{'recursive':!![]});const d=sessionPath(b);return fs['writeFileSync'](d,JSON['stringify'](defaultState(b),null,0x2)),{'projectId':b,'filePath':d};}function show({project:a}={}){const b=a||getProjectId(),c=sessionPath(b);if(!fs['existsSync'](c))return null;try{return JSON['parse'](fs['readFileSync'](c,'utf8'));}catch{return null;}}function reset({project:a,all:all=![]}={}){if(all)return fs['rmSync'](SESSIONS_ROOT,{'recursive':!![],'force':!![]}),cache['invalidatePrefix']('kb:'),{'removed':'all'};const b=a||getProjectId();return fs['rmSync'](sessionDir(b),{'recursive':!![],'force':!![]}),cache['invalidatePrefix']('kb:'+b+':'),{'removed':b};}function update({project:a,patch:patch={}}={}){const b=a||getProjectId(),c=show({'project':b})||defaultState(b),d={...c,...patch,'updated_at':new Date()['toISOString']()},e=sessionDir(b);return fs['mkdirSync'](e,{'recursive':!![]}),fs['writeFileSync'](sessionPath(b),JSON['stringify'](d,null,0x2)),d;}function listProjects(){if(!fs['existsSync'](SESSIONS_ROOT))return[];return fs['readdirSync'](SESSIONS_ROOT,{'withFileTypes':!![]})['filter'](a=>a['isDirectory']()&&fs['existsSync'](sessionPath(a['name'])))['map'](a=>a['name']);}function markAccepted({project:a,persona:b,accepted:accepted=!![]}={}){const c=a||getProjectId(),d=show({'project':c});if(!d||!d['persona_outputs']||!d['persona_outputs'][b])return{'updated':![],'reason':'No\x20output\x20recorded\x20for\x20persona\x20\x22'+b+'\x22\x20in\x20this\x20session\x20yet.'};d['persona_outputs'][b]['accepted']=accepted;const e=update({'project':c,'patch':{'persona_outputs':d['persona_outputs']}});return{'updated':!![],'state':e};}module['exports']={'getProjectId':getProjectId,'sessionPath':sessionPath,'sessionDir':sessionDir,'init':init,'show':show,'reset':reset,'update':update,'listProjects':listProjects,'markAccepted':markAccepted,'SESSIONS_ROOT':SESSIONS_ROOT};
2
+ 'use strict';
3
+
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const os = require('os');
7
+ const crypto = require('crypto');
8
+ const cache = require('./cache');
9
+
10
+ const SESSIONS_ROOT = path.join(os.homedir(), '.analyzthis_design', 'sessions');
11
+
12
+ // ─── Project identity ────────────────────────────────────────────────────────
13
+
14
+ // A project id is a short, filesystem-safe slug derived from the working
15
+ // directory so different repos never collide, and the same repo always
16
+ // resolves to the same session file across turns.
17
+ function getProjectId(cwd = process.cwd()) {
18
+ const abs = path.resolve(cwd);
19
+ const slug = path.basename(abs).toLowerCase().replace(/[^a-z0-9-]+/g, '-').replace(/^-+|-+$/g, '') || 'project';
20
+ const hash = crypto.createHash('sha1').update(abs).digest('hex').slice(0, 8);
21
+ return `${slug}-${hash}`;
22
+ }
23
+
24
+ function sessionDir(projectId) {
25
+ return path.join(SESSIONS_ROOT, projectId);
26
+ }
27
+
28
+ function sessionPath(projectId) {
29
+ return path.join(sessionDir(projectId), 'session-state.json');
30
+ }
31
+
32
+ // ─── Default shape (mirrors agents/session-schema.json) ─────────────────────
33
+
34
+ function defaultState(projectId) {
35
+ const now = new Date().toISOString();
36
+ return {
37
+ project_id: projectId,
38
+ created_at: now,
39
+ updated_at: now,
40
+ task_map: [],
41
+ figma_node: { url: '', confirmed: false },
42
+ content_sources: [],
43
+ ds_checklist: {
44
+ no_invented_hex: null,
45
+ no_important_overrides: null,
46
+ kit_components_preferred: null,
47
+ light_dark_from_tokens_only: null,
48
+ contrast_checked_against_wcag: null,
49
+ },
50
+ information_hierarchy: { declared_by: 'undeclared', ranking: [] },
51
+ routing_decision: { problem_type: '', experts: [], reason: '' },
52
+ persona_outputs: {},
53
+ full_prompts: {},
54
+ structured_outputs: {},
55
+ covered_points: [],
56
+ task_type: '',
57
+ verify_results: { primary_task: 'not_run', screenshots: [], reason: '' },
58
+ mode: 'assess_only',
59
+ design_spec: null,
60
+ feedback_log: [],
61
+ outcome: {
62
+ inferred: {},
63
+ confirmed: {},
64
+ },
65
+ vault_path: '',
66
+ last_collect_at: '',
67
+ deliberation: {
68
+ round: 0,
69
+ max_rounds: 3,
70
+ satisfaction_threshold: 0.4,
71
+ open_objections: [],
72
+ round_log: [],
73
+ consensus_reached: false,
74
+ raj_escalated: false,
75
+ mode: 'adversarial',
76
+ },
77
+ digest: {
78
+ task_map_summary: '',
79
+ hierarchy_top3: [],
80
+ ds_at_risk: [],
81
+ experts: [],
82
+ prior_scores: {},
83
+ mode: 'assess_only',
84
+ },
85
+ metrics: {
86
+ llm_calls: 0,
87
+ experts_run: [],
88
+ input_tokens_est: 0,
89
+ output_tokens_est: 0,
90
+ cache_hits: 0,
91
+ mode: 'lite',
92
+ effort_log: [],
93
+ cost_usd: 0,
94
+ deliberation_rounds: 0,
95
+ objections_raised: 0,
96
+ objections_resolved: 0,
97
+ raj_escalations: 0,
98
+ },
99
+ };
100
+ }
101
+
102
+ // ─── Public API ──────────────────────────────────────────────────────────────
103
+
104
+ /**
105
+ * Create (or overwrite) a fresh session-state.json for the given project.
106
+ */
107
+ function init({ project } = {}) {
108
+ const projectId = project || getProjectId();
109
+ const dir = sessionDir(projectId);
110
+ fs.mkdirSync(dir, { recursive: true });
111
+ const filePath = sessionPath(projectId);
112
+ fs.writeFileSync(filePath, JSON.stringify(defaultState(projectId), null, 2));
113
+ return { projectId, filePath };
114
+ }
115
+
116
+ /**
117
+ * Read the current session state. Returns null if no session exists yet.
118
+ */
119
+ function show({ project } = {}) {
120
+ const projectId = project || getProjectId();
121
+ const filePath = sessionPath(projectId);
122
+ if (!fs.existsSync(filePath)) return null;
123
+ try { return JSON.parse(fs.readFileSync(filePath, 'utf8')); }
124
+ catch { return null; }
125
+ }
126
+
127
+ /**
128
+ * Delete the session state for a project (or all projects if `all` is true).
129
+ */
130
+ function reset({ project, all = false } = {}) {
131
+ if (all) {
132
+ fs.rmSync(SESSIONS_ROOT, { recursive: true, force: true });
133
+ cache.invalidatePrefix('kb:');
134
+ return { removed: 'all' };
135
+ }
136
+ const projectId = project || getProjectId();
137
+ fs.rmSync(sessionDir(projectId), { recursive: true, force: true });
138
+ cache.invalidatePrefix(`kb:${projectId}:`);
139
+ return { removed: projectId };
140
+ }
141
+
142
+ /**
143
+ * Merge a partial update into the session state, creating it first if needed.
144
+ * Used by the orchestrator skill (via CLI) to persist routing decisions,
145
+ * persona outputs, and gate results between turns.
146
+ */
147
+ function update({ project, patch = {} } = {}) {
148
+ const projectId = project || getProjectId();
149
+ const existing = show({ project: projectId }) || defaultState(projectId);
150
+ const merged = { ...existing, ...patch, updated_at: new Date().toISOString() };
151
+ const dir = sessionDir(projectId);
152
+ fs.mkdirSync(dir, { recursive: true });
153
+ fs.writeFileSync(sessionPath(projectId), JSON.stringify(merged, null, 2));
154
+ return merged;
155
+ }
156
+
157
+ /**
158
+ * List every project id that currently has a session-state.json on disk.
159
+ * Used by `metrics --all` and `export-training --all`.
160
+ */
161
+ function listProjects() {
162
+ if (!fs.existsSync(SESSIONS_ROOT)) return [];
163
+ return fs.readdirSync(SESSIONS_ROOT, { withFileTypes: true })
164
+ .filter((d) => d.isDirectory() && fs.existsSync(sessionPath(d.name)))
165
+ .map((d) => d.name);
166
+ }
167
+
168
+ /**
169
+ * Mark a persona's most recent output as accepted (or rejected) — the
170
+ * lightweight feedback flag the future LoRA training-pair export reads.
171
+ * No-ops if the persona hasn't produced an output yet.
172
+ */
173
+ function markAccepted({ project, persona, accepted = true } = {}) {
174
+ const projectId = project || getProjectId();
175
+ const state = show({ project: projectId });
176
+ if (!state || !state.persona_outputs || !state.persona_outputs[persona]) {
177
+ return { updated: false, reason: `No output recorded for persona "${persona}" in this session yet.` };
178
+ }
179
+ state.persona_outputs[persona].accepted = accepted;
180
+ const merged = update({ project: projectId, patch: { persona_outputs: state.persona_outputs } });
181
+ return { updated: true, state: merged };
182
+ }
183
+
184
+ module.exports = {
185
+ getProjectId, sessionPath, sessionDir, init, show, reset, update, listProjects, markAccepted, SESSIONS_ROOT,
186
+ };