attune-forms 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1,111 @@
1
+ """Declarative form → AskUserQuestion bridge (elicitation v1).
2
+
3
+ The load-bearing core of the ``elicitation-form-surface`` spec (Option
4
+ B): it runs the salvaged, surface-agnostic ``FormSchema`` model
5
+ (:mod:`attune_forms.models`) against the live
6
+ ``AskUserQuestion`` tool. These are pure transforms — no agent/tool
7
+ dependency — so they are fully testable, and they are the same seam a
8
+ future richer (v2) renderer plugs into.
9
+
10
+ Public surface:
11
+
12
+ - :func:`form_from_dict` — build the declarative artifact (D3) from
13
+ plain serializable data.
14
+ - :func:`form_to_askuserquestion` — batched ``AskUserQuestion`` payloads
15
+ (≤4 questions per call).
16
+ - :func:`select_form_surface` — the surface router (D21): the widget is
17
+ the default; ``AskUserQuestion`` is the explicit fallback, taken only
18
+ for a non-widget client, keyboard mode, or a trivial form.
19
+ - :func:`is_trivial_form` — the narrow, mechanical triviality test the
20
+ router uses.
21
+ - :func:`is_fully_inferred` / :func:`inferred_field_count` — inference
22
+ state. A fully-inferred form renders as a one-tap confirmation rather
23
+ than a question, and is never silently skipped.
24
+ - :func:`keyboard_mode_enabled` — the user's terse/keyboard opt-out
25
+ (D17), persisted per project in ``attune.config.json`` with
26
+ ``ATTUNE_KEYBOARD_MODE`` as a session override.
27
+ - :func:`set_keyboard_mode` — persist that preference (what
28
+ ``attune config set keyboard_mode`` calls).
29
+ - :func:`needs_widget` — low-level *controls* check: True iff a form
30
+ loses fidelity on ``AskUserQuestion``. No longer owns the surface
31
+ decision — prefer :func:`select_form_surface`.
32
+ - :func:`form_response_summary` — collapse an answered form to a
33
+ compact markdown summary, so a long session accumulates a few lines
34
+ per ask instead of a screenful of markup.
35
+ - :func:`collect_form_response` — validate raw answers (required +
36
+ option membership) and map them into a ``FormResponse`` (R4 — never
37
+ silently accept malformed input).
38
+
39
+ Copyright 2026 Smart-AI-Memory
40
+ Licensed under Apache 2.0
41
+ """
42
+
43
+ from __future__ import annotations
44
+
45
+ from attune_forms.form_events import log_surface_decision
46
+ from attune_forms.intake_template import (
47
+ PROVIDERS,
48
+ TEMPLATES,
49
+ FieldSlot,
50
+ FormTemplate,
51
+ ProviderContext,
52
+ TemplateError,
53
+ build_form,
54
+ intake_form,
55
+ validate_template,
56
+ )
57
+ from attune_forms.models import FormQuestion, FormResponse, FormSchema, QuestionType
58
+ from attune_forms.bridge import (
59
+ FormValidationError,
60
+ collect_form_response,
61
+ form_from_dict,
62
+ form_response_summary,
63
+ form_to_askuserquestion,
64
+ inferred_field_count,
65
+ is_fully_inferred,
66
+ is_trivial_form,
67
+ keyboard_mode_enabled,
68
+ needs_widget,
69
+ select_form_surface,
70
+ set_keyboard_mode,
71
+ )
72
+ from attune_forms.elicitation_schema import form_to_elicitation_schema
73
+ from attune_forms.reference_form import EXAMPLE_ANSWERS, REFERENCE_FORM
74
+ from attune_forms.template_store import form_from_template, list_templates
75
+ from attune_forms.widget import WIDGET_RESPONSE_MARKER, form_to_widget_html
76
+
77
+ __all__ = [
78
+ "EXAMPLE_ANSWERS",
79
+ "PROVIDERS",
80
+ "TEMPLATES",
81
+ "FieldSlot",
82
+ "FormQuestion",
83
+ "FormResponse",
84
+ "FormSchema",
85
+ "FormTemplate",
86
+ "ProviderContext",
87
+ "QuestionType",
88
+ "TemplateError",
89
+ "build_form",
90
+ "intake_form",
91
+ "log_surface_decision",
92
+ "validate_template",
93
+ "REFERENCE_FORM",
94
+ "WIDGET_RESPONSE_MARKER",
95
+ "FormValidationError",
96
+ "collect_form_response",
97
+ "form_from_dict",
98
+ "form_from_template",
99
+ "form_response_summary",
100
+ "form_to_askuserquestion",
101
+ "form_to_elicitation_schema",
102
+ "form_to_widget_html",
103
+ "inferred_field_count",
104
+ "is_fully_inferred",
105
+ "is_trivial_form",
106
+ "keyboard_mode_enabled",
107
+ "list_templates",
108
+ "needs_widget",
109
+ "select_form_surface",
110
+ "set_keyboard_mode",
111
+ ]