@forgrit/shared-contracts-prompt 0.1.0

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 ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog — @forgrit/shared-contracts-prompt
2
+
3
+ ## [0.1.0] — 2026-05-26
4
+
5
+ ### Added — initial public release
6
+
7
+ - 29 type exports + 1 type alias + 1 runtime enum (ApprovalStatus) across 7 thematic sub-modules:
8
+ - `./scoring` — RequirementsScoreCard + DimensionScores
9
+ - `./features` — FeatureSpec, FeatureIntent
10
+ - `./entities` — EntityDefinition, EntityRelationship
11
+ - `./requirements` — RequirementsContractV2
12
+ - `./frozen` — FrozenPromptContract
13
+ - `./responses` — LLM response shapes
14
+ - `./quality` — quality-gate result shapes
15
+
16
+ ### Notes
17
+
18
+ - Source-of-truth reversal package: ForGrit's apps/api uses these via a 22-LOC wildcard re-export shim; the 396 LOC source lives here.
19
+ - Designed for ForGrit's prompt-engine pipeline. External consumers can use the types to build their own prompt-validation layer.
20
+ - Node 20+. Zero hard runtime deps; types-only at runtime except for the ApprovalStatus enum.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ForGrit AI <forgritai@gmail.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @forgrit/shared-contracts-prompt
2
+
3
+ > Type-only contracts for ForGrit prompt-engine surfaces — 29 type exports across 7 thematic sub-modules: scoring, features, entities, requirements, frozen, responses, quality.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@forgrit/shared-contracts-prompt.svg)](https://www.npmjs.com/package/@forgrit/shared-contracts-prompt)
6
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
7
+
8
+ > **Status: early-access (v0.x).** Internal-monorepo seam package. Pre-1.0 may include breaking changes in minor bumps.
9
+
10
+ Source-of-truth reversal package: ForGrit's `apps/api/src/prompt/` consumes these via a 22-LOC wildcard re-export shim; the 396 LOC source lives here.
11
+
12
+ ---
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @forgrit/shared-contracts-prompt
18
+ ```
19
+
20
+ Zero hard runtime deps (one runtime export: `ApprovalStatus` enum).
21
+
22
+ ## Sub-modules
23
+
24
+ ```ts
25
+ import { RequirementsScoreCard, DimensionScores } from '@forgrit/shared-contracts-prompt/scoring';
26
+ import { FeatureSpec, FeatureIntent } from '@forgrit/shared-contracts-prompt/features';
27
+ import { EntityDefinition, EntityRelationship } from '@forgrit/shared-contracts-prompt/entities';
28
+ import { RequirementsContractV2 } from '@forgrit/shared-contracts-prompt/requirements';
29
+ import { FrozenPromptContract } from '@forgrit/shared-contracts-prompt/frozen';
30
+ import {} from /* LLM response shapes */ '@forgrit/shared-contracts-prompt/responses';
31
+ import {} from /* quality-gate shapes */ '@forgrit/shared-contracts-prompt/quality';
32
+ ```
33
+
34
+ Or all from the root barrel:
35
+
36
+ ```ts
37
+ import {
38
+ RequirementsContractV2,
39
+ FeatureSpec,
40
+ ApprovalStatus,
41
+ } from '@forgrit/shared-contracts-prompt';
42
+ ```
43
+
44
+ ## License
45
+
46
+ MIT — see [LICENSE](./LICENSE).
47
+
48
+ ## Sibling packages
49
+
50
+ - [`@forgrit/contracts`](https://www.npmjs.com/package/@forgrit/contracts) — domain Zod schemas + types
51
+ - [`@forgrit/blueprint`](https://www.npmjs.com/package/@forgrit/blueprint) — app-spec format (consumes these contracts internally)
52
+ - [`@forgrit/shared-contracts-platform`](https://www.npmjs.com/package/@forgrit/shared-contracts-platform)
53
+ - [`@forgrit/shared-contracts-jobs-queue`](https://www.npmjs.com/package/@forgrit/shared-contracts-jobs-queue)
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @forgrit/shared-contracts-prompt — FOREIGN TYPE FRAGMENTS.
3
+ *
4
+ * Plan #5.04 (2026-05-25) — these 2 string unions are DUPLICATED from
5
+ * apps/api/src/preview/app-blueprint.types.ts. They are NOT re-exports;
6
+ * they are inline mirrors.
7
+ *
8
+ * Why duplicated:
9
+ * - prompt-contract.types.ts uses ProjectType + StyleIntent as field
10
+ * types on RequirementsContractV2 + UiIntentSpec.
11
+ * - The contract package CANNOT import from apps/api/src/* per §1A.b.
12
+ * - Contracting app-blueprint.types itself is out of scope here
13
+ * (zero lifecycle consumers today per T1 §4; 19 apps/api consumers).
14
+ * - The two unions are small (11 + 12 = 23 strings), stable (no
15
+ * changes in 6-8 months), and pure enum-style discriminators.
16
+ *
17
+ * Drift discipline: any change to ProjectType / StyleIntent in
18
+ * apps/api/src/preview/app-blueprint.types.ts MUST update this file in
19
+ * the same commit. README documents the reviewer checklist + the
20
+ * grep-gate one-liner. When a future plan extracts
21
+ * @forgrit/shared-contracts-app-blueprint, this file flips from
22
+ * duplicate to re-export (2-line edit; no consumer-side change).
23
+ *
24
+ * Plan #5.04 chose this path (Option A) over Option C (extend scope
25
+ * to contract app-blueprint.types) because the latter would force a
26
+ * STYLE_INTENT_LABELS runtime-value escape hatch + 9-property
27
+ * AppBlueprintContract interface tree that prompt-contract consumers
28
+ * do not need. Option B (apps/api re-export proxy) was rejected as a
29
+ * §1A.b violation (it creates apps/api → contract → apps/api cycle).
30
+ */
31
+ export type ProjectType = 'admin' | 'crm' | 'analytics' | 'commerce' | 'content' | 'collab' | 'saas' | 'public' | 'finance' | 'hr' | 'healthcare';
32
+ export type StyleIntent = 'modern_minimal' | 'enterprise_conservative' | 'neo_banking' | 'glassmorphism' | 'brutalist' | 'editorial_magazine' | 'playful_round' | 'dark_terminal' | 'vibrant_gradient' | 'luxury_serif' | 'retro_soft' | 'developer_docs';
33
+ //# sourceMappingURL=app-blueprint-fragments.d.ts.map
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * @forgrit/shared-contracts-prompt — FOREIGN TYPE FRAGMENTS.
4
+ *
5
+ * Plan #5.04 (2026-05-25) — these 2 string unions are DUPLICATED from
6
+ * apps/api/src/preview/app-blueprint.types.ts. They are NOT re-exports;
7
+ * they are inline mirrors.
8
+ *
9
+ * Why duplicated:
10
+ * - prompt-contract.types.ts uses ProjectType + StyleIntent as field
11
+ * types on RequirementsContractV2 + UiIntentSpec.
12
+ * - The contract package CANNOT import from apps/api/src/* per §1A.b.
13
+ * - Contracting app-blueprint.types itself is out of scope here
14
+ * (zero lifecycle consumers today per T1 §4; 19 apps/api consumers).
15
+ * - The two unions are small (11 + 12 = 23 strings), stable (no
16
+ * changes in 6-8 months), and pure enum-style discriminators.
17
+ *
18
+ * Drift discipline: any change to ProjectType / StyleIntent in
19
+ * apps/api/src/preview/app-blueprint.types.ts MUST update this file in
20
+ * the same commit. README documents the reviewer checklist + the
21
+ * grep-gate one-liner. When a future plan extracts
22
+ * @forgrit/shared-contracts-app-blueprint, this file flips from
23
+ * duplicate to re-export (2-line edit; no consumer-side change).
24
+ *
25
+ * Plan #5.04 chose this path (Option A) over Option C (extend scope
26
+ * to contract app-blueprint.types) because the latter would force a
27
+ * STYLE_INTENT_LABELS runtime-value escape hatch + 9-property
28
+ * AppBlueprintContract interface tree that prompt-contract consumers
29
+ * do not need. Option B (apps/api re-export proxy) was rejected as a
30
+ * §1A.b violation (it creates apps/api → contract → apps/api cycle).
31
+ */
32
+ Object.defineProperty(exports, "__esModule", { value: true });
33
+ //# sourceMappingURL=app-blueprint-fragments.js.map
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Role + entity surfaces.
3
+ *
4
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:152-180.
5
+ *
6
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
7
+ */
8
+ export interface RoleDefinition {
9
+ /** Stable snake_case identifier derived deterministically from name (e.g. "admin", "end_user") */
10
+ id: string;
11
+ name: string;
12
+ description: string;
13
+ }
14
+ /** Extended entity field with type information (used by Blueprint Engine and Validator) */
15
+ export interface TypedEntityField {
16
+ name: string;
17
+ type: string;
18
+ required: boolean;
19
+ }
20
+ export interface EntityDefinition {
21
+ /** Stable snake_case identifier derived deterministically from name (e.g. "lead", "order_item") */
22
+ id: string;
23
+ name: string;
24
+ fields: TypedEntityField[];
25
+ relationships: string[];
26
+ }
27
+ /** Extended entity definition with typed fields (used by Blueprint Engine) */
28
+ export interface TypedEntityDefinition extends EntityDefinition {
29
+ typedFields?: TypedEntityField[];
30
+ isCoreCrud?: boolean;
31
+ }
32
+ //# sourceMappingURL=entities.d.ts.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Role + entity surfaces.
4
+ *
5
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:152-180.
6
+ *
7
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=entities.js.map
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Feature + integration surfaces.
3
+ *
4
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:45-58, 182-217.
5
+ *
6
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
7
+ * Subsumes the plan #5.5 wave-2 FM-G bridge surface — after T7, the
8
+ * bridge file `_prompt-contract-types.ts` becomes a 2-line re-export
9
+ * from THIS module's `FeatureIntent` + `FeatureSpec` exports.
10
+ */
11
+ export interface FeatureGraph {
12
+ core: FeatureNode[];
13
+ advanced: FeatureNode[];
14
+ integrations: FeatureNode[];
15
+ dependencies: Record<string, string[]>;
16
+ }
17
+ export interface FeatureNode {
18
+ id: string;
19
+ name: string;
20
+ complexity: 'simple' | 'moderate' | 'complex';
21
+ estimatedScreens: number;
22
+ }
23
+ /**
24
+ * Feature intent — what the user actually DOES with this feature.
25
+ * Drives screen archetype selection, content templates, and budget weighting.
26
+ * Distinct from `type` (scope category): type = what it is, intent = how it's used.
27
+ */
28
+ export type FeatureIntent = 'crud' | 'analytics' | 'workflow' | 'notification' | 'security' | 'integration' | 'marketplace';
29
+ export interface FeatureSpec {
30
+ id: string;
31
+ name: string;
32
+ type: 'core' | 'advanced' | 'integration';
33
+ /** UX/planning intent — determines screen archetype, not just scope category */
34
+ intent?: FeatureIntent;
35
+ /** Classifier confidence 0-1. Used to gate LLM fallback. */
36
+ intentConfidence?: number;
37
+ /** How intent was determined: 'rule' (deterministic) or 'llm' (fallback) */
38
+ intentSource?: 'rule' | 'llm';
39
+ priority: 'MVP' | 'Next';
40
+ acceptanceCriteria: string[];
41
+ dependsOn: string[];
42
+ }
43
+ export interface IntegrationSpec {
44
+ provider: string;
45
+ purpose: string;
46
+ authMethod: string;
47
+ dataIn: string;
48
+ dataOut: string;
49
+ }
50
+ //# sourceMappingURL=features.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * Feature + integration surfaces.
4
+ *
5
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:45-58, 182-217.
6
+ *
7
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
8
+ * Subsumes the plan #5.5 wave-2 FM-G bridge surface — after T7, the
9
+ * bridge file `_prompt-contract-types.ts` becomes a 2-line re-export
10
+ * from THIS module's `FeatureIntent` + `FeatureSpec` exports.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=features.js.map
@@ -0,0 +1,53 @@
1
+ import type { DimensionScores, ScoringExplanation, RiskProfile } from './scoring';
2
+ import type { FeatureGraph } from './features';
3
+ import type { RequirementsContractV2 } from './requirements';
4
+ import type { RequirementsQuality } from './quality';
5
+ /**
6
+ * Frozen-prompt + combined-final-contract surfaces.
7
+ *
8
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:60-98, 388-396.
9
+ *
10
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
11
+ */
12
+ export interface PromptContract {
13
+ score: number;
14
+ scoringExplanation?: ScoringExplanation;
15
+ criticalGaps?: string[];
16
+ missingDetails?: string[];
17
+ missingFields?: string[];
18
+ dimensionScores: DimensionScores;
19
+ summary?: string;
20
+ recommendations?: string[];
21
+ riskProfile?: RiskProfile;
22
+ featureGraph?: FeatureGraph;
23
+ }
24
+ export interface FrozenPrompt {
25
+ promptId: string;
26
+ version: number;
27
+ hash: string;
28
+ originalPrompt: string;
29
+ contract: PromptContract;
30
+ requirementsContractV2?: RequirementsContractV2;
31
+ status: string;
32
+ frozenAt: string;
33
+ metadata: {
34
+ sessionId: string;
35
+ attempts: number;
36
+ score: number;
37
+ dimensionScores: DimensionScores;
38
+ };
39
+ }
40
+ export interface ExamplePrompt {
41
+ title: string;
42
+ prompt: string;
43
+ expectedScore: number;
44
+ category?: string;
45
+ }
46
+ export interface CombinedFinalContract {
47
+ promptScoreContract: PromptContract;
48
+ requirementsContractV2: RequirementsContractV2 | null;
49
+ requirementsQuality: RequirementsQuality | null;
50
+ /** SHA-256 of the normalized RequirementsContractV2 (excluding openQuestions). Stable across re-runs of equivalent prompts. */
51
+ requirementsHash: string | null;
52
+ }
53
+ //# sourceMappingURL=frozen.d.ts.map
package/dist/frozen.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=frozen.js.map
@@ -0,0 +1,9 @@
1
+ export * from './scoring';
2
+ export * from './features';
3
+ export * from './entities';
4
+ export * from './requirements';
5
+ export * from './quality';
6
+ export * from './frozen';
7
+ export * from './responses';
8
+ export * from './_external/app-blueprint-fragments';
9
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ // @forgrit/shared-contracts-prompt — public surface.
3
+ //
4
+ // Plan #5.04 (2026-05-25) — fourth contract package, sibling to
5
+ // @forgrit/shared-contracts-platform (plan #4.4),
6
+ // @forgrit/shared-contracts-design-composition (plans #4.55 + #4.57),
7
+ // and @forgrit/shared-contracts-jobs-queue (plan #5.05).
8
+ //
9
+ // Surface (29 exports across 7 thematic sub-modules):
10
+ // - scoring.ts: DimensionScores, ScoringExplanation, RiskProfile
11
+ // - features.ts: FeatureGraph, FeatureNode, FeatureIntent, FeatureSpec, IntegrationSpec
12
+ // - entities.ts: RoleDefinition, TypedEntityField, EntityDefinition, TypedEntityDefinition
13
+ // - requirements.ts: NfrSpec, UiIntentSpec, OpenQuestion, BuildTargetSuggestion, RequirementsContractV2
14
+ // - quality.ts: ContentBlueprint, KpiDefinition, NavSection, RequirementsQuality
15
+ // - frozen.ts: PromptContract, FrozenPrompt, ExamplePrompt, CombinedFinalContract
16
+ // - responses.ts: ApprovalStatus (enum — the ONE runtime export),
17
+ // FrozenPromptResponse, PromptSessionResponse, PromptAnalysisResponse
18
+ //
19
+ // Foreign types (DUPLICATED, see _external/app-blueprint-fragments.ts):
20
+ // - ProjectType, StyleIntent — mirrored from apps/api/src/preview/app-blueprint.types
21
+ //
22
+ // Sub-path exports are preferred for tree-shaking. The root barrel
23
+ // exists for convenience + for the apps/api re-export shim (T6).
24
+ //
25
+ // No dependency on @forgrit/shared-contracts-platform OR
26
+ // @forgrit/shared-contracts-design-composition OR
27
+ // @forgrit/shared-contracts-jobs-queue — orthogonal surfaces.
28
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
29
+ if (k2 === undefined) k2 = k;
30
+ var desc = Object.getOwnPropertyDescriptor(m, k);
31
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
32
+ desc = { enumerable: true, get: function() { return m[k]; } };
33
+ }
34
+ Object.defineProperty(o, k2, desc);
35
+ }) : (function(o, m, k, k2) {
36
+ if (k2 === undefined) k2 = k;
37
+ o[k2] = m[k];
38
+ }));
39
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
40
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
41
+ };
42
+ Object.defineProperty(exports, "__esModule", { value: true });
43
+ __exportStar(require("./scoring"), exports);
44
+ __exportStar(require("./features"), exports);
45
+ __exportStar(require("./entities"), exports);
46
+ __exportStar(require("./requirements"), exports);
47
+ __exportStar(require("./quality"), exports);
48
+ __exportStar(require("./frozen"), exports);
49
+ __exportStar(require("./responses"), exports);
50
+ // Foreign types — duplicated under documented drift discipline.
51
+ __exportStar(require("./_external/app-blueprint-fragments"), exports);
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Content blueprint + quality scoring surfaces.
3
+ *
4
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:331-386.
5
+ *
6
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
7
+ */
8
+ export interface ContentBlueprint {
9
+ /** One compelling, domain-specific tagline (max 10 words) */
10
+ productTagline?: string;
11
+ /** 3-5 short feature labels derived from features list */
12
+ featureHighlights?: string[];
13
+ /** Realistic social proof statement */
14
+ socialProofLine?: string;
15
+ /** Trust signals relevant to domain */
16
+ trustSignals?: string[];
17
+ /** 4-6 key metrics for dashboards */
18
+ kpiDefinitions?: KpiDefinition[];
19
+ /** Realistic sample names per entity */
20
+ sampleEntityNames?: Record<string, string[]>;
21
+ /** Status labels for entity lifecycle */
22
+ statusLabels?: string[];
23
+ /** Navigation items matching features + entities */
24
+ navSections?: NavSection[];
25
+ /** Domain-specific CTA (e.g., "Log Workout" not "Create") */
26
+ primaryActionLabel?: string;
27
+ /** Contextual search hint */
28
+ searchPlaceholder?: string;
29
+ /** Friendly empty state message for main entity */
30
+ emptyStateMessage?: string;
31
+ /** Dashboard greeting */
32
+ welcomeMessage?: string;
33
+ }
34
+ export interface KpiDefinition {
35
+ label: string;
36
+ format: 'currency' | 'number' | 'percentage' | 'duration';
37
+ context: 'primary' | 'secondary' | 'trend';
38
+ }
39
+ export interface NavSection {
40
+ label: string;
41
+ category: 'main' | 'admin' | 'settings';
42
+ }
43
+ export interface RequirementsQuality {
44
+ /** 0–100 composite quality score */
45
+ score: number;
46
+ /** 0–100: % of required top-level fields that are non-empty */
47
+ completeness: number;
48
+ /** 0–100: % of required open questions still unanswered */
49
+ ambiguity: number;
50
+ /** Non-blocking quality notes */
51
+ warnings: string[];
52
+ /** Critical missing fields that will degrade the design output */
53
+ blockers: string[];
54
+ /** Suggestions for improving the prompt (from missing Tier 3 fields) */
55
+ suggestions?: string[];
56
+ }
57
+ //# sourceMappingURL=quality.d.ts.map
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ /**
3
+ * Content blueprint + quality scoring surfaces.
4
+ *
5
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:331-386.
6
+ *
7
+ * Plan #5.04 (2026-05-25): contracted. Source-of-truth reversal at T6.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ //# sourceMappingURL=quality.js.map
@@ -0,0 +1,85 @@
1
+ import type { ProjectType, StyleIntent } from './_external/app-blueprint-fragments';
2
+ import type { RoleDefinition, EntityDefinition } from './entities';
3
+ import type { FeatureSpec, IntegrationSpec } from './features';
4
+ import type { ContentBlueprint } from './quality';
5
+ /**
6
+ * Requirements + UI intent + meta surfaces.
7
+ *
8
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:219-329.
9
+ *
10
+ * Note on _external/app-blueprint-fragments: ProjectType + StyleIntent
11
+ * are duplicated from apps/api/src/preview/app-blueprint.types per plan
12
+ * #5.04 "ProjectType + StyleIntent decision" (Option A). Drift discipline
13
+ * in _external/app-blueprint-fragments.ts JSDoc + README.
14
+ */
15
+ export interface NfrSpec {
16
+ performanceTarget?: string;
17
+ securityLevel: 'basic' | 'standard' | 'high';
18
+ complianceFlags: Array<'HIPAA' | 'GDPR' | 'PCI' | 'SOC2'>;
19
+ deploymentPreference: 'cloud' | 'self_host' | 'hybrid' | 'unknown';
20
+ }
21
+ export interface UiIntentSpec {
22
+ navigationPreference: 'sidebar' | 'topbar' | 'split' | 'auto';
23
+ densityPreference: 'compact' | 'comfortable' | 'spacious';
24
+ styleIntent: StyleIntent;
25
+ /** Brand personality — how the product feels emotionally. */
26
+ brandTone?: 'professional' | 'friendly' | 'bold' | 'calm' | 'playful';
27
+ /** Primary color mood / palette preference. */
28
+ colorMood?: 'neutral' | 'warm' | 'cool' | 'vibrant' | 'monochrome';
29
+ /** Typography personality. */
30
+ typography?: 'geometric' | 'humanist' | 'slab' | 'mono' | 'serif';
31
+ }
32
+ /**
33
+ * Input type for a clarification question.
34
+ * `single_select` → radio buttons (suggestedAnswers required)
35
+ * `multi_select` → checkboxes (suggestedAnswers required)
36
+ * `short_text` → free-text input (suggestedAnswers empty)
37
+ * `yes_no` → boolean toggle (suggestedAnswers empty)
38
+ *
39
+ * `type` defaults to 'single_select' when suggestedAnswers is non-empty,
40
+ * 'short_text' otherwise — so existing questions without a type work correctly.
41
+ *
42
+ * `mapsTo` is an optional dotted-path hint for deterministic field patching:
43
+ * e.g. 'authMethods', 'nfrs.securityLevel', 'uiIntent.styleIntent'.
44
+ * When present, the answer endpoint can apply the patch without text-search heuristics.
45
+ */
46
+ export interface OpenQuestion {
47
+ id: string;
48
+ question: string;
49
+ suggestedAnswers: string[];
50
+ required: boolean;
51
+ /** How to render the answer UI. Defaults based on suggestedAnswers length. */
52
+ type?: 'single_select' | 'multi_select' | 'short_text' | 'yes_no';
53
+ /** Dotted path in RequirementsContractV2 this answer should patch. */
54
+ mapsTo?: string;
55
+ }
56
+ export interface BuildTargetSuggestion {
57
+ suggestedBuildTarget: 'web-app' | 'backend-api' | 'full-stack' | 'smart-contract';
58
+ suggestedStack: string;
59
+ confidence: number;
60
+ reasons: string[];
61
+ }
62
+ export interface RequirementsContractV2 {
63
+ version: 2;
64
+ projectName: string;
65
+ tagline: string;
66
+ projectType: ProjectType;
67
+ mvpGoals: string[];
68
+ outOfScope: string[];
69
+ successMetrics?: string[];
70
+ roles: RoleDefinition[];
71
+ permissionMatrix: Record<string, string[]>;
72
+ authRequired: boolean;
73
+ authMethods: Array<'password' | 'magic_link' | 'sso' | 'mfa' | 'google_oauth' | 'github_oauth' | 'apple_oauth' | 'email'>;
74
+ entities: EntityDefinition[];
75
+ primaryEntity: string;
76
+ seedDataHints?: string[];
77
+ features: FeatureSpec[];
78
+ integrations: IntegrationSpec[];
79
+ nfrs: NfrSpec;
80
+ uiIntent: UiIntentSpec;
81
+ openQuestions: OpenQuestion[];
82
+ buildTargetSuggestion?: BuildTargetSuggestion;
83
+ contentBlueprint?: ContentBlueprint;
84
+ }
85
+ //# sourceMappingURL=requirements.d.ts.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=requirements.js.map
@@ -0,0 +1,68 @@
1
+ import type { PromptContract } from './frozen';
2
+ import type { RequirementsContractV2 } from './requirements';
3
+ import type { RequirementsQuality } from './quality';
4
+ /**
5
+ * Response-shaped surfaces for the prompt API.
6
+ *
7
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:100-150.
8
+ *
9
+ * THIS MODULE CONTAINS THE ONE RUNTIME EXPORT IN THE PACKAGE — the
10
+ * ApprovalStatus enum (4-variant string enum). It is the 2nd discrete
11
+ * runtime export precedent in the @forgrit/shared-contracts-* family
12
+ * after plan #4.55's variantDecisionKey. README documents the
13
+ * escape-hatch policy.
14
+ *
15
+ * Source-of-truth reversal at T6 means this enum lives canonically in
16
+ * THIS file; apps/api/src/prompt/schemas/prompt-contract.types.ts
17
+ * re-exports it via wildcard `export *`. The 5 apps/api consumers of
18
+ * ApprovalStatus.APPROVED / NEEDS_FORM / DRAFT / FAILED resolve to the
19
+ * same string values they always have — no behavior change.
20
+ */
21
+ export declare enum ApprovalStatus {
22
+ APPROVED = "APPROVED",
23
+ NEEDS_FORM = "NEEDS_FORM",
24
+ DRAFT = "DRAFT",
25
+ FAILED = "FAILED"
26
+ }
27
+ export interface FrozenPromptResponse {
28
+ promptId: string;
29
+ sessionId: string;
30
+ finalPrompt: string;
31
+ originalPrompt: string;
32
+ contract: PromptContract;
33
+ requirementsContractV2?: RequirementsContractV2;
34
+ requirementsQuality?: RequirementsQuality;
35
+ requirementsHash?: string;
36
+ /** Budget confidence 0..1 — derived from RequirementsContractV2 + RequirementsQuality */
37
+ budgetConfidence?: number;
38
+ /** Human-readable notes explaining confidence gaps */
39
+ confidenceNotes?: string[];
40
+ score: number;
41
+ version: number;
42
+ frozenAt: string;
43
+ parentPromptId: string | null;
44
+ diffSummary: string | null;
45
+ }
46
+ export interface PromptSessionResponse {
47
+ sessionId: string;
48
+ originalPrompt: string;
49
+ attempts: number;
50
+ createdAt: string;
51
+ analyses: PromptAnalysisResponse[];
52
+ }
53
+ export interface PromptAnalysisResponse {
54
+ status: ApprovalStatus;
55
+ attempt: number;
56
+ promptId: string | null;
57
+ contractDraft: PromptContract;
58
+ nextActions: string[];
59
+ metadata: {
60
+ sessionId: string;
61
+ modelUsed: string;
62
+ temperature: number;
63
+ tokensUsed: number;
64
+ latencyMs: number;
65
+ timestamp: string;
66
+ };
67
+ }
68
+ //# sourceMappingURL=responses.d.ts.map
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApprovalStatus = void 0;
4
+ /**
5
+ * Response-shaped surfaces for the prompt API.
6
+ *
7
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:100-150.
8
+ *
9
+ * THIS MODULE CONTAINS THE ONE RUNTIME EXPORT IN THE PACKAGE — the
10
+ * ApprovalStatus enum (4-variant string enum). It is the 2nd discrete
11
+ * runtime export precedent in the @forgrit/shared-contracts-* family
12
+ * after plan #4.55's variantDecisionKey. README documents the
13
+ * escape-hatch policy.
14
+ *
15
+ * Source-of-truth reversal at T6 means this enum lives canonically in
16
+ * THIS file; apps/api/src/prompt/schemas/prompt-contract.types.ts
17
+ * re-exports it via wildcard `export *`. The 5 apps/api consumers of
18
+ * ApprovalStatus.APPROVED / NEEDS_FORM / DRAFT / FAILED resolve to the
19
+ * same string values they always have — no behavior change.
20
+ */
21
+ // Existing ApprovalStatus enum
22
+ var ApprovalStatus;
23
+ (function (ApprovalStatus) {
24
+ ApprovalStatus["APPROVED"] = "APPROVED";
25
+ ApprovalStatus["NEEDS_FORM"] = "NEEDS_FORM";
26
+ ApprovalStatus["DRAFT"] = "DRAFT";
27
+ ApprovalStatus["FAILED"] = "FAILED";
28
+ })(ApprovalStatus || (exports.ApprovalStatus = ApprovalStatus = {}));
29
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Scoring + risk surfaces for PromptContract.
3
+ *
4
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:6-43.
5
+ *
6
+ * Plan #5.04 (2026-05-25): contracted so lifecycle/* consumers can
7
+ * satisfy §1A.b without importing from apps/api/src/prompt/schemas at
8
+ * runtime. Source-of-truth reversal at T6: apps/api source becomes
9
+ * 1-line re-export from this package.
10
+ */
11
+ export interface DimensionScores {
12
+ appType: number;
13
+ actors: number;
14
+ features: number;
15
+ dataDomain: number;
16
+ technicalStack: number;
17
+ nfrs: number;
18
+ uiExpectations: number;
19
+ integrations: number;
20
+ }
21
+ export interface ScoringExplanation {
22
+ rawScore: number;
23
+ normalizedScore: number;
24
+ maxRawScore: number;
25
+ breakdown: Array<{
26
+ dimension: string;
27
+ score: number;
28
+ weight: number;
29
+ contribution: number;
30
+ }>;
31
+ }
32
+ export interface RiskProfile {
33
+ scopeRisk: 'low' | 'medium' | 'high';
34
+ complianceRisk: boolean;
35
+ securityRisk: 'low' | 'medium' | 'high';
36
+ costVolatilityRisk: number;
37
+ riskFactors: string[];
38
+ }
39
+ //# sourceMappingURL=scoring.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ /**
3
+ * Scoring + risk surfaces for PromptContract.
4
+ *
5
+ * MIRRORED FROM: apps/api/src/prompt/schemas/prompt-contract.types.ts:6-43.
6
+ *
7
+ * Plan #5.04 (2026-05-25): contracted so lifecycle/* consumers can
8
+ * satisfy §1A.b without importing from apps/api/src/prompt/schemas at
9
+ * runtime. Source-of-truth reversal at T6: apps/api source becomes
10
+ * 1-line re-export from this package.
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ //# sourceMappingURL=scoring.js.map
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@forgrit/shared-contracts-prompt",
3
+ "version": "0.1.0",
4
+ "description": "Type-only contracts for ForGrit prompt-engine surfaces — 7 sub-modules: scoring, features, entities, requirements, frozen, responses, quality.",
5
+ "keywords": [
6
+ "contracts",
7
+ "types",
8
+ "prompt-engine",
9
+ "scoring",
10
+ "features",
11
+ "entities",
12
+ "requirements",
13
+ "forgrit"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "ForGrit AI <forgritai@gmail.com>",
17
+ "homepage": "https://github.com/forgrit-ai/forgrit/tree/main/shared/contracts-prompt",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/forgrit-ai/forgrit.git",
21
+ "directory": "shared/contracts-prompt"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/forgrit-ai/forgrit/issues"
25
+ },
26
+ "main": "./dist/index.js",
27
+ "types": "./dist/index.d.ts",
28
+ "exports": {
29
+ ".": {
30
+ "types": "./dist/index.d.ts",
31
+ "default": "./dist/index.js"
32
+ },
33
+ "./scoring": {
34
+ "types": "./dist/scoring.d.ts",
35
+ "default": "./dist/scoring.js"
36
+ },
37
+ "./features": {
38
+ "types": "./dist/features.d.ts",
39
+ "default": "./dist/features.js"
40
+ },
41
+ "./entities": {
42
+ "types": "./dist/entities.d.ts",
43
+ "default": "./dist/entities.js"
44
+ },
45
+ "./requirements": {
46
+ "types": "./dist/requirements.d.ts",
47
+ "default": "./dist/requirements.js"
48
+ },
49
+ "./frozen": {
50
+ "types": "./dist/frozen.d.ts",
51
+ "default": "./dist/frozen.js"
52
+ },
53
+ "./responses": {
54
+ "types": "./dist/responses.d.ts",
55
+ "default": "./dist/responses.js"
56
+ },
57
+ "./quality": {
58
+ "types": "./dist/quality.d.ts",
59
+ "default": "./dist/quality.js"
60
+ }
61
+ },
62
+ "files": [
63
+ "dist/**/*.js",
64
+ "dist/**/*.d.ts",
65
+ "README.md",
66
+ "CHANGELOG.md",
67
+ "LICENSE"
68
+ ],
69
+ "publishConfig": {
70
+ "access": "public",
71
+ "registry": "https://registry.npmjs.org/"
72
+ },
73
+ "engines": {
74
+ "node": ">=20.0.0"
75
+ },
76
+ "devDependencies": {
77
+ "typescript": "^5.3.3",
78
+ "@forgrit/tsconfig": "0.1.0"
79
+ },
80
+ "scripts": {
81
+ "build": "tsc -p tsconfig.json",
82
+ "check": "tsc --noEmit -p tsconfig.json"
83
+ }
84
+ }