@selesai/code 0.8.4 → 0.8.6
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/CHANGELOG.md +22 -0
- package/README.md +7 -1
- package/dist/core/slash-commands.js +1 -0
- package/dist/defaults/models.json +46 -55
- package/dist/defaults/settings.json +7 -8
- package/dist/extensions/agent-browser.test.ts +178 -2
- package/dist/extensions/agent-browser.ts +2 -0
- package/dist/extensions/copy-turn.test.ts +229 -0
- package/dist/extensions/copy-turn.ts +11 -0
- package/dist/extensions/grep-app/index.test.ts +356 -1
- package/dist/extensions/grep-app/index.ts +6 -1
- package/dist/extensions/handoff-new.test.ts +351 -161
- package/dist/extensions/handoff-new.ts +3 -0
- package/dist/extensions/inline-skills.test.ts +93 -0
- package/dist/extensions/inline-skills.ts +3 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +26 -3
- package/dist/extensions/pi-subagents/README.md +2 -0
- package/dist/extensions/pi-subagents/agents/builder.md +5 -2
- package/dist/extensions/pi-subagents/agents/commentator.md +1 -1
- package/dist/extensions/pi-subagents/docs/configuration.md +54 -2
- package/dist/extensions/pi-subagents/docs/observability.md +1 -1
- package/dist/extensions/pi-subagents/docs/tool-reference.md +1 -1
- package/dist/extensions/pi-subagents/docs/workflows.md +1 -1
- package/dist/extensions/pi-subagents/package-lock.json +2 -2
- package/dist/extensions/pi-subagents/package.json +1 -1
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +1 -1
- package/dist/extensions/pi-subagents/src/agents/agents.ts +9 -3
- package/dist/extensions/pi-subagents/src/extension/config.ts +12 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +40 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +104 -14
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +5 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +3 -9
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +2 -2
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +4 -1
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +4 -7
- package/dist/extensions/pi-subagents/src/missions/store.ts +4 -4
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +6 -2
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +374 -0
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +9 -5
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +117 -29
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +12 -6
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +7 -1
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +14 -5
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +33 -15
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +104 -0
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +17 -3
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +19 -1
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +2 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +5 -2
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +12 -6
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +3 -3
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +84 -36
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +2 -1
- package/dist/extensions/pi-subagents/src/runs/foreground/chain-execution.ts +37 -2
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +135 -22
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +12 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +7 -4
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +171 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +653 -196
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +13 -4
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +286 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +23 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +2 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +44 -1
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +280 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +4 -2
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +19 -3
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +17 -5
- package/dist/extensions/pi-subagents/src/shared/session-lineage.ts +71 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +108 -0
- package/dist/extensions/pi-subagents/src/shared/utils.ts +3 -1
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +7 -5
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +226 -13
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +22 -5
- package/dist/extensions/pi-subagents/src/workflows/workflow-auto-relaunch.ts +28 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +87 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +96 -6
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +28 -5
- package/dist/extensions/pi-subagents/test/integration/chain-execution.test.ts +8 -5
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +83 -2
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +211 -15
- package/dist/extensions/pi-subagents/test/integration/parallel-execution.test.ts +41 -3
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +314 -10
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +31 -1
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +317 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +21 -2
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +16 -1
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +6 -1
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +75 -4
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +18 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +29 -1
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +31 -5
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +139 -1
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +10 -0
- package/dist/extensions/pi-subagents/test/unit/handoff-adoption.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +2 -1
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +171 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +30 -4
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/owned-process-tree.test.ts +69 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +83 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +2 -2
- package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +55 -2
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +12 -1
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +7 -7
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +9 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +4 -3
- package/dist/extensions/pi-subagents/test/unit/session-lineage.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +28 -0
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +10 -1
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +39 -0
- package/dist/extensions/pi-subagents/test/unit/timeout-defaults.test.ts +65 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-auto-relaunch.test.ts +45 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +61 -0
- package/dist/extensions/ponytail/index.js +11 -0
- package/dist/extensions/ponytail/ponytail-config.cjs +2 -0
- package/dist/extensions/ponytail/ponytail-instructions.cjs +6 -0
- package/dist/extensions/ponytail/test/extension.test.js +274 -140
- package/dist/extensions/ponytail/test/helpers.test.js +280 -92
- package/dist/extensions/question/index.ts +18 -0
- package/dist/extensions/question/question-list.ts +22 -0
- package/dist/extensions/question/tests/batch.test.ts +103 -65
- package/dist/extensions/question/tests/helpers.test.ts +68 -35
- package/dist/extensions/question/tests/question-list.test.ts +506 -204
- package/dist/extensions/question/tests/row-layout.test.ts +180 -114
- package/dist/extensions/question/tests/schemas.test.ts +42 -19
- package/dist/extensions/question/tests/shortcuts.test.ts +106 -84
- package/dist/extensions/question/tests/wizard.test.ts +771 -50
- package/dist/extensions/rtk.test.ts +180 -1
- package/dist/extensions/tokenin-onboarding.ts +3 -0
- package/dist/extensions/undo.test.ts +720 -0
- package/dist/extensions/undo.ts +6 -0
- package/dist/extensions/web-agent-onboarding.test.ts +415 -0
- package/dist/extensions/workflow/extension.ts +3 -3
- package/dist/extensions/workflow/modes.ts +41 -19
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.js +48 -1
- package/dist/skills/pi-subagents/references/execution-controls.md +1 -1
- package/docs/plans/workflow-autoloop-reference.md +1 -2
- package/docs/plans/workflow-handoff-carryover.md +108 -0
- package/docs/quickstart.md +27 -43
- package/docs/settings.md +4 -0
- package/docs/usage.md +1 -0
- package/package.json +5 -1
|
@@ -1,136 +1,202 @@
|
|
|
1
|
-
import
|
|
2
|
-
import assert from "node:assert/strict";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
3
2
|
|
|
4
3
|
import { wrapPlain, buildItemBlocks, flattenBlocks, renderSingleSelectRows } from "../row-layout.ts";
|
|
5
4
|
import type { ItemBlock, QuestionOption } from "../types.ts";
|
|
6
5
|
|
|
7
6
|
const opts = (labels: string[]): QuestionOption[] => labels.map((label) => ({ value: label, label }));
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
describe("row-layout", () => {
|
|
9
|
+
it("wrapPlain: empty → ['']", () => {
|
|
10
|
+
expect(wrapPlain("", 20)).toEqual([""]);
|
|
11
|
+
expect(wrapPlain(" ", 20)).toEqual([""]);
|
|
12
|
+
});
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
14
|
+
it("wrapPlain: single word fits", () => {
|
|
15
|
+
expect(wrapPlain("hello", 20)).toEqual(["hello"]);
|
|
16
|
+
});
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
});
|
|
18
|
+
it("wrapPlain: word longer than width → chunked", () => {
|
|
19
|
+
expect(wrapPlain("abcdefgh", 3)).toEqual(["abc", "def", "gh"]);
|
|
20
|
+
});
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
});
|
|
22
|
+
it("wrapPlain: multiple words wrapping", () => {
|
|
23
|
+
expect(wrapPlain("hello world foo", 7)).toEqual(["hello", "world", "foo"]);
|
|
24
|
+
expect(wrapPlain("hello world foo", 11)).toEqual(["hello world", "foo"]);
|
|
25
|
+
});
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
27
|
+
it("wrapPlain: width=1 → char-by-char", () => {
|
|
28
|
+
expect(wrapPlain("abc", 1)).toEqual(["a", "b", "c"]);
|
|
29
|
+
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
assert.equal(blocks[0]!.itemIndex, 0);
|
|
35
|
-
assert.ok(blocks[0]!.lines[0]!.startsWith("→"));
|
|
36
|
-
assert.ok(blocks[0]!.lines[0]!.includes("1. a"));
|
|
37
|
-
assert.ok(blocks[1]!.lines[0]!.startsWith(" "));
|
|
38
|
-
});
|
|
31
|
+
it("wrapPlain: long word mid-sentence chunks and continues", () => {
|
|
32
|
+
expect(wrapPlain("a verylongwordhere b", 5)).toEqual(["a", "veryl", "ongwo", "rdher", "e b"]);
|
|
33
|
+
});
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
it("buildItemBlocks: 3 options, selected=0 → arrow on block 0", () => {
|
|
36
|
+
const blocks = buildItemBlocks(opts(["a", "b", "c"]), 80, false, false, false, 0);
|
|
37
|
+
expect(blocks).toHaveLength(3);
|
|
38
|
+
expect(blocks[0]!.itemIndex).toBe(0);
|
|
39
|
+
expect(blocks[0]!.lines[0]!.startsWith("→")).toBe(true);
|
|
40
|
+
expect(blocks[0]!.lines[0]!).toContain("1. a");
|
|
41
|
+
expect(blocks[1]!.lines[0]!.startsWith(" ")).toBe(true);
|
|
42
|
+
});
|
|
45
43
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
false,
|
|
52
|
-
false,
|
|
53
|
-
0,
|
|
54
|
-
);
|
|
55
|
-
assert.ok(blocks[0]!.lines.length > 1);
|
|
56
|
-
assert.ok(blocks[0]!.lines.some((l) => l.includes("some desc")));
|
|
57
|
-
});
|
|
44
|
+
it("buildItemBlocks: selected=1 → arrow pointer on block 1", () => {
|
|
45
|
+
const blocks = buildItemBlocks(opts(["a", "b", "c"]), 80, false, false, false, 1);
|
|
46
|
+
expect(blocks[1]!.lines[0]!.startsWith("→")).toBe(true);
|
|
47
|
+
expect(blocks[0]!.lines[0]!.startsWith(" ")).toBe(true);
|
|
48
|
+
});
|
|
58
49
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
});
|
|
50
|
+
it("buildItemBlocks: with description → description lines included", () => {
|
|
51
|
+
const blocks = buildItemBlocks(
|
|
52
|
+
[{ value: "a", label: "a", description: "some desc" }],
|
|
53
|
+
80,
|
|
54
|
+
false,
|
|
55
|
+
false,
|
|
56
|
+
false,
|
|
57
|
+
0,
|
|
58
|
+
);
|
|
59
|
+
expect(blocks[0]!.lines.length).toBeGreaterThan(1);
|
|
60
|
+
expect(blocks[0]!.lines.some((l) => l.includes("some desc"))).toBe(true);
|
|
61
|
+
});
|
|
72
62
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
it("buildItemBlocks: hideDescriptions=true → no description lines", () => {
|
|
64
|
+
const blocks = buildItemBlocks(
|
|
65
|
+
[{ value: "a", label: "a", description: "some desc" }],
|
|
66
|
+
80,
|
|
67
|
+
false,
|
|
68
|
+
false,
|
|
69
|
+
false,
|
|
70
|
+
0,
|
|
71
|
+
true,
|
|
72
|
+
);
|
|
73
|
+
// Only the title line, no description
|
|
74
|
+
expect(blocks[0]!.lines).toHaveLength(1);
|
|
75
|
+
});
|
|
78
76
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
});
|
|
77
|
+
it("buildItemBlocks: allowFreeform → freeform block appended", () => {
|
|
78
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, true, false, false, 0);
|
|
79
|
+
expect(blocks).toHaveLength(2);
|
|
80
|
+
expect(blocks[1]!.lines[0]!).toContain("Type custom answer");
|
|
81
|
+
});
|
|
85
82
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
it("buildItemBlocks: allowComment → comment-toggle block appended", () => {
|
|
84
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, false, true, false, 0);
|
|
85
|
+
expect(blocks).toHaveLength(2);
|
|
86
|
+
expect(blocks[1]!.lines[0]!).toContain("[ ]");
|
|
87
|
+
expect(blocks[1]!.lines[0]!).toContain("Add extra context");
|
|
88
|
+
});
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
];
|
|
96
|
-
const rows = flattenBlocks(blocks, 1);
|
|
97
|
-
assert.equal(rows.length, 3);
|
|
98
|
-
assert.equal(rows[0]!.selected, false);
|
|
99
|
-
assert.equal(rows[1]!.selected, false);
|
|
100
|
-
assert.equal(rows[2]!.selected, true);
|
|
101
|
-
});
|
|
90
|
+
it("buildItemBlocks: allowComment + commentEnabled → [✓]", () => {
|
|
91
|
+
const blocks = buildItemBlocks(opts(["a"]), 80, false, true, true, 0);
|
|
92
|
+
expect(blocks[1]!.lines[0]!).toContain("[✓]");
|
|
93
|
+
});
|
|
102
94
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
selectedIndex: 0,
|
|
107
|
-
width: 80,
|
|
108
|
-
allowFreeform: false,
|
|
95
|
+
it("buildItemBlocks: narrow width wraps labels", () => {
|
|
96
|
+
const blocks = buildItemBlocks(opts(["a very long label"]), 12, false, false, false, 0);
|
|
97
|
+
expect(blocks[0]!.lines.length).toBeGreaterThan(1);
|
|
109
98
|
});
|
|
110
|
-
assert.equal(rows.length, 2);
|
|
111
|
-
});
|
|
112
99
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
100
|
+
it("flattenBlocks: correct selected flags", () => {
|
|
101
|
+
const blocks: ItemBlock[] = [
|
|
102
|
+
{ itemIndex: 0, lines: ["a", "b"] },
|
|
103
|
+
{ itemIndex: 1, lines: ["c"] },
|
|
104
|
+
];
|
|
105
|
+
const rows = flattenBlocks(blocks, 1);
|
|
106
|
+
expect(rows).toHaveLength(3);
|
|
107
|
+
expect(rows[0]!.selected).toBe(false);
|
|
108
|
+
expect(rows[1]!.selected).toBe(false);
|
|
109
|
+
expect(rows[2]!.selected).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it("renderSingleSelectRows: few rows, all visible", () => {
|
|
113
|
+
const rows = renderSingleSelectRows({
|
|
114
|
+
options: opts(["a", "b"]),
|
|
115
|
+
selectedIndex: 0,
|
|
116
|
+
width: 80,
|
|
117
|
+
allowFreeform: false,
|
|
118
|
+
});
|
|
119
|
+
expect(rows).toHaveLength(2);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("renderSingleSelectRows: maxRows truncation with indicator", () => {
|
|
123
|
+
const rows = renderSingleSelectRows({
|
|
124
|
+
options: opts(["a", "b", "c", "c", "e", "f", "g", "h"]),
|
|
125
|
+
selectedIndex: 0,
|
|
126
|
+
width: 80,
|
|
127
|
+
allowFreeform: false,
|
|
128
|
+
maxRows: 3,
|
|
129
|
+
});
|
|
130
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
131
|
+
// Last row should be the indicator
|
|
132
|
+
expect(rows[rows.length - 1]!.line).toContain("(");
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("renderSingleSelectRows: selected block larger than available → only selected + indicator", () => {
|
|
136
|
+
const rows = renderSingleSelectRows({
|
|
137
|
+
options: [{ value: "a", label: "a".repeat(100) }],
|
|
138
|
+
selectedIndex: 0,
|
|
139
|
+
width: 10,
|
|
140
|
+
allowFreeform: false,
|
|
141
|
+
maxRows: 3,
|
|
142
|
+
});
|
|
143
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
144
|
+
expect(rows.every((r) => r.selected || r.line.includes("("))).toBe(true);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it("renderSingleSelectRows: maxRows=1 shows only the selected line", () => {
|
|
148
|
+
const rows = renderSingleSelectRows({
|
|
149
|
+
options: opts(["a", "b"]),
|
|
150
|
+
selectedIndex: 0,
|
|
151
|
+
width: 80,
|
|
152
|
+
allowFreeform: false,
|
|
153
|
+
maxRows: 1,
|
|
154
|
+
});
|
|
155
|
+
expect(rows.length).toBeLessThanOrEqual(1);
|
|
156
|
+
});
|
|
125
157
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
158
|
+
it("renderSingleSelectRows: empty options with freeform still renders", () => {
|
|
159
|
+
const rows = renderSingleSelectRows({
|
|
160
|
+
options: [],
|
|
161
|
+
selectedIndex: 0,
|
|
162
|
+
width: 80,
|
|
163
|
+
allowFreeform: true,
|
|
164
|
+
maxRows: 5,
|
|
165
|
+
});
|
|
166
|
+
expect(rows.length).toBeGreaterThan(0);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it("renderSingleSelectRows: empty options without freeform returns empty", () => {
|
|
170
|
+
const rows = renderSingleSelectRows({
|
|
171
|
+
options: [],
|
|
172
|
+
selectedIndex: 0,
|
|
173
|
+
width: 80,
|
|
174
|
+
allowFreeform: false,
|
|
175
|
+
maxRows: 5,
|
|
176
|
+
});
|
|
177
|
+
expect(rows).toEqual([]);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
it("renderSingleSelectRows: previous block fits when next does not", () => {
|
|
181
|
+
// Selected block is small; the next block is too large but the previous fits.
|
|
182
|
+
const rows = renderSingleSelectRows({
|
|
183
|
+
options: [
|
|
184
|
+
{ value: "a", label: "A" },
|
|
185
|
+
{ value: "b", label: "B" },
|
|
186
|
+
{ value: "c", label: "C".repeat(100) },
|
|
187
|
+
],
|
|
188
|
+
selectedIndex: 1,
|
|
189
|
+
width: 10,
|
|
190
|
+
allowFreeform: false,
|
|
191
|
+
maxRows: 3,
|
|
192
|
+
});
|
|
193
|
+
expect(rows.length).toBeLessThanOrEqual(3);
|
|
194
|
+
expect(rows.some((r) => r.line.includes("A"))).toBe(true);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("buildItemBlocks: wrapped freeform label uses continuation prefix", () => {
|
|
198
|
+
const blocks = buildItemBlocks(opts(["a"]), 12, true, false, false, 1);
|
|
199
|
+
expect(blocks[1]!.lines.length).toBeGreaterThan(1);
|
|
200
|
+
expect(blocks[1]!.lines[1]!.startsWith(" ")).toBe(true);
|
|
201
|
+
});
|
|
202
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import assert from "node:assert/strict";
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
3
2
|
|
|
4
3
|
import { Value } from "typebox/value";
|
|
5
4
|
|
|
@@ -9,22 +8,46 @@ const valid = {
|
|
|
9
8
|
questions: [{ type: "select", question: "Pick", options: [{ value: "yes", label: "Yes" }] }],
|
|
10
9
|
};
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
describe("QuestionParamsSchema", () => {
|
|
12
|
+
it("accepts typed batch requests", () => {
|
|
13
|
+
expect(Value.Check(QuestionParamsSchema, valid)).toBe(true);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("accepts multiselect, text, ids, labels, context, allowOther, descriptions", () => {
|
|
17
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
18
|
+
questions: [
|
|
19
|
+
{ type: "multiselect", id: "m", label: "M", question: "Pick many", context: "ctx", options: [{ value: "a", label: "A", description: "d" }], allowOther: true },
|
|
20
|
+
{ type: "text", question: "Explain" },
|
|
21
|
+
],
|
|
22
|
+
})).toBe(true);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("rejects legacy and mistyped fields", () => {
|
|
26
|
+
expect(Value.Check(QuestionParamsSchema, { ...valid, timeout: 1000 })).toBe(false);
|
|
27
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
28
|
+
questions: [{ ...valid.questions[0], allowMultiple: true }],
|
|
29
|
+
})).toBe(false);
|
|
30
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
31
|
+
questions: [{ ...valid.questions[0], allowComment: true }],
|
|
32
|
+
})).toBe(false);
|
|
33
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
34
|
+
questions: [{ type: "text", question: "Explain", options: [] }],
|
|
35
|
+
})).toBe(false);
|
|
36
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
37
|
+
questions: [{ ...valid.questions[0], options: [{ value: "yes", label: "Yes", extra: true }] }],
|
|
38
|
+
})).toBe(false);
|
|
39
|
+
});
|
|
15
40
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
questions: [{ ...valid.questions[0], options: [{ value: "yes", label: "Yes", extra: true }] }],
|
|
29
|
-
}), false);
|
|
41
|
+
it("rejects empty questions and bad option shapes", () => {
|
|
42
|
+
expect(Value.Check(QuestionParamsSchema, { questions: [] })).toBe(false);
|
|
43
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
44
|
+
questions: [{ type: "select", question: "Pick", options: [] }],
|
|
45
|
+
})).toBe(false);
|
|
46
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
47
|
+
questions: [{ type: "select", question: "Pick", options: [{ value: "yes" }] }],
|
|
48
|
+
})).toBe(false);
|
|
49
|
+
expect(Value.Check(QuestionParamsSchema, {
|
|
50
|
+
questions: [{ type: "select", question: "Pick", options: [{ label: "Yes" }] }],
|
|
51
|
+
})).toBe(false);
|
|
52
|
+
});
|
|
30
53
|
});
|
|
@@ -1,85 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import { normalizeShortcutSpec, isValidShortcutSpec, resolveShortcut, resolveShortcuts, buildShortcut } from "../shortcuts.ts";
|
|
4
|
+
import { DISABLED_SHORTCUT, DEFAULT_COMMENT_TOGGLE_KEY } from "../constants.ts";
|
|
5
|
+
|
|
6
|
+
describe("shortcut resolution", () => {
|
|
7
|
+
it("normalizeShortcutSpec: undefined → undefined", () => {
|
|
8
|
+
expect(normalizeShortcutSpec(undefined)).toBeUndefined();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("normalizeShortcutSpec: null → null", () => {
|
|
12
|
+
expect(normalizeShortcutSpec(null)).toBeNull();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("normalizeShortcutSpec: disable values → null", () => {
|
|
16
|
+
expect(normalizeShortcutSpec("off")).toBeNull();
|
|
17
|
+
expect(normalizeShortcutSpec("none")).toBeNull();
|
|
18
|
+
expect(normalizeShortcutSpec("disabled")).toBeNull();
|
|
19
|
+
expect(normalizeShortcutSpec("")).toBeNull();
|
|
20
|
+
expect(normalizeShortcutSpec(" off ")).toBeNull();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("normalizeShortcutSpec: normalizes case and trims", () => {
|
|
24
|
+
expect(normalizeShortcutSpec("Alt+O")).toBe("alt+o");
|
|
25
|
+
expect(normalizeShortcutSpec(" Ctrl+G ")).toBe("ctrl+g");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("isValidShortcutSpec: empty → false", () => {
|
|
29
|
+
expect(isValidShortcutSpec("")).toBe(false);
|
|
30
|
+
expect(isValidShortcutSpec(" ")).toBe(false);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("isValidShortcutSpec: valid specs", () => {
|
|
34
|
+
expect(isValidShortcutSpec("alt+o")).toBe(true);
|
|
35
|
+
expect(isValidShortcutSpec("ctrl+g")).toBe(true);
|
|
36
|
+
expect(isValidShortcutSpec("shift+f1")).toBe(true);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("isValidShortcutSpec: leading/trailing + → false", () => {
|
|
40
|
+
expect(isValidShortcutSpec("+o")).toBe(false);
|
|
41
|
+
expect(isValidShortcutSpec("o+")).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("isValidShortcutSpec: double + → false", () => {
|
|
45
|
+
expect(isValidShortcutSpec("alt++o")).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("isValidShortcutSpec: illegal characters → false", () => {
|
|
49
|
+
expect(isValidShortcutSpec("alt o")).toBe(false);
|
|
50
|
+
expect(isValidShortcutSpec("alt\n")).toBe(false);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("buildShortcut returns a matching shortcut", () => {
|
|
54
|
+
const shortcut = buildShortcut("ctrl+g");
|
|
55
|
+
expect(shortcut.disabled).toBe(false);
|
|
56
|
+
expect(shortcut.spec).toBe("ctrl+g");
|
|
57
|
+
expect(shortcut.matches("\x07")).toBe(true);
|
|
58
|
+
expect(shortcut.matches("x")).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("resolveShortcut: uses param when valid", () => {
|
|
62
|
+
const result = resolveShortcut("alt+o", undefined, "alt+o");
|
|
63
|
+
expect(result.disabled).toBe(false);
|
|
64
|
+
expect(result.spec).toBe("alt+o");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("resolveShortcut: param undefined, uses env", () => {
|
|
68
|
+
const result = resolveShortcut(undefined, "ctrl+x", "alt+o");
|
|
69
|
+
expect(result.disabled).toBe(false);
|
|
70
|
+
expect(result.spec).toBe("ctrl+x");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("resolveShortcut: param null → disabled", () => {
|
|
74
|
+
expect(resolveShortcut(null, "ctrl+x", "alt+o")).toBe(DISABLED_SHORTCUT);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("resolveShortcut: param undefined, env undefined, uses default", () => {
|
|
78
|
+
const result = resolveShortcut(undefined, undefined, "alt+o");
|
|
79
|
+
expect(result.disabled).toBe(false);
|
|
80
|
+
expect(result.spec).toBe("alt+o");
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("resolveShortcut: param 'off' → disabled", () => {
|
|
84
|
+
expect(resolveShortcut("off", "ctrl+x", "alt+o")).toBe(DISABLED_SHORTCUT);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("resolveShortcut: invalid param falls through to env", () => {
|
|
88
|
+
const result = resolveShortcut("invalid++", "ctrl+x", "alt+o");
|
|
89
|
+
expect(result.disabled).toBe(false);
|
|
90
|
+
expect(result.spec).toBe("ctrl+x");
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("resolveShortcut: all invalid → disabled", () => {
|
|
94
|
+
expect(resolveShortcut("invalid++", "also++", "default++")).toBe(DISABLED_SHORTCUT);
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("resolveShortcuts builds the commentToggle map with the default key", () => {
|
|
98
|
+
const shortcuts = resolveShortcuts(undefined, undefined);
|
|
99
|
+
expect(shortcuts.commentToggle.disabled).toBe(false);
|
|
100
|
+
expect(shortcuts.commentToggle.spec).toBe(DEFAULT_COMMENT_TOGGLE_KEY);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("DISABLED_SHORTCUT matches nothing", () => {
|
|
104
|
+
expect(DISABLED_SHORTCUT.matches("anything")).toBe(false);
|
|
105
|
+
expect(DISABLED_SHORTCUT.disabled).toBe(true);
|
|
106
|
+
});
|
|
26
107
|
});
|
|
27
|
-
|
|
28
|
-
test("isValidShortcutSpec: empty → false", () => {
|
|
29
|
-
assert.equal(isValidShortcutSpec(""), false);
|
|
30
|
-
assert.equal(isValidShortcutSpec(" "), false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test("isValidShortcutSpec: valid specs", () => {
|
|
34
|
-
assert.equal(isValidShortcutSpec("alt+o"), true);
|
|
35
|
-
assert.equal(isValidShortcutSpec("ctrl+g"), true);
|
|
36
|
-
assert.equal(isValidShortcutSpec("shift+f1"), true);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
test("isValidShortcutSpec: leading/trailing + → false", () => {
|
|
40
|
-
assert.equal(isValidShortcutSpec("+o"), false);
|
|
41
|
-
assert.equal(isValidShortcutSpec("o+"), false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test("isValidShortcutSpec: double + → false", () => {
|
|
45
|
-
assert.equal(isValidShortcutSpec("alt++o"), false);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("resolveShortcut: uses param when valid", () => {
|
|
49
|
-
const result = resolveShortcut("alt+o", undefined, "alt+o");
|
|
50
|
-
assert.equal(result.disabled, false);
|
|
51
|
-
assert.equal(result.spec, "alt+o");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
test("resolveShortcut: param undefined, uses env", () => {
|
|
55
|
-
const result = resolveShortcut(undefined, "ctrl+x", "alt+o");
|
|
56
|
-
assert.equal(result.disabled, false);
|
|
57
|
-
assert.equal(result.spec, "ctrl+x");
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test("resolveShortcut: param null → disabled", () => {
|
|
61
|
-
const result = resolveShortcut(null, "ctrl+x", "alt+o");
|
|
62
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
test("resolveShortcut: param undefined, env undefined, uses default", () => {
|
|
66
|
-
const result = resolveShortcut(undefined, undefined, "alt+o");
|
|
67
|
-
assert.equal(result.disabled, false);
|
|
68
|
-
assert.equal(result.spec, "alt+o");
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
test("resolveShortcut: param 'off' → disabled", () => {
|
|
72
|
-
const result = resolveShortcut("off", "ctrl+x", "alt+o");
|
|
73
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test("resolveShortcut: invalid param falls through to env", () => {
|
|
77
|
-
const result = resolveShortcut("invalid++", "ctrl+x", "alt+o");
|
|
78
|
-
assert.equal(result.disabled, false);
|
|
79
|
-
assert.equal(result.spec, "ctrl+x");
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("resolveShortcut: all invalid → disabled", () => {
|
|
83
|
-
const result = resolveShortcut("invalid++", "also++", "default++");
|
|
84
|
-
assert.equal(result, DISABLED_SHORTCUT);
|
|
85
|
-
});
|