vc-extras 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/README.md +128 -71
- package/agent-install.mjs +159 -0
- package/agents/tester.md +23 -23
- package/install-extras.mjs +41 -109
- package/install-menu.mjs +22 -43
- package/install-skills.mjs +112 -112
- package/package.json +72 -28
- package/plugin-registry.mjs +73 -0
- package/plugins/config-ui/index.ts +159 -159
- package/plugins/config-ui/lib/arguments.mjs +24 -24
- package/plugins/config-ui/lib/documents.mjs +67 -67
- package/plugins/config-ui/lib/frontmatter.mjs +91 -91
- package/plugins/config-ui/lib/open.mjs +16 -16
- package/plugins/config-ui/lib/ownership.mjs +99 -99
- package/plugins/config-ui/lib/page.mjs +11 -11
- package/plugins/config-ui/lib/patch.mjs +35 -35
- package/plugins/config-ui/lib/paths.mjs +14 -14
- package/plugins/config-ui/lib/plugin-fields.mjs +86 -86
- package/plugins/config-ui/lib/plugin-validation.mjs +28 -28
- package/plugins/config-ui/lib/redaction.mjs +8 -8
- package/plugins/config-ui/lib/registry.mjs +282 -282
- package/plugins/config-ui/lib/secrets.mjs +44 -44
- package/plugins/config-ui/lib/server.mjs +250 -250
- package/plugins/config-ui/lib/sources.mjs +96 -96
- package/plugins/config-ui/lib/state.mjs +156 -156
- package/plugins/config-ui/lib/themes.mjs +113 -113
- package/plugins/config-ui/lib/writer.mjs +690 -690
- package/plugins/config-ui/project-local-owner.ts +106 -106
- package/plugins/config-ui/vc-extras.plugin.json +13 -0
- package/plugins/config-ui/web/app.mjs +997 -997
- package/plugins/config-ui/web/index.html +342 -342
- package/plugins/pi-blackhole/vc-extras.plugin.json +12 -0
- package/plugins/pi-btw/vc-extras.plugin.json +12 -0
- package/plugins/pi-claude-code/vc-extras.plugin.json +12 -0
- package/plugins/pi-fff/vc-extras.plugin.json +12 -0
- package/plugins/pi-jev-auto-mode/vc-extras.plugin.json +12 -0
- package/plugins/pi-mcp-adapter/vc-extras.plugin.json +12 -0
- package/plugins/pi-web-access/vc-extras.plugin.json +12 -0
- package/plugins/vc-ask/claude-hook.mjs +37 -0
- package/plugins/vc-ask/codex-native.mjs +28 -0
- package/plugins/vc-ask/host-channel.mjs +75 -0
- package/plugins/vc-ask/index.ts +57 -0
- package/plugins/vc-ask/native-questions.mjs +33 -0
- package/plugins/vc-ask/package.json +10 -0
- package/plugins/vc-ask/payload.ts +170 -0
- package/plugins/vc-ask/questionnaire/LICENSE.ask-user-question +21 -0
- package/plugins/vc-ask/questionnaire/UPSTREAM.md +104 -0
- package/plugins/vc-ask/questionnaire/answer-channel.ts +135 -0
- package/plugins/vc-ask/questionnaire/config.ts +180 -0
- package/plugins/vc-ask/questionnaire/events.ts +154 -0
- package/plugins/vc-ask/questionnaire/execute.ts +688 -0
- package/plugins/vc-ask/questionnaire/i18n.ts +73 -0
- package/plugins/vc-ask/questionnaire/inline-entry.ts +312 -0
- package/plugins/vc-ask/questionnaire/locales/de.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/en.json +42 -0
- package/plugins/vc-ask/questionnaire/locales/es.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/fr.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt-BR.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/pt.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/ru.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/uk.json +43 -0
- package/plugins/vc-ask/questionnaire/locales/zh.json +46 -0
- package/plugins/vc-ask/questionnaire/presentation.ts +11 -0
- package/plugins/vc-ask/questionnaire/question-preview.ts +6 -0
- package/plugins/vc-ask/questionnaire/rpc.ts +221 -0
- package/plugins/vc-ask/questionnaire/session-timeout.ts +67 -0
- package/plugins/vc-ask/questionnaire/state/build-questionnaire.ts +144 -0
- package/plugins/vc-ask/questionnaire/state/external-editor.ts +62 -0
- package/plugins/vc-ask/questionnaire/state/geometry.ts +131 -0
- package/plugins/vc-ask/questionnaire/state/key-router.ts +382 -0
- package/plugins/vc-ask/questionnaire/state/panel-router.ts +32 -0
- package/plugins/vc-ask/questionnaire/state/questionnaire-session.ts +642 -0
- package/plugins/vc-ask/questionnaire/state/row-intent.ts +143 -0
- package/plugins/vc-ask/questionnaire/state/selectors/contract.ts +24 -0
- package/plugins/vc-ask/questionnaire/state/selectors/derivations.ts +40 -0
- package/plugins/vc-ask/questionnaire/state/selectors/focus.ts +17 -0
- package/plugins/vc-ask/questionnaire/state/selectors/projections.ts +99 -0
- package/plugins/vc-ask/questionnaire/state/state-reducer.ts +455 -0
- package/plugins/vc-ask/questionnaire/state/state.ts +90 -0
- package/plugins/vc-ask/questionnaire/state/vertical.ts +158 -0
- package/plugins/vc-ask/questionnaire/timeout.ts +59 -0
- package/plugins/vc-ask/questionnaire/tool/external-answer.ts +103 -0
- package/plugins/vc-ask/questionnaire/tool/format-answer.ts +24 -0
- package/plugins/vc-ask/questionnaire/tool/normalize-params.ts +37 -0
- package/plugins/vc-ask/questionnaire/tool/response-envelope.ts +75 -0
- package/plugins/vc-ask/questionnaire/tool/types.ts +74 -0
- package/plugins/vc-ask/questionnaire/tool/validate-questionnaire.ts +75 -0
- package/plugins/vc-ask/questionnaire/view/card-theme.ts +245 -0
- package/plugins/vc-ask/questionnaire/view/components/inline-input.ts +66 -0
- package/plugins/vc-ask/questionnaire/view/components/multi-select-view.ts +177 -0
- package/plugins/vc-ask/questionnaire/view/components/option-list-view.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/markdown-content-cache.ts +101 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-block-renderer.ts +130 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-box-renderer.ts +86 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-layout-decider.ts +204 -0
- package/plugins/vc-ask/questionnaire/view/components/preview/preview-pane.ts +257 -0
- package/plugins/vc-ask/questionnaire/view/components/submit-picker.ts +65 -0
- package/plugins/vc-ask/questionnaire/view/components/tab-bar.ts +57 -0
- package/plugins/vc-ask/questionnaire/view/components/wrapping-select.ts +269 -0
- package/plugins/vc-ask/questionnaire/view/dialog-builder.ts +319 -0
- package/plugins/vc-ask/questionnaire/view/document-theme.ts +53 -0
- package/plugins/vc-ask/questionnaire/view/document-view.ts +306 -0
- package/plugins/vc-ask/questionnaire/view/panel-chrome.ts +133 -0
- package/plugins/vc-ask/questionnaire/view/props-adapter.ts +77 -0
- package/plugins/vc-ask/questionnaire/view/stateful-view.ts +24 -0
- package/plugins/vc-ask/questionnaire/view/tab-components.ts +16 -0
- package/plugins/vc-ask/questionnaire/view/tab-content-strategy.ts +280 -0
- package/plugins/vc-ask/questionnaire/view/vertical-view.ts +218 -0
- package/plugins/vc-ask/user-input-events.ts +34 -0
- package/plugins/vc-ask/vc-extras.plugin.json +18 -0
- package/plugins/vc-footer/agents/claude-code/adapter.mjs +29 -0
- package/plugins/vc-footer/agents/claude-code/cli.mjs +23 -0
- package/plugins/vc-footer/agents/claude-code/renderer.mjs +1 -0
- package/plugins/vc-footer/agents/claude-code/types.d.ts +38 -0
- package/plugins/vc-footer/agents/codex/adapter.mjs +13 -0
- package/plugins/vc-footer/agents/codex/mcp.mjs +45 -0
- package/plugins/vc-footer/agents/codex/native.mjs +19 -0
- package/plugins/vc-footer/agents/codex/renderer.mjs +2 -0
- package/plugins/vc-footer/agents/pi/adapter.mjs +23 -0
- package/plugins/vc-footer/agents/pi/index.js +84 -0
- package/plugins/vc-footer/agents/pi/project-local-owner.mjs +97 -0
- package/plugins/vc-footer/agents/pi/renderer.mjs +5 -0
- package/plugins/vc-footer/core/data.mjs +218 -0
- package/plugins/vc-footer/core/render.mjs +291 -0
- package/plugins/vc-footer/core/types.d.ts +29 -0
- package/plugins/vc-footer/package.json +22 -0
- package/plugins/vc-footer/vc-extras.plugin.json +32 -0
- package/skills/animate/LICENSE +21 -21
- package/skills/animate/RECIPES.md +324 -324
- package/skills/animate/SKILL.md +208 -208
- package/skills/animate/UPSTREAM.md +19 -19
- package/skills/animation-performance/LICENSE +21 -21
- package/skills/animation-performance/SKILL.md +223 -223
- package/skills/animation-performance/UPSTREAM.md +19 -19
- package/skills/answer-me-with-html/SKILL.md +174 -174
- package/skills/answer-me-with-html/scripts/am.mjs +12896 -12896
- package/skills/apple-design/LICENSE +21 -21
- package/skills/apple-design/SKILL.md +291 -291
- package/skills/apple-design/UPSTREAM.md +19 -19
- package/skills/bad-smell/SKILL.md +44 -44
- package/skills/commit/SKILL.md +90 -90
- package/skills/emil-design-eng/LICENSE +21 -21
- package/skills/emil-design-eng/SKILL.md +677 -677
- package/skills/emil-design-eng/UPSTREAM.md +19 -19
- package/skills/find-the-truth/SKILL.md +38 -38
- package/skills/find-the-truth/references/trace-method.md +48 -48
- package/skills/find-the-truth/references/truth-method.md +39 -39
- package/skills/gestures/LICENSE +21 -21
- package/skills/gestures/SKILL.md +107 -107
- package/skills/gestures/UPSTREAM.md +19 -19
- package/skills/humanizer-zh/LICENSE +21 -21
- package/skills/humanizer-zh/SKILL.md +409 -409
- package/skills/humanizer-zh/UPSTREAM.md +7 -7
- package/skills/impeccable/LICENSE +191 -191
- package/skills/impeccable/NOTICE.md +11 -11
- package/skills/impeccable/SKILL.md +89 -89
- package/skills/impeccable/licenses/modern-screenshot-MIT.txt +8 -8
- package/skills/impeccable/licenses/platform-design-skills-MIT.txt +21 -21
- package/skills/impeccable/reference/adapt.md +318 -318
- package/skills/impeccable/reference/adapt.native.md +58 -58
- package/skills/impeccable/reference/android.md +46 -46
- package/skills/impeccable/reference/animate.md +89 -89
- package/skills/impeccable/reference/audit.md +139 -139
- package/skills/impeccable/reference/audit.native.md +139 -139
- package/skills/impeccable/reference/bolder.md +33 -33
- package/skills/impeccable/reference/clarify.md +94 -94
- package/skills/impeccable/reference/colorize.md +86 -86
- package/skills/impeccable/reference/component-review.md +63 -63
- package/skills/impeccable/reference/craft-floor.md +44 -44
- package/skills/impeccable/reference/craft.md +5 -5
- package/skills/impeccable/reference/critique.md +819 -819
- package/skills/impeccable/reference/degraded/asset-producer.md +41 -41
- package/skills/impeccable/reference/degraded/documenter.md +23 -23
- package/skills/impeccable/reference/degraded/finish-reviewer.md +37 -37
- package/skills/impeccable/reference/degraded/manual-edit-applier.md +92 -92
- package/skills/impeccable/reference/delight.md +70 -70
- package/skills/impeccable/reference/distill.md +111 -111
- package/skills/impeccable/reference/doctor.md +54 -54
- package/skills/impeccable/reference/document.md +416 -416
- package/skills/impeccable/reference/extract.md +69 -69
- package/skills/impeccable/reference/generate.md +101 -101
- package/skills/impeccable/reference/harden.md +362 -362
- package/skills/impeccable/reference/hooks.md +114 -114
- package/skills/impeccable/reference/init.md +131 -131
- package/skills/impeccable/reference/ios.md +51 -51
- package/skills/impeccable/reference/layout.md +84 -84
- package/skills/impeccable/reference/live-setup.md +104 -104
- package/skills/impeccable/reference/live.md +327 -327
- package/skills/impeccable/reference/mode-operate.md +21 -21
- package/skills/impeccable/reference/mode-persuade.md +19 -19
- package/skills/impeccable/reference/mode-read.md +21 -21
- package/skills/impeccable/reference/new-work.md +152 -152
- package/skills/impeccable/reference/onboard.md +234 -234
- package/skills/impeccable/reference/operate.md +61 -61
- package/skills/impeccable/reference/optimize.md +257 -257
- package/skills/impeccable/reference/overdrive.md +127 -127
- package/skills/impeccable/reference/polish.md +105 -105
- package/skills/impeccable/reference/quieter.md +99 -99
- package/skills/impeccable/reference/region-map.md +26 -26
- package/skills/impeccable/reference/routing.md +24 -24
- package/skills/impeccable/reference/shape.md +59 -59
- package/skills/impeccable/reference/typeset.md +90 -90
- package/skills/impeccable/reference/visualize.md +47 -47
- package/skills/impeccable/scripts/VERSION +1 -1
- package/skills/impeccable/scripts/command-metadata.json +98 -98
- package/skills/impeccable/scripts/data/font-index-failures.json +120 -120
- package/skills/impeccable/scripts/engine-checksums.txt +9 -9
- package/skills/impeccable/scripts/impeccable +249 -249
- package/skills/impeccable/scripts/impeccable.cmd +278 -278
- package/skills/impeccable/scripts/live-browser-dom.js +320 -320
- package/skills/impeccable/scripts/live-browser-ignores.js +246 -246
- package/skills/impeccable/scripts/live-browser-session.js +183 -183
- package/skills/impeccable/scripts/live-browser.js +13862 -13862
- package/skills/impeccable/scripts/modern-screenshot.umd.js +14 -14
- package/skills/improve-animations/AUDIT.md +115 -115
- package/skills/improve-animations/LICENSE +21 -21
- package/skills/improve-animations/PLAN-TEMPLATE.md +73 -73
- package/skills/improve-animations/SKILL.md +110 -110
- package/skills/improve-animations/UPSTREAM.md +19 -19
- package/skills/pick-ui-library/LICENSE +21 -21
- package/skills/pick-ui-library/SKILL.md +85 -85
- package/skills/pick-ui-library/UPSTREAM.md +19 -19
- package/skills/review-animations/LICENSE +21 -21
- package/skills/review-animations/SKILL.md +120 -120
- package/skills/review-animations/STANDARDS.md +187 -187
- package/skills/review-animations/UPSTREAM.md +19 -19
- package/skills/test/SKILL.md +29 -29
- package/skills/test/references/test-method.md +60 -60
- package/skills/write-doc/SKILL.md +115 -115
- package/skills/write-doc/examples/result-report.md +53 -53
- package/skills/write-doc/examples/task-summary.md +45 -45
- package/skills/write-doc/references/terminology.md +147 -147
- package/specs/ask-host-protocol-v1.md +58 -0
- package/specs/design-demo.md +1102 -1102
- package/specs/frontend-immersive.md +28 -28
- package/specs/plugin-install-v2.md +123 -0
- package/specs/plugin-install.md +38 -0
- package/specs/web-modes/explore.md +31 -31
- package/specs/web-modes/risk.md +15 -15
- package/specs/web-modes/verify.md +16 -16
- package/vc-extras.mjs +46 -62
- package/plugins/essrj/context.ts +0 -47
- package/plugins/essrj/data.ts +0 -190
- package/plugins/essrj/index.ts +0 -139
- package/plugins/essrj/package.json +0 -12
- package/plugins/essrj/project-local-owner.ts +0 -106
- package/plugins/essrj/render.ts +0 -217
- package/plugins/essrj/types.ts +0 -40
- package/plugins.json +0 -38
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sentinel.other": "Введите что-нибудь.",
|
|
3
|
+
"sentinel.next": "Далее",
|
|
4
|
+
"submit.label": "Отправить ответы",
|
|
5
|
+
"submit.cancel": "Отмена",
|
|
6
|
+
"hint.enter": "↵ выбрать",
|
|
7
|
+
"hint.navigate": "↑↓ навигация",
|
|
8
|
+
"hint.newline": "⇧↵ новая строка",
|
|
9
|
+
"hint.clear": "⌃u очистить",
|
|
10
|
+
"hint.toggle": " переключить",
|
|
11
|
+
"hint.notes": "n заметки",
|
|
12
|
+
"hint.tab": "⇥ вопросы",
|
|
13
|
+
"hint.collapse": "⌃] свернуть",
|
|
14
|
+
"hint.expand_line": "⌃] развернуть · esc отмена",
|
|
15
|
+
"hint.cancel": "esc отмена",
|
|
16
|
+
"review.heading": "Проверьте свои ответы",
|
|
17
|
+
"review.ready": "Готовы отправить ответы?",
|
|
18
|
+
"review.incomplete": "⚠ Ответьте на оставшиеся вопросы перед отправкой:",
|
|
19
|
+
"preview.no_preview": "Предпросмотр недоступен",
|
|
20
|
+
"preview.notes_affordance": "Заметки: нажмите n, чтобы добавить заметки",
|
|
21
|
+
"notes.header": "Заметки:",
|
|
22
|
+
"editor.failed": "Ошибка внешнего редактора",
|
|
23
|
+
"entry.answered": "получен ответ",
|
|
24
|
+
"entry.cancelled": "отменено",
|
|
25
|
+
"entry.question_cancelled": "Вопрос отменён",
|
|
26
|
+
"rpc.multi_instructions": "Введите номера всех подходящих вариантов через запятую (например, \"1,3\") или введите свой ответ текстом.",
|
|
27
|
+
"rpc.custom_answer_title": "Введите свой ответ:",
|
|
28
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n, Ctrl+G, Ctrl+U) are universal CLI conventions and stay untranslated.",
|
|
29
|
+
"gate.title": "Emma · Дальше",
|
|
30
|
+
"gate.question": "Выберите следующий шаг.",
|
|
31
|
+
"preview.label": "Сводка Emma:",
|
|
32
|
+
"preview.label.shape": "План Emma:",
|
|
33
|
+
"preview.label.build": "Отчёт Emma:",
|
|
34
|
+
"preview.label.hunt": "Выводы Emma:",
|
|
35
|
+
"vertical.too_small": "Увеличьте: 40x20",
|
|
36
|
+
"vertical.too_small_hint": "Esc / Ctrl+C: отмена",
|
|
37
|
+
"vertical.input_label": "Ввод:",
|
|
38
|
+
"vertical.recommended": "Рекомендуется",
|
|
39
|
+
"vertical.unanswered": "без ответа",
|
|
40
|
+
"vertical.global_note": "Общая заметка",
|
|
41
|
+
"vertical.note_empty": "(нажмите n, чтобы добавить)",
|
|
42
|
+
"vertical.back": "esc назад"
|
|
43
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sentinel.other": "Введіть щось.",
|
|
3
|
+
"sentinel.next": "Далі",
|
|
4
|
+
"submit.label": "Надіслати відповіді",
|
|
5
|
+
"submit.cancel": "Скасувати",
|
|
6
|
+
"hint.enter": "↵ обрати",
|
|
7
|
+
"hint.navigate": "↑↓ навігація",
|
|
8
|
+
"hint.newline": "⇧↵ новий рядок",
|
|
9
|
+
"hint.clear": "⌃u очистити",
|
|
10
|
+
"hint.toggle": " перемкнути",
|
|
11
|
+
"hint.notes": "n нотатки",
|
|
12
|
+
"hint.tab": "⇥ питання",
|
|
13
|
+
"hint.collapse": "⌃] згорнути",
|
|
14
|
+
"hint.expand_line": "⌃] розгорнути · esc скасувати",
|
|
15
|
+
"hint.cancel": "esc скасувати",
|
|
16
|
+
"review.heading": "Перегляньте свої відповіді",
|
|
17
|
+
"review.ready": "Готові надіслати відповіді?",
|
|
18
|
+
"review.incomplete": "⚠ Дайте відповіді на решту питань перед надсиланням:",
|
|
19
|
+
"preview.no_preview": "Попередній перегляд недоступний",
|
|
20
|
+
"preview.notes_affordance": "Нотатки: натисніть n, щоб додати нотатки",
|
|
21
|
+
"notes.header": "Нотатки:",
|
|
22
|
+
"editor.failed": "Помилка зовнішнього редактора",
|
|
23
|
+
"entry.answered": "отримано відповідь",
|
|
24
|
+
"entry.cancelled": "скасовано",
|
|
25
|
+
"entry.question_cancelled": "Питання скасовано",
|
|
26
|
+
"rpc.multi_instructions": "Введіть номери всіх відповідних варіантів через кому (наприклад, \"1,3\") або введіть власну відповідь текстом.",
|
|
27
|
+
"rpc.custom_answer_title": "Введіть свою відповідь:",
|
|
28
|
+
"_meta.notes": "Auto-translated draft. Native-speaker review welcome via PR. TUI symbols (↑/↓, ⚠) and key names (Enter, Esc, Tab, Space, n, Ctrl+G, Ctrl+U) are universal CLI conventions and stay untranslated.",
|
|
29
|
+
"gate.title": "Emma · Далі",
|
|
30
|
+
"gate.question": "Виберіть наступний крок.",
|
|
31
|
+
"preview.label": "Підсумок Emma:",
|
|
32
|
+
"preview.label.shape": "План Emma:",
|
|
33
|
+
"preview.label.build": "Звіт Emma:",
|
|
34
|
+
"preview.label.hunt": "Висновки Emma:",
|
|
35
|
+
"vertical.too_small": "Збільште: 40x20",
|
|
36
|
+
"vertical.too_small_hint": "Esc / Ctrl+C: скасувати",
|
|
37
|
+
"vertical.input_label": "Введення:",
|
|
38
|
+
"vertical.recommended": "Рекомендовано",
|
|
39
|
+
"vertical.unanswered": "без відповіді",
|
|
40
|
+
"vertical.global_note": "Загальна нотатка",
|
|
41
|
+
"vertical.note_empty": "(натисніть n, щоб додати)",
|
|
42
|
+
"vertical.back": "esc назад"
|
|
43
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"sentinel.other": "输入内容",
|
|
3
|
+
"sentinel.next": "下一个",
|
|
4
|
+
"submit.label": "提交答案",
|
|
5
|
+
"submit.cancel": "取消",
|
|
6
|
+
"hint.enter": "↵ 选择",
|
|
7
|
+
"hint.navigate": "↑↓ 导航",
|
|
8
|
+
"hint.newline": "⇧↵ 换行",
|
|
9
|
+
"hint.clear": "⌃u 清空",
|
|
10
|
+
"hint.toggle": "空格 切换",
|
|
11
|
+
"hint.notes": "n 备注",
|
|
12
|
+
"hint.tab": "⇥ 切换问题",
|
|
13
|
+
"hint.collapse": "⌃] 折叠",
|
|
14
|
+
"hint.expand_line": "⌃] 展开 · esc 取消",
|
|
15
|
+
"hint.cancel": "esc 取消",
|
|
16
|
+
"review.heading": "检查你的答案",
|
|
17
|
+
"review.ready": "准备提交答案了吗?",
|
|
18
|
+
"review.incomplete": "⚠ 提交前请先回答以下问题:",
|
|
19
|
+
"preview.no_preview": "暂无预览",
|
|
20
|
+
"preview.notes_affordance": "备注:按 n 添加",
|
|
21
|
+
"notes.header": "备注:",
|
|
22
|
+
"editor.failed": "外部编辑器启动失败",
|
|
23
|
+
"entry.answered": "已回答",
|
|
24
|
+
"entry.feedback_no_action": "反馈 — 未请求动作,未授权修复",
|
|
25
|
+
"entry.cancelled": "已取消",
|
|
26
|
+
"entry.question_cancelled": "问题已取消",
|
|
27
|
+
"rpc.multi_instructions": "输入所有适用选项的编号,用逗号分隔(例如 \"1,3\"),或直接输入自定义回答。",
|
|
28
|
+
"rpc.custom_answer_title": "输入你的回答:",
|
|
29
|
+
"_meta.notes": "中文翻译。欢迎中文母语者通过 PR 审校。TUI 符号(↑/↓、⚠)为通用 CLI 约定,保持原文不译。Enter、Space 采用中文惯用说法(回车、空格);Esc、Tab、Ctrl、n 等保留原文。",
|
|
30
|
+
"shape.blockers": "阻塞问题",
|
|
31
|
+
"shape.authorize": "Continue 将确认当前计划并授权施工。",
|
|
32
|
+
"gate.title": "Emma · 下一步",
|
|
33
|
+
"gate.question": "请选择下一步",
|
|
34
|
+
"preview.label": "这是 Emma 的汇总:",
|
|
35
|
+
"preview.label.shape": "这是 Emma 的计划:",
|
|
36
|
+
"preview.label.build": "这是 Emma 的报告:",
|
|
37
|
+
"preview.label.hunt": "这是 Emma 的排查结论:",
|
|
38
|
+
"vertical.too_small": "请放大至 40x20",
|
|
39
|
+
"vertical.too_small_hint": "Esc / Ctrl+C:取消",
|
|
40
|
+
"vertical.input_label": "输入:",
|
|
41
|
+
"vertical.recommended": "建议",
|
|
42
|
+
"vertical.unanswered": "未答",
|
|
43
|
+
"vertical.global_note": "全局备注",
|
|
44
|
+
"vertical.note_empty": "(按 n 添加)",
|
|
45
|
+
"vertical.back": "esc 返回"
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Public overlay presence is deliberately conservative: passive HUDs count too. */
|
|
2
|
+
export function mustYieldInlineSlot(tui: { hasOverlay?: () => boolean }): boolean {
|
|
3
|
+
return tui.hasOverlay?.() ?? false;
|
|
4
|
+
}
|
|
5
|
+
let inlineSlotHeld = false;
|
|
6
|
+
export function claimInlineSlot(): (() => void) | undefined {
|
|
7
|
+
if (inlineSlotHeld) return undefined;
|
|
8
|
+
inlineSlotHeld = true;
|
|
9
|
+
let released = false;
|
|
10
|
+
return () => { if (!released) { released = true; inlineSlotHeld = false; } };
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { QuestionData } from "./tool/types.js";
|
|
2
|
+
|
|
3
|
+
/** True when the question-level document preview is the body rendered for this question. */
|
|
4
|
+
export function hasQuestionLevelPreview(question: QuestionData | undefined): boolean {
|
|
5
|
+
return Boolean(question?.preview) && question?.multiSelect !== true;
|
|
6
|
+
}
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC / dialog-primitive fallback for `ask_user_question`.
|
|
3
|
+
*
|
|
4
|
+
* The canonical TUI path (`ctx.ui.custom()`) renders the interactive transcript entry
|
|
5
|
+
* and needs a real terminal. RPC-mode hosts (the VSCode pendant, ACP clients such
|
|
6
|
+
* as Zed or Paseo) report `hasUI: true` because pi's dialog sub-protocol
|
|
7
|
+
* (`extension_ui_request`/`extension_ui_response`) works, but `ui.custom()`
|
|
8
|
+
* resolves `undefined` without rendering anything (issue #78). `ui.select()`
|
|
9
|
+
* and `ui.input()` ARE functional there — the host renders them natively — so
|
|
10
|
+
* this module walks the questions sequentially with those primitives and
|
|
11
|
+
* returns the same `QuestionnaireResult` shapes the TUI produces, feeding the
|
|
12
|
+
* shared `QuestionnaireResult` envelope.
|
|
13
|
+
*
|
|
14
|
+
* Parity trade-offs vs the TUI, inherent to the select/input API surface: no
|
|
15
|
+
* side-by-side preview pane (previews are folded into the prompt title), no
|
|
16
|
+
* tabbed multi-question review (one dialog per question), and multi-select is
|
|
17
|
+
* a free-text numbers input instead of checkbox rows. The "Type something."
|
|
18
|
+
* escape is preserved on both variants — multi-select treats any non-index
|
|
19
|
+
* input as a typed custom answer — matching
|
|
20
|
+
* `ROW_INTENT_META.other.autoAppendOnMultiSelect`.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { displayLabel, t } from "./i18n.js";
|
|
24
|
+
import type { QuestionAnswer, QuestionData, QuestionnaireResult, QuestionParams } from "./tool/types.js";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Canonical-English fallbacks; resolved through `t()` at dialog time so the
|
|
28
|
+
* live locale applies (top-level `const x = t(...)` would bake load-time
|
|
29
|
+
* English in — see i18n-bridge.ts). The sentinel row label comes from
|
|
30
|
+
* `displayLabel("other")` — same source as the TUI row.
|
|
31
|
+
*/
|
|
32
|
+
const MULTI_SELECT_INSTRUCTIONS =
|
|
33
|
+
'Enter the numbers of all that apply, comma-separated (e.g. "1,3"), or type a custom answer as plain text.';
|
|
34
|
+
const CUSTOM_ANSWER_TITLE = "Type your answer:";
|
|
35
|
+
const MULTI_SELECT_PLACEHOLDER = "1,3";
|
|
36
|
+
|
|
37
|
+
/** Longest preview slice folded into a select title before truncation. */
|
|
38
|
+
const MAX_PREVIEW_CHARS = 600;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The dialog-primitive slice of `ExtensionUIContext` this walker needs.
|
|
42
|
+
* Structural on purpose: the pinned pi 0.74 peer types predate `ctx.mode`,
|
|
43
|
+
* and jiti transpiles without type-checking — `hasDialogUI` is the runtime
|
|
44
|
+
* gate that makes the shape trustworthy.
|
|
45
|
+
*/
|
|
46
|
+
export type DialogUI = {
|
|
47
|
+
select: (
|
|
48
|
+
title: string,
|
|
49
|
+
options: string[],
|
|
50
|
+
opts?: { signal?: AbortSignal },
|
|
51
|
+
) => Promise<string | undefined>;
|
|
52
|
+
input: (
|
|
53
|
+
title: string,
|
|
54
|
+
placeholder?: string,
|
|
55
|
+
opts?: { signal?: AbortSignal },
|
|
56
|
+
) => Promise<string | undefined>;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/** True when the host implements the select/input dialog primitives. */
|
|
60
|
+
export function hasDialogUI(ui: unknown): ui is DialogUI {
|
|
61
|
+
const u = ui as Partial<Record<"select" | "input", unknown>> | null | undefined;
|
|
62
|
+
return typeof u?.select === "function" && typeof u?.input === "function";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type Option = QuestionData["options"][number];
|
|
66
|
+
const ABORTED = Symbol("questionnaire-aborted");
|
|
67
|
+
|
|
68
|
+
async function waitForDialog<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T | typeof ABORTED> {
|
|
69
|
+
if (!signal) return promise;
|
|
70
|
+
if (signal.aborted) return ABORTED;
|
|
71
|
+
return new Promise<T | typeof ABORTED>((resolve, reject) => {
|
|
72
|
+
let settled = false;
|
|
73
|
+
const finish = (value: T | typeof ABORTED) => {
|
|
74
|
+
if (settled) return;
|
|
75
|
+
settled = true;
|
|
76
|
+
signal.removeEventListener("abort", onAbort);
|
|
77
|
+
resolve(value);
|
|
78
|
+
};
|
|
79
|
+
const onAbort = () => finish(ABORTED);
|
|
80
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
81
|
+
promise.then(finish, (error) => {
|
|
82
|
+
if (settled) return;
|
|
83
|
+
settled = true;
|
|
84
|
+
signal.removeEventListener("abort", onAbort);
|
|
85
|
+
reject(error);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function formatOptionLine(option: Option, index: number): string {
|
|
91
|
+
return option.description
|
|
92
|
+
? `${index + 1}. ${option.label} — ${option.description}`
|
|
93
|
+
: `${index + 1}. ${option.label}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Parse a user-entered (or select-returned) "N…" token to a 0-based option
|
|
98
|
+
* index. `parseInt` reads the leading digits of "2. B — b" as 2; NaN and
|
|
99
|
+
* out-of-range fail the bounds check and return null.
|
|
100
|
+
*/
|
|
101
|
+
function parseIndex(token: string, count: number): number | null {
|
|
102
|
+
const i = Number.parseInt(token, 10) - 1;
|
|
103
|
+
return i >= 0 && i < count ? i : null;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** Previews folded into the select title — RPC has no side-by-side pane. */
|
|
107
|
+
function buildPreviewBlock(question: QuestionData, fullPreview = false): string {
|
|
108
|
+
const limit = fullPreview ? undefined : MAX_PREVIEW_CHARS;
|
|
109
|
+
const blocks = question.preview && question.preview.length > 0
|
|
110
|
+
? [`--- preview ---\n${question.preview.slice(0, limit)}`]
|
|
111
|
+
: [];
|
|
112
|
+
for (let i = 0; i < question.options.length; i++) {
|
|
113
|
+
const o = question.options[i];
|
|
114
|
+
if (o.preview && o.preview.length > 0)
|
|
115
|
+
blocks.push(`--- ${i + 1}. ${o.label} preview ---\n${o.preview.slice(0, limit)}`);
|
|
116
|
+
}
|
|
117
|
+
return blocks.length > 0 ? `\n\n${blocks.join("\n\n")}` : "";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Walk the questionnaire one native dialog at a time. Dismissing any dialog
|
|
122
|
+
* (the primitive resolves `undefined`) cancels the whole questionnaire —
|
|
123
|
+
* mirroring Esc in the TUI — and the shared envelope emits DECLINE. A
|
|
124
|
+
* `QuestionAnswer` is produced per question otherwise, so the envelope is
|
|
125
|
+
* identical to the TUI path's.
|
|
126
|
+
*/
|
|
127
|
+
export async function runRpcQuestionnaire(
|
|
128
|
+
ui: DialogUI,
|
|
129
|
+
params: QuestionParams,
|
|
130
|
+
signal?: AbortSignal,
|
|
131
|
+
fullPreview = false,
|
|
132
|
+
): Promise<QuestionnaireResult> {
|
|
133
|
+
const answers: QuestionAnswer[] = [];
|
|
134
|
+
for (let qi = 0; qi < params.questions.length; qi++) {
|
|
135
|
+
const q = params.questions[qi];
|
|
136
|
+
const header = q.header ? `[${q.header}] ` : "";
|
|
137
|
+
const answer = q.multiSelect
|
|
138
|
+
? await askMultiSelect(ui, q, qi, header, signal)
|
|
139
|
+
: await askSingleSelect(ui, q, qi, header, signal, fullPreview);
|
|
140
|
+
if (answer === undefined) return { answers, cancelled: true };
|
|
141
|
+
answers.push(answer);
|
|
142
|
+
}
|
|
143
|
+
return { answers, cancelled: false };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** `undefined` means the user dismissed the dialog (cancel the questionnaire). */
|
|
147
|
+
async function askSingleSelect(
|
|
148
|
+
ui: DialogUI,
|
|
149
|
+
q: QuestionData,
|
|
150
|
+
questionIndex: number,
|
|
151
|
+
header: string,
|
|
152
|
+
signal?: AbortSignal,
|
|
153
|
+
fullPreview = false,
|
|
154
|
+
): Promise<QuestionAnswer | undefined> {
|
|
155
|
+
const options = q.options.map(formatOptionLine);
|
|
156
|
+
options.push(`${q.options.length + 1}. ${displayLabel("other")}`);
|
|
157
|
+
const chosen = await waitForDialog(ui.select(
|
|
158
|
+
`${header}${q.question}${buildPreviewBlock(q, fullPreview)}`,
|
|
159
|
+
options,
|
|
160
|
+
{ signal },
|
|
161
|
+
), signal);
|
|
162
|
+
if (chosen === ABORTED || chosen == null) return undefined;
|
|
163
|
+
// Only an exact offered value is a selection; numbered feedback is not consent.
|
|
164
|
+
const idx = options.indexOf(chosen);
|
|
165
|
+
if (idx === -1) return undefined;
|
|
166
|
+
if (idx < q.options.length) {
|
|
167
|
+
const o = q.options[idx];
|
|
168
|
+
return {
|
|
169
|
+
questionIndex,
|
|
170
|
+
question: q.question,
|
|
171
|
+
kind: "option",
|
|
172
|
+
answer: o.label,
|
|
173
|
+
preview: o.preview && o.preview.length > 0 ? o.preview : undefined,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
// "Type something." sentinel → free-text follow-up.
|
|
177
|
+
const typed = await waitForDialog(ui.input(
|
|
178
|
+
`${header}${q.question}\n\n${t("rpc.custom_answer_title", CUSTOM_ANSWER_TITLE)}`,
|
|
179
|
+
"",
|
|
180
|
+
{ signal },
|
|
181
|
+
), signal);
|
|
182
|
+
if (typed === ABORTED || typed == null) return undefined;
|
|
183
|
+
return { questionIndex, question: q.question, kind: "custom", answer: typed };
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** `undefined` means the user dismissed the dialog (cancel the questionnaire). */
|
|
187
|
+
async function askMultiSelect(
|
|
188
|
+
ui: DialogUI,
|
|
189
|
+
q: QuestionData,
|
|
190
|
+
questionIndex: number,
|
|
191
|
+
header: string,
|
|
192
|
+
signal?: AbortSignal,
|
|
193
|
+
): Promise<QuestionAnswer | undefined> {
|
|
194
|
+
const list = q.options.map(formatOptionLine).join("\n");
|
|
195
|
+
const value = await waitForDialog(ui.input(
|
|
196
|
+
`${header}${q.question}\n\n${list}\n\n${t("rpc.multi_instructions", MULTI_SELECT_INSTRUCTIONS)}`,
|
|
197
|
+
MULTI_SELECT_PLACEHOLDER,
|
|
198
|
+
{ signal },
|
|
199
|
+
), signal);
|
|
200
|
+
if (value === ABORTED || value == null) return undefined;
|
|
201
|
+
const trimmed = value.trim();
|
|
202
|
+
if (trimmed.length === 0) {
|
|
203
|
+
// Deliberate empty commit — same as pressing "Next" with nothing toggled.
|
|
204
|
+
return { questionIndex, question: q.question, kind: "multi", answer: null, selected: [] };
|
|
205
|
+
}
|
|
206
|
+
const tokens = trimmed.split(/[,\s]+/).filter((tok) => tok.length > 0);
|
|
207
|
+
const indices = tokens.map((tok) => (/^\d+\.?$/.test(tok) ? parseIndex(tok, q.options.length) : null));
|
|
208
|
+
if (indices.every((i): i is number => i != null)) {
|
|
209
|
+
const selected: string[] = [];
|
|
210
|
+
for (const i of indices) {
|
|
211
|
+
const label = q.options[i].label;
|
|
212
|
+
if (!selected.includes(label)) selected.push(label);
|
|
213
|
+
}
|
|
214
|
+
return { questionIndex, question: q.question, kind: "multi", answer: null, selected };
|
|
215
|
+
}
|
|
216
|
+
// Any non-index token (words, or an out-of-range number like "13" for three
|
|
217
|
+
// options) means the user typed an answer, not a selection. Preserve it
|
|
218
|
+
// verbatim as a custom answer instead of silently dropping their input —
|
|
219
|
+
// this is also the multi-select "Type something." escape.
|
|
220
|
+
return { questionIndex, question: q.question, kind: "custom", answer: trimmed };
|
|
221
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { loadTimeoutPolicy, validTimeoutSeconds } from './timeout.js';
|
|
3
|
+
|
|
4
|
+
const USAGE = '用法:/vc-ask unattended <1–86400 秒> | status | reset';
|
|
5
|
+
|
|
6
|
+
export function registerSessionTimeout(pi: ExtensionAPI, getAgentDir: () => string) {
|
|
7
|
+
const overrides = new Map<string, number>();
|
|
8
|
+
const policyFor = (sessionId: string, warn: (message: string) => void) => {
|
|
9
|
+
const seconds = overrides.get(sessionId);
|
|
10
|
+
try {
|
|
11
|
+
return loadTimeoutPolicy(getAgentDir(), seconds);
|
|
12
|
+
} catch {
|
|
13
|
+
warn(seconds === undefined
|
|
14
|
+
? '无法读取或验证 vc-ask.json;问卷将等待人工回答,不设超时。'
|
|
15
|
+
: `无法读取或验证 vc-ask.json;保留会话超时 ${seconds} 秒,关闭自动选择。`);
|
|
16
|
+
return seconds === undefined ? undefined : { seconds, autoSelect: false, allowed: [] };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
pi.on('session_shutdown', () => overrides.clear());
|
|
21
|
+
pi.registerCommand('vc-ask', {
|
|
22
|
+
description: '查看或临时调整当前 Pi 会话的问卷超时',
|
|
23
|
+
async handler(args, context) {
|
|
24
|
+
if (context.mode !== 'tui') {
|
|
25
|
+
context.ui.notify('当前模式不支持 /vc-ask 问卷超时设置,仅限 Pi TUI。', 'warning');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const [action, seconds, ...rest] = args.trim().split(/\s+/);
|
|
29
|
+
const warn = (message: string) => context.ui.notify(message, 'warning');
|
|
30
|
+
const sessionId = context.sessionManager.getSessionId();
|
|
31
|
+
if (!sessionId) {
|
|
32
|
+
context.ui.notify('无法识别当前会话,未修改问卷策略。', 'warning');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (action === 'reset' && seconds === undefined) {
|
|
36
|
+
overrides.delete(sessionId);
|
|
37
|
+
let validConfig = true;
|
|
38
|
+
policyFor(sessionId, message => {
|
|
39
|
+
validConfig = false;
|
|
40
|
+
warn(`已清除当前会话覆盖。${message}`);
|
|
41
|
+
});
|
|
42
|
+
if (validConfig) context.ui.notify('已清除当前会话覆盖,后续问卷使用 vc-ask.json 中的配置。', 'info');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
if (action === 'status' && seconds === undefined) {
|
|
47
|
+
const policy = policyFor(sessionId, warn);
|
|
48
|
+
const source = overrides.has(sessionId) ? '会话覆盖' : 'vc-ask.json(缺省时不设超时)';
|
|
49
|
+
context.ui.notify(policy
|
|
50
|
+
? `超时 ${policy.seconds} 秒;自动选择${policy.autoSelect ? '开启' : '关闭'};白名单 ${policy.allowed.length} 条。来源:${source}。`
|
|
51
|
+
: `不设超时;自动选择关闭。来源:${source}。`, 'info');
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
if (action === 'unattended' && seconds !== undefined && /^\d+$/.test(seconds) && !rest.length && validTimeoutSeconds(Number(seconds))) {
|
|
55
|
+
const policy = loadTimeoutPolicy(getAgentDir(), Number(seconds))!;
|
|
56
|
+
overrides.set(sessionId, policy.seconds);
|
|
57
|
+
context.ui.notify(`当前会话的后续普通问卷将在 ${policy.seconds} 秒后超时,自动选择仅使用白名单(${policy.allowed.length} 条);未匹配时返回用户未选择。`, 'info');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
context.ui.notify(USAGE, 'warning');
|
|
61
|
+
} catch {
|
|
62
|
+
context.ui.notify('无法读取或验证 vc-ask.json;未修改当前会话策略。', 'error');
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
return policyFor;
|
|
67
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { getMarkdownTheme, type Theme } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { Editor, type EditorTheme, type TUI } from "@earendil-works/pi-tui";
|
|
3
|
+
import type { QuestionData } from "../tool/types.js";
|
|
4
|
+
import { MultiSelectView } from "../view/components/multi-select-view.js";
|
|
5
|
+
import { OptionListView } from "../view/components/option-list-view.js";
|
|
6
|
+
import { PreviewBlockRenderer } from "../view/components/preview/preview-block-renderer.js";
|
|
7
|
+
import { crossTabLeftWidthWithDonation } from "../view/components/preview/preview-layout-decider.js";
|
|
8
|
+
import { PreviewPane } from "../view/components/preview/preview-pane.js";
|
|
9
|
+
import { SubmitPicker } from "../view/components/submit-picker.js";
|
|
10
|
+
import { TabBar } from "../view/components/tab-bar.js";
|
|
11
|
+
import type { WrappingSelectItem, WrappingSelectTheme } from "../view/components/wrapping-select.js";
|
|
12
|
+
import type { AskPalette } from "../view/panel-chrome.js";
|
|
13
|
+
import { DocumentView } from "../view/document-view.js";
|
|
14
|
+
import { VerticalView } from "../view/vertical-view.js";
|
|
15
|
+
import { DialogView } from "../view/dialog-builder.js";
|
|
16
|
+
import { QuestionnairePropsAdapter } from "../view/props-adapter.js";
|
|
17
|
+
import type { TabComponents } from "../view/tab-components.js";
|
|
18
|
+
import { selectActivePreviewPaneIndex } from "./selectors/derivations.js";
|
|
19
|
+
import type { QuestionnaireState, QuestionnaireViewport } from "./state.js";
|
|
20
|
+
|
|
21
|
+
export interface QuestionnaireBuildConfig {
|
|
22
|
+
tui: TUI;
|
|
23
|
+
theme: Theme;
|
|
24
|
+
questions: readonly QuestionData[];
|
|
25
|
+
itemsByTab: ReadonlyArray<readonly WrappingSelectItem[]>;
|
|
26
|
+
isMulti: boolean;
|
|
27
|
+
initialState: QuestionnaireState;
|
|
28
|
+
getCurrentTab: () => number;
|
|
29
|
+
previewLabel?: string;
|
|
30
|
+
palette?: AskPalette;
|
|
31
|
+
document?: boolean;
|
|
32
|
+
vertical?: boolean;
|
|
33
|
+
/** Docked content that turns out not to fit promotes itself to the floating form. */
|
|
34
|
+
onDockOverflow?: () => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface QuestionnaireBuilt {
|
|
38
|
+
adapter: Pick<QuestionnairePropsAdapter, "apply" | "invalidate">;
|
|
39
|
+
document?: DocumentView;
|
|
40
|
+
vertical?: VerticalView;
|
|
41
|
+
notesInput: Editor;
|
|
42
|
+
inlineInput: Editor;
|
|
43
|
+
render: (width: number) => string[];
|
|
44
|
+
getViewport: () => QuestionnaireViewport;
|
|
45
|
+
invalidate: () => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function editorTheme(theme: Theme): EditorTheme {
|
|
49
|
+
return {
|
|
50
|
+
borderColor: (text) => theme.fg("borderMuted", text),
|
|
51
|
+
selectList: {
|
|
52
|
+
selectedPrefix: (text) => theme.bg("selectedBg", theme.fg("accent", text)),
|
|
53
|
+
selectedText: (text) => theme.bg("selectedBg", theme.bold(text)),
|
|
54
|
+
description: (text) => theme.fg("muted", text),
|
|
55
|
+
scrollInfo: (text) => theme.fg("dim", text),
|
|
56
|
+
noMatch: (text) => theme.fg("warning", text),
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function buildQuestionnaire(config: QuestionnaireBuildConfig): QuestionnaireBuilt {
|
|
62
|
+
const { tui, theme, questions, itemsByTab, isMulti, initialState, getCurrentTab, previewLabel } = config;
|
|
63
|
+
const selectTheme: WrappingSelectTheme = {
|
|
64
|
+
selectedText: (text) => theme.bg("selectedBg", theme.fg("accent", theme.bold(text))),
|
|
65
|
+
description: (text) => theme.fg("muted", text),
|
|
66
|
+
scrollInfo: (text) => theme.fg("dim", text),
|
|
67
|
+
};
|
|
68
|
+
const markdownTheme = getMarkdownTheme();
|
|
69
|
+
const textEditorTheme = editorTheme(theme);
|
|
70
|
+
const notesInput = new Editor(tui, textEditorTheme);
|
|
71
|
+
const inlineInput = new Editor(tui, textEditorTheme);
|
|
72
|
+
if (config.vertical) {
|
|
73
|
+
const vertical = new VerticalView({ theme, palette: config.palette, questions, input: inlineInput, notes: notesInput, rows: () => tui.terminal.rows, columns: () => tui.terminal.columns, initialState, requestRender: () => tui.requestRender() });
|
|
74
|
+
return {
|
|
75
|
+
adapter: { apply: state => { vertical.setProps(state); tui.requestRender(); }, invalidate: () => vertical.invalidate() },
|
|
76
|
+
vertical, notesInput, inlineInput, render: width => vertical.render(width),
|
|
77
|
+
getViewport: () => vertical.getViewport(), invalidate: () => vertical.invalidate(),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
if (config.document) {
|
|
81
|
+
const document = new DocumentView({ theme, palette: config.palette, question: questions[0]!, items: itemsByTab[0]!, input: inlineInput, notes: notesInput,
|
|
82
|
+
rows: () => tui.terminal.rows,
|
|
83
|
+
terminalRows: () => tui.terminal.rows,
|
|
84
|
+
terminalColumns: () => tui.terminal.columns,
|
|
85
|
+
requestRender: () => tui.requestRender(),
|
|
86
|
+
initialState, previewLabel,
|
|
87
|
+
...(config.onDockOverflow ? { onOverflow: config.onDockOverflow } : {}),
|
|
88
|
+
});
|
|
89
|
+
return {
|
|
90
|
+
adapter: {
|
|
91
|
+
apply: state => { document.setProps(state); tui.requestRender(); },
|
|
92
|
+
invalidate: () => document.invalidate(),
|
|
93
|
+
},
|
|
94
|
+
document, notesInput, inlineInput,
|
|
95
|
+
render: width => document.render(width),
|
|
96
|
+
getViewport: () => document.getViewport(),
|
|
97
|
+
invalidate: () => document.invalidate(),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const getTerminalWidth = () => tui.terminal.columns;
|
|
101
|
+
const globalLeftWidth = (width: number) => crossTabLeftWidthWithDonation(itemsByTab, questions, width);
|
|
102
|
+
const tabs: TabComponents[] = questions.map((question, index) => {
|
|
103
|
+
const optionList = new OptionListView({ items: itemsByTab[index] ?? [], theme: selectTheme });
|
|
104
|
+
const previewBlock = new PreviewBlockRenderer({
|
|
105
|
+
question, theme, markdownTheme,
|
|
106
|
+
...(previewLabel ? { previewLabel } : {}),
|
|
107
|
+
});
|
|
108
|
+
const preview = new PreviewPane({ question, getTerminalWidth, optionListView: optionList, previewBlock });
|
|
109
|
+
preview.setGlobalLeftWidth(globalLeftWidth);
|
|
110
|
+
const multiSelect = question.multiSelect ? new MultiSelectView(theme, question) : undefined;
|
|
111
|
+
return {
|
|
112
|
+
optionList, preview, multiSelect,
|
|
113
|
+
bodyHeights: (width) => {
|
|
114
|
+
if (multiSelect) {
|
|
115
|
+
const height = multiSelect.naturalHeight(width);
|
|
116
|
+
return { current: height, max: height };
|
|
117
|
+
}
|
|
118
|
+
const current = preview.naturalHeight(width);
|
|
119
|
+
return { current, max: Math.max(current, preview.maxNaturalHeight(width)) };
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
const submitPicker = isMulti ? new SubmitPicker(theme) : undefined;
|
|
124
|
+
const tabBar = isMulti ? new TabBar(theme) : undefined;
|
|
125
|
+
const paneIndex = selectActivePreviewPaneIndex(initialState.currentTab, questions.length);
|
|
126
|
+
const dialog = new DialogView({
|
|
127
|
+
theme, questions, tabBar, notesInput, isMulti, tabsByIndex: tabs, submitPicker,
|
|
128
|
+
getBodyHeight: (width) => Math.max(1, ...tabs.map((tab) => tab.bodyHeights(width).max)),
|
|
129
|
+
getCurrentBodyHeight: (width) => {
|
|
130
|
+
const index = Math.min(getCurrentTab(), tabs.length - 1);
|
|
131
|
+
return Math.max(0, tabs[index]?.bodyHeights(width).current ?? 0);
|
|
132
|
+
},
|
|
133
|
+
getTerminalRows: () => tui.terminal.rows,
|
|
134
|
+
}, { state: initialState, activePreviewPane: tabs[paneIndex]?.preview ?? tabs[0]!.preview });
|
|
135
|
+
const adapter = new QuestionnairePropsAdapter({
|
|
136
|
+
tui, questions, itemsByTab, tabsByIndex: tabs, inlineInput, notesInput, dialog, submitPicker, tabBar,
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
adapter, notesInput, inlineInput,
|
|
140
|
+
render: (width) => dialog.render(width),
|
|
141
|
+
getViewport: () => dialog.getViewport(),
|
|
142
|
+
invalidate: () => adapter.invalidate(),
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
|
|
6
|
+
export interface ExternalEditorTui {
|
|
7
|
+
stop(): void;
|
|
8
|
+
start(): void;
|
|
9
|
+
requestRender(force?: boolean): void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function runEditor(command: string, file: string): Promise<void> {
|
|
13
|
+
// Keep the command grammar identical to Pi's built-in external-editor flow. A
|
|
14
|
+
// separate shell or argv parser here would make Ctrl+G behave differently.
|
|
15
|
+
const [editor, ...args] = command.split(" ");
|
|
16
|
+
if (!editor) return Promise.reject(new Error("External editor command is empty"));
|
|
17
|
+
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const child = spawn(editor, [...args, file], {
|
|
20
|
+
stdio: "inherit",
|
|
21
|
+
shell: process.platform === "win32",
|
|
22
|
+
});
|
|
23
|
+
child.once("error", reject);
|
|
24
|
+
child.once("close", (code, signal) => {
|
|
25
|
+
if (code === 0) {
|
|
26
|
+
resolve();
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const reason = signal ? `signal ${signal}` : `exit code ${code ?? "unknown"}`;
|
|
30
|
+
reject(new Error(`External editor exited with ${reason}`));
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Edit a custom answer with Pi's configured external-editor command. The TUI lifecycle
|
|
37
|
+
* and one-trailing-newline normalization intentionally match Pi's main editor flow.
|
|
38
|
+
*/
|
|
39
|
+
export async function editWithExternalEditor(tui: ExternalEditorTui, command: string, value: string): Promise<string> {
|
|
40
|
+
const tempDir = mkdtempSync(join(tmpdir(), "emma-questionnaire-"));
|
|
41
|
+
const tempFile = join(tempDir, "answer.md");
|
|
42
|
+
let tuiStopped = false;
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
writeFileSync(tempFile, value, "utf8");
|
|
46
|
+
tui.stop();
|
|
47
|
+
tuiStopped = true;
|
|
48
|
+
process.stdout.write(`Launching external editor: ${command}\nPi will resume when the editor exits.\n`);
|
|
49
|
+
await runEditor(command, tempFile);
|
|
50
|
+
return readFileSync(tempFile, "utf8").replace(/\r?\n$/, "");
|
|
51
|
+
} finally {
|
|
52
|
+
try {
|
|
53
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
54
|
+
} catch {
|
|
55
|
+
// Temp cleanup is best effort; never leave the TUI stopped because it failed.
|
|
56
|
+
}
|
|
57
|
+
if (tuiStopped) {
|
|
58
|
+
tui.start();
|
|
59
|
+
tui.requestRender(true);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|