@hanzo/build 0.2.118 → 0.2.120
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.
- package/README.md +25 -4
- package/lib/api/agents.d.ts +4 -2
- package/lib/api/agents.js +5 -3
- package/lib/api/billing.d.ts +6 -0
- package/lib/api/billing.js +9 -0
- package/lib/api/chat.d.ts +1 -1
- package/lib/api/chat.js +2 -2
- package/lib/api/draft.d.ts +33 -0
- package/lib/api/draft.js +81 -0
- package/lib/api/gallery.d.ts +32 -0
- package/lib/api/gallery.js +85 -0
- package/lib/customize/agents.js +35 -8
- package/lib/customize/drafted.d.ts +4 -0
- package/lib/customize/drafted.js +79 -0
- package/lib/customize/inventory.d.ts +11 -0
- package/lib/customize/inventory.js +78 -0
- package/lib/customize/ocean.d.ts +41 -0
- package/lib/customize/ocean.js +332 -0
- package/lib/customize/ui.d.ts +9 -2
- package/lib/customize/ui.js +33 -4
- package/lib/host.d.ts +7 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/landing.js +1 -1
- package/lib/library.js +7 -7
- package/lib/make.d.ts +10 -0
- package/lib/make.js +113 -0
- package/lib/marks.d.ts +15 -0
- package/lib/marks.js +18 -0
- package/lib/mind.d.ts +29 -3
- package/lib/mind.js +73 -6
- package/lib/nav.d.ts +1 -1
- package/lib/nav.js +16 -8
- package/lib/route.d.ts +3 -2
- package/lib/route.js +2 -2
- package/package.json +5 -5
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The Big Five questionnaire Clone yourself asks, and what it found.
|
|
4
|
+
*
|
|
5
|
+
* On a phone one statement fills the screen, with a bar, Back, and the keys 1
|
|
6
|
+
* to 5; a wider window lists them all, and the keys answer the first one left.
|
|
7
|
+
* Every answer goes to `onChange` as it is given, which keeps it in this
|
|
8
|
+
* browser, so a closed dialog opens where it stopped. The statements are the
|
|
9
|
+
* IPIP's (ocean.ts), drawn through `t`; figures are drawn as given.
|
|
10
|
+
*/
|
|
11
|
+
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
12
|
+
import { useI18n } from '@hanzo/i18n/react';
|
|
13
|
+
import { Button } from '@hanzo/ui';
|
|
14
|
+
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { ANCHORS, DOMAIN, DOMAINS, FACET, FACETS, ITEMS } from './ocean.js';
|
|
16
|
+
const LEVELS = [1, 2, 3, 4, 5];
|
|
17
|
+
export function Inventory({ answers, onChange, onDone }) {
|
|
18
|
+
const { t } = useI18n();
|
|
19
|
+
const phone = !useMedia().sm;
|
|
20
|
+
const items = ITEMS[answers.form];
|
|
21
|
+
const given = answers[answers.form];
|
|
22
|
+
const n = given.filter(Boolean).length;
|
|
23
|
+
const [at, setAt] = useState(() => Math.max(0, given.indexOf(0)));
|
|
24
|
+
const list = useRef(null);
|
|
25
|
+
// The keys answer the statement on screen, or the first one left in the list.
|
|
26
|
+
const current = phone ? at : given.indexOf(0);
|
|
27
|
+
const answer = (i, v) => {
|
|
28
|
+
const next = given.map((x, j) => (j === i ? v : x));
|
|
29
|
+
onChange({ ...answers, [answers.form]: next });
|
|
30
|
+
const after = next.findIndex((x, j) => j > i && !x);
|
|
31
|
+
const left = after >= 0 ? after : next.indexOf(0);
|
|
32
|
+
if (phone) {
|
|
33
|
+
if (left < 0)
|
|
34
|
+
onDone();
|
|
35
|
+
else
|
|
36
|
+
setAt(left);
|
|
37
|
+
}
|
|
38
|
+
else if (left >= 0) {
|
|
39
|
+
list.current?.querySelector(`[data-item="${left}"]`)?.scrollIntoView({ block: 'nearest' });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const press = useRef(answer);
|
|
43
|
+
press.current = answer;
|
|
44
|
+
// One handler for every row, so a row redraws only when its own answer or highlight changes.
|
|
45
|
+
const pick = useCallback((i, v) => press.current(i, v), []);
|
|
46
|
+
useEffect(() => {
|
|
47
|
+
const key = (e) => {
|
|
48
|
+
const v = Number(e.key);
|
|
49
|
+
if (e.metaKey || e.ctrlKey || e.altKey || !(v >= 1 && v <= 5) || current < 0)
|
|
50
|
+
return;
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
press.current(current, v);
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener('keydown', key);
|
|
55
|
+
return () => window.removeEventListener('keydown', key);
|
|
56
|
+
}, [current]);
|
|
57
|
+
// Pinned to the top of the dialog's scroll, so the count and Done stay in reach down the list.
|
|
58
|
+
const head = (_jsxs(YStack, { gap: "$2", pb: "$2", bg: "$background", z: 1, position: "sticky", t: 0, children: [_jsxs(XStack, { items: "center", gap: "$3", children: [_jsx(YStack, { flex: 1, height: 4, rounded: 999, bg: "$hover", overflow: "hidden", role: "progressbar", "aria-label": t('Answered'), "aria-valuenow": n, "aria-valuemin": 0, "aria-valuemax": items.length, children: _jsx(YStack, { height: 4, width: `${(n / items.length) * 100}%`, rounded: 999, bg: "$ink" }) }), _jsx(SizableText, { size: "$1", color: "$soft", fontVariant: ['tabular-nums'], children: t('{n} of {total}', { n, total: items.length }) }), _jsx(Button, { size: "sm", variant: "ghost", onPress: onDone, children: t('Done') })] }), _jsx(SizableText, { size: "$1", color: "$soft", children: t('Describe yourself as you generally are now, not as you wish to be in the future. From 1, very inaccurate, to 5, very accurate.') })] }));
|
|
59
|
+
if (phone) {
|
|
60
|
+
const item = items[at];
|
|
61
|
+
return (_jsxs(YStack, { gap: "$4", children: [head, _jsx(SizableText, { size: "$6", color: "$ink", minH: 64, children: t(item.text) }), _jsx(YStack, { role: "radiogroup", "aria-label": t(item.text), gap: "$2", children: LEVELS.map((v) => (_jsxs(XStack, { render: "button", role: "radio", "aria-checked": given[at] === v, "aria-label": t(ANCHORS[v - 1]), onPress: () => answer(at, v), minH: 48, px: "$3", gap: "$3", items: "center", rounded: "$3", borderWidth: 1, borderColor: given[at] === v ? '$ink' : '$borderColor', bg: given[at] === v ? '$hover' : 'transparent', cursor: "pointer", children: [_jsx(SizableText, { size: "$2", color: "$soft", width: 12, fontVariant: ['tabular-nums'], children: v }), _jsx(SizableText, { size: "$3", color: "$ink", children: t(ANCHORS[v - 1]) })] }, v))) }), _jsx(XStack, { children: _jsx(Button, { size: "sm", variant: "ghost", disabled: at === 0, onPress: () => setAt(at - 1), children: t('Back') }) })] }));
|
|
62
|
+
}
|
|
63
|
+
return (_jsxs(YStack, { gap: "$3", children: [head, _jsx(YStack, { ref: list, role: "list", "aria-label": t('Statements'), children: items.map((item, i) => (_jsx(Statement, { i: i, text: t(item.text), value: given[i] ?? 0, current: i === current, onAnswer: pick }, i))) })] }));
|
|
64
|
+
}
|
|
65
|
+
/** One statement of the list, with its five answers. */
|
|
66
|
+
const Statement = memo(function Statement({ i, text, value, current, onAnswer }) {
|
|
67
|
+
const { t } = useI18n();
|
|
68
|
+
return (_jsxs(XStack, { role: "listitem", "data-item": i, items: "center", gap: "$3", px: "$2", py: "$1.5", rounded: "$2", bg: current ? '$hover' : 'transparent', children: [_jsx(SizableText, { flex: 1, size: "$2", color: value ? '$soft' : '$ink', children: text }), _jsx(XStack, { role: "radiogroup", "aria-label": text, gap: "$1.5", shrink: 0, children: LEVELS.map((v) => (_jsx(XStack, { render: "button", role: "radio", "aria-checked": value === v, "aria-label": t(ANCHORS[v - 1]), onPress: () => onAnswer(i, v), width: 28, height: 28, rounded: 999, items: "center", justify: "center", borderWidth: 1, borderColor: value === v ? '$ink' : '$borderColor', bg: value === v ? '$ink' : 'transparent', hoverStyle: value === v ? undefined : { bg: '$hover' }, cursor: "pointer", children: _jsx(SizableText, { size: "$1", color: value === v ? '$background' : '$soft', fontVariant: ['tabular-nums'], children: v }) }, v))) })] }));
|
|
69
|
+
});
|
|
70
|
+
/** The five domains as bars of their raw means, 1 to 5, and on the long form each domain's six facets under it. */
|
|
71
|
+
export function Traits({ form, score }) {
|
|
72
|
+
const { t } = useI18n();
|
|
73
|
+
return (_jsx(YStack, { gap: "$3", children: DOMAINS.map((d) => (_jsxs(YStack, { gap: "$1.5", children: [_jsx(Bar, { label: t(DOMAIN[d]), value: score.domains[d], strong: true }), form === 'long' ? FACETS(d).map((f) => _jsx(Bar, { label: t(FACET[f]), value: score.facets[f] ?? 0 }, f)) : null] }, d))) }));
|
|
74
|
+
}
|
|
75
|
+
function Bar({ label, value, strong = false }) {
|
|
76
|
+
const h = strong ? 6 : 4;
|
|
77
|
+
return (_jsxs(XStack, { items: "center", gap: "$3", role: "meter", "aria-label": label, "aria-valuenow": value, "aria-valuemin": 1, "aria-valuemax": 5, "aria-valuetext": value.toFixed(1), pl: strong ? 0 : '$3', children: [_jsx(SizableText, { size: strong ? '$2' : '$1', color: strong ? '$ink' : '$soft', width: strong ? 150 : 138, numberOfLines: 1, children: label }), _jsx(YStack, { flex: 1, height: h, rounded: 999, bg: "$hover", overflow: "hidden", children: _jsx(YStack, { height: h, width: `${((value - 1) / 4) * 100}%`, rounded: 999, bg: strong ? '$ink' : '$soft' }) }), _jsx(SizableText, { size: "$1", color: "$soft", width: 24, text: "right", fontVariant: ['tabular-nums'], children: value.toFixed(1) })] }));
|
|
78
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type Domain = 'O' | 'C' | 'E' | 'A' | 'N';
|
|
2
|
+
export declare const DOMAINS: readonly Domain[];
|
|
3
|
+
export type Facet = `${Domain}${1 | 2 | 3 | 4 | 5 | 6}`;
|
|
4
|
+
export type Form = 'short' | 'long';
|
|
5
|
+
export interface Item {
|
|
6
|
+
text: string;
|
|
7
|
+
domain: Domain;
|
|
8
|
+
/** The long form's facet; null on the short form. */
|
|
9
|
+
facet: Facet | null;
|
|
10
|
+
/** +1 scores the answer, -1 scores 6 - answer. */
|
|
11
|
+
key: 1 | -1;
|
|
12
|
+
}
|
|
13
|
+
export declare const DOMAIN: Record<Domain, string>;
|
|
14
|
+
export declare const FACET: Record<Facet, string>;
|
|
15
|
+
/** A domain's six facets, in order. */
|
|
16
|
+
export declare const FACETS: (d: Domain) => Facet[];
|
|
17
|
+
/** The five answers, as the IPIP words them, for 1 to 5. */
|
|
18
|
+
export declare const ANCHORS: readonly [string, string, string, string, string];
|
|
19
|
+
export declare const ITEMS: Record<Form, readonly Item[]>;
|
|
20
|
+
export interface Score {
|
|
21
|
+
domains: Record<Domain, number>;
|
|
22
|
+
/** The long form's 30; empty for the short form. */
|
|
23
|
+
facets: Partial<Record<Facet, number>>;
|
|
24
|
+
}
|
|
25
|
+
/** Every scale's mean over its answered items (0 where none is); `answers[i]` is item i's 1 to 5, 0 unanswered. */
|
|
26
|
+
export declare function score(form: Form, answers: readonly number[]): Score;
|
|
27
|
+
/**
|
|
28
|
+
* How `name` tends to think and write, from a whole answer sheet's score: a
|
|
29
|
+
* line for each domain at either end, the facets furthest out (long form), and
|
|
30
|
+
* the five means.
|
|
31
|
+
*/
|
|
32
|
+
export declare function nature(name: string, form: Form, s: Score): string;
|
|
33
|
+
/** Both answer sheets and the form being taken: what this browser keeps between visits. */
|
|
34
|
+
export interface Answers {
|
|
35
|
+
form: Form;
|
|
36
|
+
short: number[];
|
|
37
|
+
long: number[];
|
|
38
|
+
}
|
|
39
|
+
/** The answers kept for `who`, or blank sheets. */
|
|
40
|
+
export declare function kept(who: string): Answers;
|
|
41
|
+
export declare function keep(who: string, a: Answers): void;
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Big Five (OCEAN) as the International Personality Item Pool asks it, and
|
|
3
|
+
* how an answer sheet is scored.
|
|
4
|
+
*
|
|
5
|
+
* Long: the IPIP-NEO-120. Johnson, J. A. (2014). Measuring thirty facets of
|
|
6
|
+
* the Five Factor Model with a 120-item public domain inventory: Development of
|
|
7
|
+
* the IPIP-NEO-120. Journal of Research in Personality, 51, 78-89. Statements
|
|
8
|
+
* and keys: https://ipip.ori.org/30FacetNEO-PI-RItems.htm; facet names:
|
|
9
|
+
* https://ipip.ori.org/newNEO_FacetsTable.htm. In Johnson's order, item n is
|
|
10
|
+
* facet (n - 1) mod 30 of N1 E1 O1 A1 C1 N2 … C6, as in the MIT-licensed
|
|
11
|
+
* `five-factor-e` package (`ipipneo`, NeuroQuest AI), whose reversed-item list
|
|
12
|
+
* agrees with every key here.
|
|
13
|
+
*
|
|
14
|
+
* Short: the 50-item IPIP Big-Five factor markers, in their published order,
|
|
15
|
+
* each with the factor and key printed beside it:
|
|
16
|
+
* https://ipip.ori.org/new_ipip-50-item-scale.htm (Goldberg, L. R. (1992). The
|
|
17
|
+
* development of markers for the Big-Five factor structure. Psychological
|
|
18
|
+
* Assessment, 4, 26-42). Factor IV there is Emotional Stability; here it is
|
|
19
|
+
* Neuroticism, every key turned over, so Neuroticism = 6 - Emotional Stability.
|
|
20
|
+
*
|
|
21
|
+
* The IPIP's items and scales are in the public domain (https://ipip.ori.org).
|
|
22
|
+
*
|
|
23
|
+
* Answers run 1 (very inaccurate) to 5 (very accurate). An item keyed minus
|
|
24
|
+
* counts 6 - answer. A scale's score is the mean of its answered items: raw,
|
|
25
|
+
* 1 to 5, against no norm table.
|
|
26
|
+
*/
|
|
27
|
+
import { phrase } from '@hanzo/i18n';
|
|
28
|
+
export const DOMAINS = ['O', 'C', 'E', 'A', 'N'];
|
|
29
|
+
export const DOMAIN = {
|
|
30
|
+
O: phrase('Openness'),
|
|
31
|
+
C: phrase('Conscientiousness'),
|
|
32
|
+
E: phrase('Extraversion'),
|
|
33
|
+
A: phrase('Agreeableness'),
|
|
34
|
+
N: phrase('Neuroticism'),
|
|
35
|
+
};
|
|
36
|
+
export const FACET = {
|
|
37
|
+
N1: phrase('Anxiety'),
|
|
38
|
+
N2: phrase('Anger'),
|
|
39
|
+
N3: phrase('Depression'),
|
|
40
|
+
N4: phrase('Self-consciousness'),
|
|
41
|
+
N5: phrase('Immoderation'),
|
|
42
|
+
N6: phrase('Vulnerability'),
|
|
43
|
+
E1: phrase('Friendliness'),
|
|
44
|
+
E2: phrase('Gregariousness'),
|
|
45
|
+
E3: phrase('Assertiveness'),
|
|
46
|
+
E4: phrase('Activity level'),
|
|
47
|
+
E5: phrase('Excitement-seeking'),
|
|
48
|
+
E6: phrase('Cheerfulness'),
|
|
49
|
+
O1: phrase('Imagination'),
|
|
50
|
+
O2: phrase('Artistic interests'),
|
|
51
|
+
O3: phrase('Emotionality'),
|
|
52
|
+
O4: phrase('Adventurousness'),
|
|
53
|
+
O5: phrase('Intellect'),
|
|
54
|
+
O6: phrase('Liberalism'),
|
|
55
|
+
A1: phrase('Trust'),
|
|
56
|
+
A2: phrase('Morality'),
|
|
57
|
+
A3: phrase('Altruism'),
|
|
58
|
+
A4: phrase('Cooperation'),
|
|
59
|
+
A5: phrase('Modesty'),
|
|
60
|
+
A6: phrase('Sympathy'),
|
|
61
|
+
C1: phrase('Self-efficacy'),
|
|
62
|
+
C2: phrase('Orderliness'),
|
|
63
|
+
C3: phrase('Dutifulness'),
|
|
64
|
+
C4: phrase('Achievement-striving'),
|
|
65
|
+
C5: phrase('Self-discipline'),
|
|
66
|
+
C6: phrase('Cautiousness'),
|
|
67
|
+
};
|
|
68
|
+
/** A domain's six facets, in order. */
|
|
69
|
+
export const FACETS = (d) => [1, 2, 3, 4, 5, 6].map((n) => `${d}${n}`);
|
|
70
|
+
/** The five answers, as the IPIP words them, for 1 to 5. */
|
|
71
|
+
export const ANCHORS = [phrase('Very inaccurate'), phrase('Moderately inaccurate'), phrase('Neither accurate nor inaccurate'), phrase('Moderately accurate'), phrase('Very accurate')];
|
|
72
|
+
/** The IPIP-NEO-120, as published: facet, key, statement. */
|
|
73
|
+
const long = [
|
|
74
|
+
['N1', '+', phrase('Worry about things.')],
|
|
75
|
+
['E1', '+', phrase('Make friends easily.')],
|
|
76
|
+
['O1', '+', phrase('Have a vivid imagination.')],
|
|
77
|
+
['A1', '+', phrase('Trust others.')],
|
|
78
|
+
['C1', '+', phrase('Complete tasks successfully.')],
|
|
79
|
+
['N2', '+', phrase('Get angry easily.')],
|
|
80
|
+
['E2', '+', phrase('Love large parties.')],
|
|
81
|
+
['O2', '+', phrase('Believe in the importance of art.')],
|
|
82
|
+
['A2', '-', phrase('Use others for my own ends.')],
|
|
83
|
+
['C2', '+', phrase('Like to tidy up.')],
|
|
84
|
+
['N3', '+', phrase('Often feel blue.')],
|
|
85
|
+
['E3', '+', phrase('Take charge.')],
|
|
86
|
+
['O3', '+', phrase('Experience my emotions intensely.')],
|
|
87
|
+
['A3', '+', phrase('Love to help others.')],
|
|
88
|
+
['C3', '+', phrase('Keep my promises.')],
|
|
89
|
+
['N4', '+', phrase('Find it difficult to approach others.')],
|
|
90
|
+
['E4', '+', phrase('Am always busy.')],
|
|
91
|
+
['O4', '+', phrase('Prefer variety to routine.')],
|
|
92
|
+
['A4', '-', phrase('Love a good fight.')],
|
|
93
|
+
['C4', '+', phrase('Work hard.')],
|
|
94
|
+
['N5', '+', phrase('Go on binges.')],
|
|
95
|
+
['E5', '+', phrase('Love excitement.')],
|
|
96
|
+
['O5', '+', phrase('Love to read challenging material.')],
|
|
97
|
+
['A5', '-', phrase('Believe that I am better than others.')],
|
|
98
|
+
['C5', '+', phrase('Am always prepared.')],
|
|
99
|
+
['N6', '+', phrase('Panic easily.')],
|
|
100
|
+
['E6', '+', phrase('Radiate joy.')],
|
|
101
|
+
['O6', '+', phrase('Tend to vote for liberal political candidates.')],
|
|
102
|
+
['A6', '+', phrase('Sympathize with the homeless.')],
|
|
103
|
+
['C6', '-', phrase('Jump into things without thinking.')],
|
|
104
|
+
['N1', '+', phrase('Fear for the worst.')],
|
|
105
|
+
['E1', '+', phrase('Feel comfortable around people.')],
|
|
106
|
+
['O1', '+', phrase('Enjoy wild flights of fantasy.')],
|
|
107
|
+
['A1', '+', phrase('Believe that others have good intentions.')],
|
|
108
|
+
['C1', '+', phrase('Excel in what I do.')],
|
|
109
|
+
['N2', '+', phrase('Get irritated easily.')],
|
|
110
|
+
['E2', '+', phrase('Talk to a lot of different people at parties.')],
|
|
111
|
+
['O2', '+', phrase('See beauty in things that others might not notice.')],
|
|
112
|
+
['A2', '-', phrase('Cheat to get ahead.')],
|
|
113
|
+
['C2', '-', phrase('Often forget to put things back in their proper place.')],
|
|
114
|
+
['N3', '+', phrase('Dislike myself.')],
|
|
115
|
+
['E3', '+', phrase('Try to lead others.')],
|
|
116
|
+
['O3', '+', phrase("Feel others' emotions.")],
|
|
117
|
+
['A3', '+', phrase('Am concerned about others.')],
|
|
118
|
+
['C3', '+', phrase('Tell the truth.')],
|
|
119
|
+
['N4', '+', phrase('Am afraid to draw attention to myself.')],
|
|
120
|
+
['E4', '+', phrase('Am always on the go.')],
|
|
121
|
+
['O4', '-', phrase('Prefer to stick with things that I know.')],
|
|
122
|
+
['A4', '-', phrase('Yell at people.')],
|
|
123
|
+
['C4', '+', phrase("Do more than what's expected of me.")],
|
|
124
|
+
['N5', '-', phrase('Rarely overindulge.')],
|
|
125
|
+
['E5', '+', phrase('Seek adventure.')],
|
|
126
|
+
['O5', '-', phrase('Avoid philosophical discussions.')],
|
|
127
|
+
['A5', '-', phrase('Think highly of myself.')],
|
|
128
|
+
['C5', '+', phrase('Carry out my plans.')],
|
|
129
|
+
['N6', '+', phrase('Become overwhelmed by events.')],
|
|
130
|
+
['E6', '+', phrase('Have a lot of fun.')],
|
|
131
|
+
['O6', '+', phrase('Believe that there is no absolute right and wrong.')],
|
|
132
|
+
['A6', '+', phrase('Feel sympathy for those who are worse off than myself.')],
|
|
133
|
+
['C6', '-', phrase('Make rash decisions.')],
|
|
134
|
+
['N1', '+', phrase('Am afraid of many things.')],
|
|
135
|
+
['E1', '-', phrase('Avoid contacts with others.')],
|
|
136
|
+
['O1', '+', phrase('Love to daydream.')],
|
|
137
|
+
['A1', '+', phrase('Trust what people say.')],
|
|
138
|
+
['C1', '+', phrase('Handle tasks smoothly.')],
|
|
139
|
+
['N2', '+', phrase('Lose my temper.')],
|
|
140
|
+
['E2', '-', phrase('Prefer to be alone.')],
|
|
141
|
+
['O2', '-', phrase('Do not like poetry.')],
|
|
142
|
+
['A2', '-', phrase('Take advantage of others.')],
|
|
143
|
+
['C2', '-', phrase('Leave a mess in my room.')],
|
|
144
|
+
['N3', '+', phrase('Am often down in the dumps.')],
|
|
145
|
+
['E3', '+', phrase('Take control of things.')],
|
|
146
|
+
['O3', '-', phrase('Rarely notice my emotional reactions.')],
|
|
147
|
+
['A3', '-', phrase('Am indifferent to the feelings of others.')],
|
|
148
|
+
['C3', '-', phrase('Break rules.')],
|
|
149
|
+
['N4', '+', phrase('Only feel comfortable with friends.')],
|
|
150
|
+
['E4', '+', phrase('Do a lot in my spare time.')],
|
|
151
|
+
['O4', '-', phrase('Dislike changes.')],
|
|
152
|
+
['A4', '-', phrase('Insult people.')],
|
|
153
|
+
['C4', '-', phrase('Do just enough work to get by.')],
|
|
154
|
+
['N5', '-', phrase('Easily resist temptations.')],
|
|
155
|
+
['E5', '+', phrase('Enjoy being reckless.')],
|
|
156
|
+
['O5', '-', phrase('Have difficulty understanding abstract ideas.')],
|
|
157
|
+
['A5', '-', phrase('Have a high opinion of myself.')],
|
|
158
|
+
['C5', '-', phrase('Waste my time.')],
|
|
159
|
+
['N6', '+', phrase("Feel that I'm unable to deal with things.")],
|
|
160
|
+
['E6', '+', phrase('Love life.')],
|
|
161
|
+
['O6', '-', phrase('Tend to vote for conservative political candidates.')],
|
|
162
|
+
['A6', '-', phrase("Am not interested in other people's problems.")],
|
|
163
|
+
['C6', '-', phrase('Rush into things.')],
|
|
164
|
+
['N1', '+', phrase('Get stressed out easily.')],
|
|
165
|
+
['E1', '-', phrase('Keep others at a distance.')],
|
|
166
|
+
['O1', '+', phrase('Like to get lost in thought.')],
|
|
167
|
+
['A1', '-', phrase('Distrust people.')],
|
|
168
|
+
['C1', '+', phrase('Know how to get things done.')],
|
|
169
|
+
['N2', '-', phrase('Am not easily annoyed.')],
|
|
170
|
+
['E2', '-', phrase('Avoid crowds.')],
|
|
171
|
+
['O2', '-', phrase('Do not enjoy going to art museums.')],
|
|
172
|
+
['A2', '-', phrase("Obstruct others' plans.")],
|
|
173
|
+
['C2', '-', phrase('Leave my belongings around.')],
|
|
174
|
+
['N3', '-', phrase('Feel comfortable with myself.')],
|
|
175
|
+
['E3', '-', phrase('Wait for others to lead the way.')],
|
|
176
|
+
['O3', '-', phrase("Don't understand people who get emotional.")],
|
|
177
|
+
['A3', '-', phrase('Take no time for others.')],
|
|
178
|
+
['C3', '-', phrase('Break my promises.')],
|
|
179
|
+
['N4', '-', phrase('Am not bothered by difficult social situations.')],
|
|
180
|
+
['E4', '-', phrase('Like to take it easy.')],
|
|
181
|
+
['O4', '-', phrase('Am attached to conventional ways.')],
|
|
182
|
+
['A4', '-', phrase('Get back at others.')],
|
|
183
|
+
['C4', '-', phrase('Put little time and effort into my work.')],
|
|
184
|
+
['N5', '-', phrase('Am able to control my cravings.')],
|
|
185
|
+
['E5', '+', phrase('Act wild and crazy.')],
|
|
186
|
+
['O5', '-', phrase('Am not interested in theoretical discussions.')],
|
|
187
|
+
['A5', '-', phrase('Boast about my virtues.')],
|
|
188
|
+
['C5', '-', phrase('Have difficulty starting tasks.')],
|
|
189
|
+
['N6', '-', phrase('Remain calm under pressure.')],
|
|
190
|
+
['E6', '+', phrase('Look at the bright side of life.')],
|
|
191
|
+
['O6', '-', phrase('Believe that we should be tough on crime.')],
|
|
192
|
+
['A6', '-', phrase('Try not to think about the needy.')],
|
|
193
|
+
['C6', '-', phrase('Act without thinking.')],
|
|
194
|
+
];
|
|
195
|
+
/** The 50 markers, as published: factor (I Extraversion, II Agreeableness, III Conscientiousness, IV Emotional Stability, V Intellect/Imagination), key, statement. */
|
|
196
|
+
const short = [
|
|
197
|
+
[1, '+', phrase('Am the life of the party.')],
|
|
198
|
+
[2, '-', phrase('Feel little concern for others.')],
|
|
199
|
+
[3, '+', phrase('Am always prepared.')],
|
|
200
|
+
[4, '-', phrase('Get stressed out easily.')],
|
|
201
|
+
[5, '+', phrase('Have a rich vocabulary.')],
|
|
202
|
+
[1, '-', phrase("Don't talk a lot.")],
|
|
203
|
+
[2, '+', phrase('Am interested in people.')],
|
|
204
|
+
[3, '-', phrase('Leave my belongings around.')],
|
|
205
|
+
[4, '+', phrase('Am relaxed most of the time.')],
|
|
206
|
+
[5, '-', phrase('Have difficulty understanding abstract ideas.')],
|
|
207
|
+
[1, '+', phrase('Feel comfortable around people.')],
|
|
208
|
+
[2, '-', phrase('Insult people.')],
|
|
209
|
+
[3, '+', phrase('Pay attention to details.')],
|
|
210
|
+
[4, '-', phrase('Worry about things.')],
|
|
211
|
+
[5, '+', phrase('Have a vivid imagination.')],
|
|
212
|
+
[1, '-', phrase('Keep in the background.')],
|
|
213
|
+
[2, '+', phrase("Sympathize with others' feelings.")],
|
|
214
|
+
[3, '-', phrase('Make a mess of things.')],
|
|
215
|
+
[4, '+', phrase('Seldom feel blue.')],
|
|
216
|
+
[5, '-', phrase('Am not interested in abstract ideas.')],
|
|
217
|
+
[1, '+', phrase('Start conversations.')],
|
|
218
|
+
[2, '-', phrase("Am not interested in other people's problems.")],
|
|
219
|
+
[3, '+', phrase('Get chores done right away.')],
|
|
220
|
+
[4, '-', phrase('Am easily disturbed.')],
|
|
221
|
+
[5, '+', phrase('Have excellent ideas.')],
|
|
222
|
+
[1, '-', phrase('Have little to say.')],
|
|
223
|
+
[2, '+', phrase('Have a soft heart.')],
|
|
224
|
+
[3, '-', phrase('Often forget to put things back in their proper place.')],
|
|
225
|
+
[4, '-', phrase('Get upset easily.')],
|
|
226
|
+
[5, '-', phrase('Do not have a good imagination.')],
|
|
227
|
+
[1, '+', phrase('Talk to a lot of different people at parties.')],
|
|
228
|
+
[2, '-', phrase('Am not really interested in others.')],
|
|
229
|
+
[3, '+', phrase('Like order.')],
|
|
230
|
+
[4, '-', phrase('Change my mood a lot.')],
|
|
231
|
+
[5, '+', phrase('Am quick to understand things.')],
|
|
232
|
+
[1, '-', phrase("Don't like to draw attention to myself.")],
|
|
233
|
+
[2, '+', phrase('Take time out for others.')],
|
|
234
|
+
[3, '-', phrase('Shirk my duties.')],
|
|
235
|
+
[4, '-', phrase('Have frequent mood swings.')],
|
|
236
|
+
[5, '+', phrase('Use difficult words.')],
|
|
237
|
+
[1, '+', phrase("Don't mind being the center of attention.")],
|
|
238
|
+
[2, '+', phrase("Feel others' emotions.")],
|
|
239
|
+
[3, '+', phrase('Follow a schedule.')],
|
|
240
|
+
[4, '-', phrase('Get irritated easily.')],
|
|
241
|
+
[5, '+', phrase('Spend time reflecting on things.')],
|
|
242
|
+
[1, '-', phrase('Am quiet around strangers.')],
|
|
243
|
+
[2, '+', phrase('Make people feel at ease.')],
|
|
244
|
+
[3, '+', phrase('Am exacting in my work.')],
|
|
245
|
+
[4, '-', phrase('Often feel blue.')],
|
|
246
|
+
[5, '+', phrase('Am full of ideas.')],
|
|
247
|
+
];
|
|
248
|
+
const FACTOR = { 1: 'E', 2: 'A', 3: 'C', 4: 'N', 5: 'O' };
|
|
249
|
+
export const ITEMS = {
|
|
250
|
+
long: long.map(([facet, key, text]) => ({ text, domain: facet[0], facet, key: key === '+' ? 1 : -1 })),
|
|
251
|
+
short: short.map(([factor, key, text]) => ({ text, domain: FACTOR[factor], facet: null, key: (key === '+') !== (factor === 4) ? 1 : -1 })),
|
|
252
|
+
};
|
|
253
|
+
/** Every scale's mean over its answered items (0 where none is); `answers[i]` is item i's 1 to 5, 0 unanswered. */
|
|
254
|
+
export function score(form, answers) {
|
|
255
|
+
const sums = new Map();
|
|
256
|
+
const add = (scale, v) => {
|
|
257
|
+
const [s, n] = sums.get(scale) ?? [0, 0];
|
|
258
|
+
sums.set(scale, [s + v, n + 1]);
|
|
259
|
+
};
|
|
260
|
+
ITEMS[form].forEach((item, i) => {
|
|
261
|
+
const a = answers[i] ?? 0;
|
|
262
|
+
if (!a)
|
|
263
|
+
return;
|
|
264
|
+
const v = item.key === 1 ? a : 6 - a;
|
|
265
|
+
add(item.domain, v);
|
|
266
|
+
if (item.facet)
|
|
267
|
+
add(item.facet, v);
|
|
268
|
+
});
|
|
269
|
+
const mean = (scale) => {
|
|
270
|
+
const [s, n] = sums.get(scale) ?? [0, 0];
|
|
271
|
+
return n ? s / n : 0;
|
|
272
|
+
};
|
|
273
|
+
return {
|
|
274
|
+
domains: Object.fromEntries(DOMAINS.map((d) => [d, mean(d)])),
|
|
275
|
+
facets: form === 'long' ? Object.fromEntries(DOMAINS.flatMap(FACETS).map((f) => [f, mean(f)])) : {},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/** How a high (≥ 3.5) and a low (≤ 2.5) domain reads in the clone's instructions. Prompt text: English. */
|
|
279
|
+
const READS = {
|
|
280
|
+
O: [
|
|
281
|
+
'Curious and imaginative: drawn to ideas, abstraction and new approaches; writes with range and the odd metaphor.',
|
|
282
|
+
'Practical and concrete: trusts the proven over the novel; writes plainly, with examples rather than theory.',
|
|
283
|
+
],
|
|
284
|
+
C: ['Organized and thorough: plans ahead and follows through; writes in a structured, precise way.', 'Spontaneous and flexible: improvises rather than plans; writes loosely and gets to the point.'],
|
|
285
|
+
E: ['Outgoing and energetic: thinks out loud and takes the lead; writes with warmth and enthusiasm.', 'Reserved and reflective: thinks before speaking; writes briefly and without fuss.'],
|
|
286
|
+
A: ['Warm and cooperative: assumes good intent; writes tactfully and generously.', 'Direct and skeptical: questions claims and says what they think; writes bluntly, without softening.'],
|
|
287
|
+
N: ['Sensitive to pressure: alert to what could go wrong; writes with care and caveats.', 'Calm and steady: unflustered under pressure; writes with an even tone.'],
|
|
288
|
+
};
|
|
289
|
+
const NAME = { long: 'IPIP-NEO-120', short: 'IPIP 50-item Big-Five markers' };
|
|
290
|
+
const fixed = (m) => m.toFixed(1);
|
|
291
|
+
/**
|
|
292
|
+
* How `name` tends to think and write, from a whole answer sheet's score: a
|
|
293
|
+
* line for each domain at either end, the facets furthest out (long form), and
|
|
294
|
+
* the five means.
|
|
295
|
+
*/
|
|
296
|
+
export function nature(name, form, s) {
|
|
297
|
+
const lines = DOMAINS.flatMap((d) => (s.domains[d] >= 3.5 ? [READS[d][0]] : s.domains[d] <= 2.5 ? [READS[d][1]] : []));
|
|
298
|
+
const far = Object.entries(s.facets).sort((a, b) => Math.abs(b[1] - 3) - Math.abs(a[1] - 3));
|
|
299
|
+
const list = (fs) => fs.slice(0, 3).map(([f, m]) => `${FACET[f]} (${fixed(m)})`).join(', ');
|
|
300
|
+
const high = list(far.filter(([, m]) => m >= 4.25));
|
|
301
|
+
const low = list(far.filter(([, m]) => m <= 1.75));
|
|
302
|
+
if (high || low)
|
|
303
|
+
lines.push(`Stands out: ${[high && `high ${high}`, low && `low ${low}`].filter(Boolean).join('; ')}.`);
|
|
304
|
+
const means = `Big Five (${NAME[form]}, means on 1 to 5): ${DOMAINS.map((d) => `${DOMAIN[d]} ${fixed(s.domains[d])}`).join(', ')}.`;
|
|
305
|
+
return [lines.length ? `How ${name} thinks and writes:\n${lines.map((l) => `- ${l}`).join('\n')}` : '', means].filter(Boolean).join('\n');
|
|
306
|
+
}
|
|
307
|
+
const sheet = (form, v) => {
|
|
308
|
+
const n = ITEMS[form].length;
|
|
309
|
+
return Array.isArray(v) && v.length === n && v.every((a) => Number.isInteger(a) && a >= 0 && a <= 5) ? v : Array(n).fill(0);
|
|
310
|
+
};
|
|
311
|
+
const KEY = (who) => `hanzo.build.ocean.${who}`;
|
|
312
|
+
/** The answers kept for `who`, or blank sheets. */
|
|
313
|
+
export function kept(who) {
|
|
314
|
+
let v = {};
|
|
315
|
+
try {
|
|
316
|
+
const raw = JSON.parse(window.localStorage.getItem(KEY(who)) ?? 'null');
|
|
317
|
+
if (raw && typeof raw === 'object')
|
|
318
|
+
v = raw;
|
|
319
|
+
}
|
|
320
|
+
catch {
|
|
321
|
+
/* blank sheets */
|
|
322
|
+
}
|
|
323
|
+
return { form: v.form === 'long' ? 'long' : 'short', short: sheet('short', v.short), long: sheet('long', v.long) };
|
|
324
|
+
}
|
|
325
|
+
export function keep(who, a) {
|
|
326
|
+
try {
|
|
327
|
+
window.localStorage.setItem(KEY(who), JSON.stringify(a));
|
|
328
|
+
}
|
|
329
|
+
catch {
|
|
330
|
+
/* kept only while the dialog is open */
|
|
331
|
+
}
|
|
332
|
+
}
|
package/lib/customize/ui.d.ts
CHANGED
|
@@ -59,12 +59,19 @@ export declare function Add({ name, added, busy, onPress, use }: {
|
|
|
59
59
|
onPress: () => void;
|
|
60
60
|
use?: boolean;
|
|
61
61
|
}): import("react").JSX.Element;
|
|
62
|
-
/**
|
|
63
|
-
|
|
62
|
+
/**
|
|
63
|
+
* A dialog with a title, a close control and a body that scrolls inside the
|
|
64
|
+
* window; `full`, it is the whole screen on a phone. Opening a `<dialog>`
|
|
65
|
+
* focuses its first focusable element, so the dialog is that element
|
|
66
|
+
* (tabIndex -1, no ring): the close control wears the focus ring only once the
|
|
67
|
+
* keyboard moves to it.
|
|
68
|
+
*/
|
|
69
|
+
export declare function Sheet({ title, open, onOpenChange, width, full, children }: {
|
|
64
70
|
title: string;
|
|
65
71
|
open: boolean;
|
|
66
72
|
onOpenChange: (o: boolean) => void;
|
|
67
73
|
width?: number;
|
|
74
|
+
full?: boolean;
|
|
68
75
|
children: ReactNode;
|
|
69
76
|
}): import("react").JSX.Element;
|
|
70
77
|
/** Asks before a delete; says what goes with it. `what` is the thing's name, `says` comes already said. */
|
package/lib/customize/ui.js
CHANGED
|
@@ -10,7 +10,7 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
10
10
|
* line or a label a tab hands them comes already said, since it may be a
|
|
11
11
|
* name or a description that is drawn as given.
|
|
12
12
|
*/
|
|
13
|
-
import { SizableText, XStack, YStack } from '@hanzo/gui';
|
|
13
|
+
import { SizableText, useMedia, XStack, YStack } from '@hanzo/gui';
|
|
14
14
|
import { useI18n } from '@hanzo/i18n/react';
|
|
15
15
|
import { Check, Plus, X } from '@hanzogui/lucide-icons-2';
|
|
16
16
|
import { Button, Dialog, DialogContent, DialogTitle } from '@hanzo/ui';
|
|
@@ -55,10 +55,39 @@ export function Add({ name, added, busy, onPress, use = false }) {
|
|
|
55
55
|
}
|
|
56
56
|
return (_jsxs(Button, { size: "sm", variant: "outline", "aria-label": use ? t('Use {name}', { name }) : t('Add {name}', { name }), disabled: busy, onPress: onPress, children: [_jsx(Plus, { size: 14 }), " ", use ? t('Use') : t('Add')] }));
|
|
57
57
|
}
|
|
58
|
-
/**
|
|
59
|
-
|
|
58
|
+
/**
|
|
59
|
+
* A phone's whole screen, clear of the notch and the home bar: pinned to the
|
|
60
|
+
* viewport, since the `<dialog>` around it is inset by its padding and the
|
|
61
|
+
* page's scrollbar gutter, and out of @hanzo/ui's floating-card glass, which
|
|
62
|
+
* it draws on `[data-slot="dialog-content"]`.
|
|
63
|
+
*/
|
|
64
|
+
const SCREEN = {
|
|
65
|
+
'data-slot': 'dialog-screen',
|
|
66
|
+
position: 'fixed',
|
|
67
|
+
t: 0,
|
|
68
|
+
l: 0,
|
|
69
|
+
width: '100vw',
|
|
70
|
+
maxW: '100vw',
|
|
71
|
+
height: '100dvh',
|
|
72
|
+
maxH: '100dvh',
|
|
73
|
+
rounded: 0,
|
|
74
|
+
borderWidth: 0,
|
|
75
|
+
pt: 'max(16px, env(safe-area-inset-top))',
|
|
76
|
+
pr: 'max(16px, env(safe-area-inset-right))',
|
|
77
|
+
pb: 'max(16px, env(safe-area-inset-bottom))',
|
|
78
|
+
pl: 'max(16px, env(safe-area-inset-left))',
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* A dialog with a title, a close control and a body that scrolls inside the
|
|
82
|
+
* window; `full`, it is the whole screen on a phone. Opening a `<dialog>`
|
|
83
|
+
* focuses its first focusable element, so the dialog is that element
|
|
84
|
+
* (tabIndex -1, no ring): the close control wears the focus ring only once the
|
|
85
|
+
* keyboard moves to it.
|
|
86
|
+
*/
|
|
87
|
+
export function Sheet({ title, open, onOpenChange, width = 560, full = false, children }) {
|
|
60
88
|
const { t } = useI18n();
|
|
61
|
-
|
|
89
|
+
const screen = full && !useMedia().sm;
|
|
90
|
+
return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsxs(DialogContent, { maxW: width, showCloseButton: false, maxH: "88vh", gap: "$3", tabIndex: -1, focusVisibleStyle: { outlineWidth: 0 }, ...(screen ? SCREEN : null), children: [_jsxs(XStack, { items: "center", justify: "space-between", gap: "$2", children: [_jsx(DialogTitle, { numberOfLines: 1, flex: 1, children: title }), _jsx(XStack, { render: "button", "aria-label": t('Close'), onPress: () => onOpenChange(false), width: 32, height: 32, mr: -6, rounded: 999, items: "center", justify: "center", shrink: 0, cursor: "pointer", hoverStyle: { bg: '$hover' }, "$max-sm": { width: 44, height: 44, mr: -12 }, children: _jsx(X, { size: 16 }) })] }), _jsx(YStack, { gap: "$3", overflow: "scroll", minH: 0, shrink: 1, children: children })] }) }));
|
|
62
91
|
}
|
|
63
92
|
/** Asks before a delete; says what goes with it. `what` is the thing's name, `says` comes already said. */
|
|
64
93
|
export function Confirm({ what, says, open, onOpenChange, onYes }) {
|
package/lib/host.d.ts
CHANGED
|
@@ -99,6 +99,13 @@ export interface Host {
|
|
|
99
99
|
};
|
|
100
100
|
/** Open a host address in this window. hanzo.build keeps the window on its own origin. */
|
|
101
101
|
open: (href: string) => void;
|
|
102
|
+
/**
|
|
103
|
+
* Take the person to top the prepaid balance up, returning to this page with the
|
|
104
|
+
* model they chose (`?model=`) once paid. Another maker's models are paid from the
|
|
105
|
+
* balance on any plan, so a host that offers a top-up has them selectable on Free.
|
|
106
|
+
* Absent, they follow the plan as before.
|
|
107
|
+
*/
|
|
108
|
+
topUp?: (model?: string) => void;
|
|
102
109
|
signIn?: () => void;
|
|
103
110
|
signOut?: () => void;
|
|
104
111
|
/** A page tab's remote address, shown by the host (Hanzo Desktop: a native webview). Absent, a browser frames what it may. */
|
package/lib/index.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ export { SOURCE, type Item, type Kind as ItemKind, type Source } from './api/lib
|
|
|
26
26
|
export { Scheduled, schedule } from './scheduled.tsx';
|
|
27
27
|
export { Editor } from './automations.tsx';
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled, type Group } from './nav.tsx';
|
|
29
|
+
export { MARKS, type Icon, type Mark } from './marks.tsx';
|
|
30
|
+
export { useFunds, type Funds } from './mind.ts';
|
|
29
31
|
export { DevSection, DOTS, useSessions } from './section.tsx';
|
|
30
32
|
export { HostProvider } from './host.tsx';
|
|
31
33
|
export { Slack, useWho, Who } from './foot.tsx';
|
package/lib/index.js
CHANGED
|
@@ -26,6 +26,8 @@ export { SOURCE } from './api/library.js';
|
|
|
26
26
|
export { Scheduled, schedule } from './scheduled.js';
|
|
27
27
|
export { Editor } from './automations.js';
|
|
28
28
|
export { library, nav, NEW, own, sections, tabs, useScheduled } from './nav.js';
|
|
29
|
+
export { MARKS } from './marks.js';
|
|
30
|
+
export { useFunds } from './mind.js';
|
|
29
31
|
export { DevSection, DOTS, useSessions } from './section.js';
|
|
30
32
|
export { HostProvider } from './host.js';
|
|
31
33
|
export { Slack, useWho, Who } from './foot.js';
|
package/lib/landing.js
CHANGED
|
@@ -133,7 +133,7 @@ export function Landing({ onStarted }) {
|
|
|
133
133
|
const places = usePlaces(target, signed);
|
|
134
134
|
// The model and effort Chat shares, and dictation into the ask.
|
|
135
135
|
const { limits } = useLimits(signed ? (signal) => readLimits(target, signal) : null, target);
|
|
136
|
-
const mind = useMind(target, limits?.plan);
|
|
136
|
+
const mind = useMind(target, limits?.plan, host.topUp);
|
|
137
137
|
const voice = useVoice({ speech: useEar(target), language: useSpoken(), ...useDictation(draft, setDraft) });
|
|
138
138
|
const talk = useTalk({ baseUrl: target.api, token: () => target.token(), ...(target.org ? { org: target.org } : {}) });
|
|
139
139
|
// What the run carries beside the ask: skills, memory and the mode, as Chat's turns do.
|