@xynogen/pix-core 0.1.0 → 0.1.1
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/package.json +49 -40
- package/src/commands/clear/clear.ts +1 -1
- package/src/commands/copy-all/copy-all.ts +21 -6
- package/src/commands/diff/diff.ts +45 -13
- package/src/commands/models/models.test.ts +2 -2
- package/src/commands/models/models.ts +1 -1
- package/src/commands/update/update.test.ts +8 -8
- package/src/commands/update/update.ts +4 -4
- package/src/index.ts +9 -9
- package/src/lib/data.ts +1 -1
- package/src/nudge/capability.test.ts +5 -8
- package/src/nudge/capability.ts +3 -1
- package/src/nudge/index.ts +1 -1
- package/src/nudge/tools.test.ts +21 -9
- package/src/nudge/tools.ts +0 -2
- package/src/tool/ask/ask.test.ts +29 -18
- package/src/tool/ask/ask.ts +1004 -979
- package/src/tool/ask/single-select-layout.test.ts +21 -5
- package/src/tool/ask/single-select-layout.ts +48 -14
- package/src/tool/todo/todo.ts +24 -37
- package/src/tool/toolbox/toolbox.test.ts +2 -2
- package/src/tool/toolbox/toolbox.ts +0 -1
- package/src/ui/footer.ts +3 -4
- package/src/ui/welcome.test.ts +6 -6
package/src/tool/ask/ask.test.ts
CHANGED
|
@@ -7,17 +7,21 @@
|
|
|
7
7
|
|
|
8
8
|
import { describe, expect, test } from "bun:test";
|
|
9
9
|
import {
|
|
10
|
-
type OptionData,
|
|
11
|
-
type QuestionData,
|
|
12
10
|
buildResponseText,
|
|
13
11
|
formatAnswerScalar,
|
|
14
12
|
hasAnyPreview,
|
|
13
|
+
type OptionData,
|
|
14
|
+
type QuestionData,
|
|
15
15
|
sentinelsFor,
|
|
16
16
|
} from "./ask.ts";
|
|
17
17
|
|
|
18
18
|
// ── Fixtures ──────────────────────────────────────────────────────────
|
|
19
19
|
|
|
20
|
-
const opt = (
|
|
20
|
+
const opt = (
|
|
21
|
+
label: string,
|
|
22
|
+
description = "Test option",
|
|
23
|
+
preview?: string,
|
|
24
|
+
): OptionData => ({
|
|
21
25
|
label,
|
|
22
26
|
description,
|
|
23
27
|
...(preview ? { preview } : {}),
|
|
@@ -55,10 +59,7 @@ const qWithPreview: QuestionData = {
|
|
|
55
59
|
const qSingleNoPreview: QuestionData = {
|
|
56
60
|
question: "Color?",
|
|
57
61
|
header: "Color",
|
|
58
|
-
options: [
|
|
59
|
-
opt("Red", "Ruby red"),
|
|
60
|
-
opt("Blue", "Ocean blue"),
|
|
61
|
-
],
|
|
62
|
+
options: [opt("Red", "Ruby red"), opt("Blue", "Ocean blue")],
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
// ── hasAnyPreview ─────────────────────────────────────────────────────
|
|
@@ -85,8 +86,8 @@ describe("sentinelsFor", () => {
|
|
|
85
86
|
test('single-select without preview appends "Type something."', () => {
|
|
86
87
|
const r = sentinelsFor(qSingleNoPreview);
|
|
87
88
|
expect(r).toHaveLength(1);
|
|
88
|
-
expect(r[0]
|
|
89
|
-
expect(r[0]
|
|
89
|
+
expect(r[0]?.kind).toBe("other");
|
|
90
|
+
expect(r[0]?.label).toBe("Type something.");
|
|
90
91
|
});
|
|
91
92
|
|
|
92
93
|
test('single-select with preview appends nothing (only "Chat about this" is separate)', () => {
|
|
@@ -97,8 +98,8 @@ describe("sentinelsFor", () => {
|
|
|
97
98
|
test('multi-select appends "Next"', () => {
|
|
98
99
|
const r = sentinelsFor(qMulti);
|
|
99
100
|
expect(r).toHaveLength(1);
|
|
100
|
-
expect(r[0]
|
|
101
|
-
expect(r[0]
|
|
101
|
+
expect(r[0]?.kind).toBe("next");
|
|
102
|
+
expect(r[0]?.label).toBe("Next");
|
|
102
103
|
});
|
|
103
104
|
|
|
104
105
|
test("multi-select never appends Type something.", () => {
|
|
@@ -109,14 +110,14 @@ describe("sentinelsFor", () => {
|
|
|
109
110
|
test("empty options still gets freeform sentinel (no preview = single-select)", () => {
|
|
110
111
|
const r = sentinelsFor({ question: "?", header: "X", options: [] });
|
|
111
112
|
expect(r).toHaveLength(1);
|
|
112
|
-
expect(r[0]
|
|
113
|
+
expect(r[0]?.kind).toBe("other");
|
|
113
114
|
});
|
|
114
115
|
});
|
|
115
116
|
|
|
116
117
|
// ── formatAnswerScalar ────────────────────────────────────────────────
|
|
117
118
|
|
|
118
119
|
describe("formatAnswerScalar", () => {
|
|
119
|
-
test(
|
|
120
|
+
test("option kind returns the answer string", () => {
|
|
120
121
|
const a = {
|
|
121
122
|
questionIndex: 0,
|
|
122
123
|
question: "Q",
|
|
@@ -126,7 +127,7 @@ describe("formatAnswerScalar", () => {
|
|
|
126
127
|
expect(formatAnswerScalar(a)).toBe("REST");
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
test(
|
|
130
|
+
test("multi kind joins selected with comma", () => {
|
|
130
131
|
const a = {
|
|
131
132
|
questionIndex: 0,
|
|
132
133
|
question: "Q",
|
|
@@ -137,7 +138,7 @@ describe("formatAnswerScalar", () => {
|
|
|
137
138
|
expect(formatAnswerScalar(a)).toBe("Auth, Search");
|
|
138
139
|
});
|
|
139
140
|
|
|
140
|
-
test(
|
|
141
|
+
test("custom kind returns the typed text", () => {
|
|
141
142
|
const a = {
|
|
142
143
|
questionIndex: 0,
|
|
143
144
|
question: "Q",
|
|
@@ -147,7 +148,7 @@ describe("formatAnswerScalar", () => {
|
|
|
147
148
|
expect(formatAnswerScalar(a)).toBe("my custom answer");
|
|
148
149
|
});
|
|
149
150
|
|
|
150
|
-
test(
|
|
151
|
+
test("chat kind returns (chat)", () => {
|
|
151
152
|
const a = {
|
|
152
153
|
questionIndex: 0,
|
|
153
154
|
question: "Q",
|
|
@@ -163,7 +164,12 @@ describe("formatAnswerScalar", () => {
|
|
|
163
164
|
describe("buildResponseText", () => {
|
|
164
165
|
test("formats single answer", () => {
|
|
165
166
|
const answers = [
|
|
166
|
-
{
|
|
167
|
+
{
|
|
168
|
+
questionIndex: 0,
|
|
169
|
+
question: "Which approach?",
|
|
170
|
+
kind: "option" as const,
|
|
171
|
+
answer: "REST",
|
|
172
|
+
},
|
|
167
173
|
];
|
|
168
174
|
const text = buildResponseText(answers, [qSingle]);
|
|
169
175
|
expect(text).toContain("REST");
|
|
@@ -202,7 +208,12 @@ describe("buildResponseText", () => {
|
|
|
202
208
|
test("formats multiple answers", () => {
|
|
203
209
|
const qs = [qSingle, qMulti];
|
|
204
210
|
const answers = [
|
|
205
|
-
{
|
|
211
|
+
{
|
|
212
|
+
questionIndex: 0,
|
|
213
|
+
question: "Which approach?",
|
|
214
|
+
kind: "option" as const,
|
|
215
|
+
answer: "GraphQL",
|
|
216
|
+
},
|
|
206
217
|
{
|
|
207
218
|
questionIndex: 1,
|
|
208
219
|
question: "Which features?",
|