@juicesharp/rpiv-ask-user-question 1.8.0 → 1.8.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.
Files changed (2) hide show
  1. package/config.ts +5 -34
  2. package/package.json +86 -83
package/config.ts CHANGED
@@ -1,43 +1,14 @@
1
- import { existsSync, readFileSync } from "node:fs";
2
- import { homedir } from "node:os";
3
- import { join } from "node:path";
1
+ import type { GuidanceFields } from "@juicesharp/rpiv-config";
2
+ import { configPath, loadJsonConfig, validateGuidanceFields } from "@juicesharp/rpiv-config";
4
3
 
5
- const CONFIG_DIR = join(homedir(), ".config", "rpiv-ask-user-question");
6
- const CONFIG_PATH = join(CONFIG_DIR, "config.json");
7
-
8
- interface GuidanceFields {
9
- promptSnippet?: string;
10
- promptGuidelines?: string[];
11
- }
4
+ const CONFIG_PATH = configPath("rpiv-ask-user-question");
12
5
 
13
6
  interface AskUserQuestionConfig {
14
7
  guidance?: GuidanceFields;
15
8
  }
16
9
 
17
10
  export function loadConfig(): AskUserQuestionConfig {
18
- if (!existsSync(CONFIG_PATH)) return {};
19
- try {
20
- const parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf-8")) as unknown;
21
- if (parsed === null || typeof parsed !== "object") return {};
22
- return parsed as AskUserQuestionConfig;
23
- } catch {
24
- return {};
25
- }
11
+ return loadJsonConfig<AskUserQuestionConfig>(CONFIG_PATH);
26
12
  }
27
13
 
28
- export function validateGuidanceFields(fields: unknown): GuidanceFields {
29
- if (!fields || typeof fields !== "object") return {};
30
- const g = fields as Record<string, unknown>;
31
- const result: GuidanceFields = {};
32
- if (typeof g.promptSnippet === "string" && g.promptSnippet.length > 0) {
33
- result.promptSnippet = g.promptSnippet;
34
- }
35
- if (
36
- Array.isArray(g.promptGuidelines) &&
37
- g.promptGuidelines.length > 0 &&
38
- g.promptGuidelines.every((s) => typeof s === "string" && s.length > 0)
39
- ) {
40
- result.promptGuidelines = g.promptGuidelines;
41
- }
42
- return result;
43
- }
14
+ export { validateGuidanceFields };
package/package.json CHANGED
@@ -1,85 +1,88 @@
1
1
  {
2
- "name": "@juicesharp/rpiv-ask-user-question",
3
- "version": "1.8.0",
4
- "description": "Pi extension. A structured questionnaire the model can put to you when it would otherwise guess, with typed options instead of free-form replies.",
5
- "keywords": [
6
- "pi-package",
7
- "pi-extension",
8
- "rpiv"
9
- ],
10
- "type": "module",
11
- "license": "MIT",
12
- "author": "juicesharp",
13
- "repository": {
14
- "type": "git",
15
- "url": "git+https://github.com/juicesharp/rpiv-mono.git",
16
- "directory": "packages/rpiv-ask-user-question"
17
- },
18
- "homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-ask-user-question#readme",
19
- "bugs": {
20
- "url": "https://github.com/juicesharp/rpiv-mono/issues"
21
- },
22
- "publishConfig": {
23
- "access": "public"
24
- },
25
- "scripts": {
26
- "test": "vitest run"
27
- },
28
- "files": [
29
- "ask-user-question.ts",
30
- "config.ts",
31
- "index.ts",
32
- "LICENSE",
33
- "locales/",
34
- "README.md",
35
- "state/build-questionnaire.ts",
36
- "state/i18n-bridge.ts",
37
- "state/key-router.ts",
38
- "state/questionnaire-session.ts",
39
- "state/row-intent.ts",
40
- "state/selectors/contract.ts",
41
- "state/selectors/derivations.ts",
42
- "state/selectors/focus.ts",
43
- "state/selectors/projections.ts",
44
- "state/state-reducer.ts",
45
- "state/state.ts",
46
- "tool/format-answer.ts",
47
- "tool/response-envelope.ts",
48
- "tool/types.ts",
49
- "tool/validate-questionnaire.ts",
50
- "view/body-residual-spacer.ts",
51
- "view/component-binding.ts",
52
- "view/components/chat-row-view.ts",
53
- "view/components/multi-select-view.ts",
54
- "view/components/option-list-view.ts",
55
- "view/components/preview/markdown-content-cache.ts",
56
- "view/components/preview/preview-block-renderer.ts",
57
- "view/components/preview/preview-box-renderer.ts",
58
- "view/components/preview/preview-layout-decider.ts",
59
- "view/components/preview/preview-pane.ts",
60
- "view/components/submit-picker.ts",
61
- "view/components/tab-bar.ts",
62
- "view/components/wrapping-select.ts",
63
- "view/dialog-builder.ts",
64
- "view/props-adapter.ts",
65
- "view/stateful-view.ts",
66
- "view/tab-components.ts",
67
- "view/tab-content-strategy.ts"
68
- ],
69
- "pi": {
70
- "extensions": [
71
- "./index.ts"
72
- ]
73
- },
74
- "peerDependencies": {
75
- "@juicesharp/rpiv-i18n": "*",
76
- "@earendil-works/pi-coding-agent": "*",
77
- "@earendil-works/pi-tui": "*",
78
- "typebox": "*"
79
- },
80
- "peerDependenciesMeta": {
81
- "@juicesharp/rpiv-i18n": {
82
- "optional": true
83
- }
84
- }
2
+ "name": "@juicesharp/rpiv-ask-user-question",
3
+ "version": "1.8.1",
4
+ "description": "Pi extension. A structured questionnaire the model can put to you when it would otherwise guess, with typed options instead of free-form replies.",
5
+ "keywords": [
6
+ "pi-package",
7
+ "pi-extension",
8
+ "rpiv"
9
+ ],
10
+ "type": "module",
11
+ "license": "MIT",
12
+ "author": "juicesharp",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/juicesharp/rpiv-mono.git",
16
+ "directory": "packages/rpiv-ask-user-question"
17
+ },
18
+ "homepage": "https://github.com/juicesharp/rpiv-mono/tree/main/packages/rpiv-ask-user-question#readme",
19
+ "bugs": {
20
+ "url": "https://github.com/juicesharp/rpiv-mono/issues"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "test": "vitest run"
27
+ },
28
+ "files": [
29
+ "ask-user-question.ts",
30
+ "config.ts",
31
+ "index.ts",
32
+ "LICENSE",
33
+ "locales/",
34
+ "README.md",
35
+ "state/build-questionnaire.ts",
36
+ "state/i18n-bridge.ts",
37
+ "state/key-router.ts",
38
+ "state/questionnaire-session.ts",
39
+ "state/row-intent.ts",
40
+ "state/selectors/contract.ts",
41
+ "state/selectors/derivations.ts",
42
+ "state/selectors/focus.ts",
43
+ "state/selectors/projections.ts",
44
+ "state/state-reducer.ts",
45
+ "state/state.ts",
46
+ "tool/format-answer.ts",
47
+ "tool/response-envelope.ts",
48
+ "tool/types.ts",
49
+ "tool/validate-questionnaire.ts",
50
+ "view/body-residual-spacer.ts",
51
+ "view/component-binding.ts",
52
+ "view/components/chat-row-view.ts",
53
+ "view/components/multi-select-view.ts",
54
+ "view/components/option-list-view.ts",
55
+ "view/components/preview/markdown-content-cache.ts",
56
+ "view/components/preview/preview-block-renderer.ts",
57
+ "view/components/preview/preview-box-renderer.ts",
58
+ "view/components/preview/preview-layout-decider.ts",
59
+ "view/components/preview/preview-pane.ts",
60
+ "view/components/submit-picker.ts",
61
+ "view/components/tab-bar.ts",
62
+ "view/components/wrapping-select.ts",
63
+ "view/dialog-builder.ts",
64
+ "view/props-adapter.ts",
65
+ "view/stateful-view.ts",
66
+ "view/tab-components.ts",
67
+ "view/tab-content-strategy.ts"
68
+ ],
69
+ "pi": {
70
+ "extensions": [
71
+ "./index.ts"
72
+ ]
73
+ },
74
+ "peerDependencies": {
75
+ "@juicesharp/rpiv-i18n": "*",
76
+ "@earendil-works/pi-coding-agent": "*",
77
+ "@earendil-works/pi-tui": "*",
78
+ "typebox": "*"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@juicesharp/rpiv-i18n": {
82
+ "optional": true
83
+ }
84
+ },
85
+ "dependencies": {
86
+ "@juicesharp/rpiv-config": "^1.8.1"
87
+ }
85
88
  }