@hunsu/protocol 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/LICENSE +157 -0
- package/dist/command-decoder.d.ts +5 -0
- package/dist/command-decoder.js +329 -0
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +15 -0
- package/dist/decoder-helpers.d.ts +58 -0
- package/dist/decoder-helpers.js +1757 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.js +28 -0
- package/dist/event-decoder.d.ts +5 -0
- package/dist/event-decoder.js +232 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/lifecycle.d.ts +67 -0
- package/dist/lifecycle.js +271 -0
- package/dist/model.d.ts +1058 -0
- package/dist/model.js +1 -0
- package/dist/primitives.d.ts +59 -0
- package/dist/primitives.js +135 -0
- package/dist/projection.d.ts +8 -0
- package/dist/projection.js +875 -0
- package/dist/prompt-template.d.ts +12 -0
- package/dist/prompt-template.js +83 -0
- package/dist/protocol-validation.d.ts +36 -0
- package/dist/protocol-validation.js +1139 -0
- package/dist/result.d.ts +20 -0
- package/dist/result.js +21 -0
- package/dist/workflow-helpers.d.ts +31 -0
- package/dist/workflow-helpers.js +193 -0
- package/dist/workflow.d.ts +10 -0
- package/dist/workflow.js +594 -0
- package/package.json +30 -0
- package/src/command-decoder.ts +292 -0
- package/src/constants.ts +27 -0
- package/src/decoder-helpers.ts +1672 -0
- package/src/errors.ts +38 -0
- package/src/event-decoder.ts +225 -0
- package/src/index.ts +43 -0
- package/src/lifecycle.ts +403 -0
- package/src/model.ts +1233 -0
- package/src/primitives.ts +196 -0
- package/src/projection.ts +1081 -0
- package/src/prompt-template.ts +97 -0
- package/src/protocol-validation.ts +1252 -0
- package/src/result.ts +35 -0
- package/src/workflow-helpers.ts +239 -0
- package/src/workflow.ts +753 -0
package/dist/model.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type Result } from "./result.ts";
|
|
2
|
+
export type Brand<T, Name extends string> = T & {
|
|
3
|
+
readonly __brand: Name;
|
|
4
|
+
};
|
|
5
|
+
export type NonEmptyText = Brand<string, "NonEmptyText">;
|
|
6
|
+
export type RequestTitle = Brand<string, "RequestTitle">;
|
|
7
|
+
export type RequestGoal = Brand<string, "RequestGoal">;
|
|
8
|
+
export type DestinationTitle = Brand<string, "DestinationTitle">;
|
|
9
|
+
export type DestinationAcceptanceCriterion = Brand<string, "DestinationAcceptanceCriterion">;
|
|
10
|
+
export type DestinationConstraint = Brand<string, "DestinationConstraint">;
|
|
11
|
+
export type DestinationNotes = Brand<string, "DestinationNotes">;
|
|
12
|
+
export type Summary = Brand<string, "Summary">;
|
|
13
|
+
export type EvidenceText = Brand<string, "EvidenceText">;
|
|
14
|
+
export type FailureReason = Brand<string, "FailureReason">;
|
|
15
|
+
export type RiskText = Brand<string, "RiskText">;
|
|
16
|
+
export type MoveCommit = Brand<string, "MoveCommit">;
|
|
17
|
+
export type TeamName = Brand<string, "TeamName">;
|
|
18
|
+
export type PositiveInteger = Brand<number, "PositiveInteger">;
|
|
19
|
+
export type NonNegativeInteger = Brand<number, "NonNegativeInteger">;
|
|
20
|
+
export type NonEmptyArray<T> = [T, ...T[]];
|
|
21
|
+
export type SingleItemArray<T> = [T];
|
|
22
|
+
export type PrimitiveValidationError = {
|
|
23
|
+
type: "PrimitiveValidationError";
|
|
24
|
+
field: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
export declare function makeNonEmptyText(value: unknown, field?: string): Result<NonEmptyText, PrimitiveValidationError>;
|
|
28
|
+
export declare function makeRequestTitle(value: unknown): Result<RequestTitle, PrimitiveValidationError>;
|
|
29
|
+
export declare function makeRequestGoal(value: unknown): Result<RequestGoal, PrimitiveValidationError>;
|
|
30
|
+
export declare function makeDestinationTitle(value: unknown, field?: string): Result<DestinationTitle, PrimitiveValidationError>;
|
|
31
|
+
export declare function makeDestinationAcceptanceCriterion(value: unknown, field?: string): Result<DestinationAcceptanceCriterion, PrimitiveValidationError>;
|
|
32
|
+
export declare function makeDestinationConstraint(value: unknown, field?: string): Result<DestinationConstraint, PrimitiveValidationError>;
|
|
33
|
+
export declare function makeDestinationNotes(value: unknown, field?: string): Result<DestinationNotes, PrimitiveValidationError>;
|
|
34
|
+
export declare function makeSummary(value: unknown, field?: string): Result<Summary, PrimitiveValidationError>;
|
|
35
|
+
export declare function makeEvidenceText(value: unknown, field?: string): Result<EvidenceText, PrimitiveValidationError>;
|
|
36
|
+
export declare function makeFailureReason(value: unknown, field?: string): Result<FailureReason, PrimitiveValidationError>;
|
|
37
|
+
export declare function makeRiskText(value: unknown, field?: string): Result<RiskText, PrimitiveValidationError>;
|
|
38
|
+
export declare function makeMoveCommit(value: unknown, field?: string): Result<MoveCommit, PrimitiveValidationError>;
|
|
39
|
+
export declare function makeTeamName(value: unknown, field?: string): Result<TeamName, PrimitiveValidationError>;
|
|
40
|
+
export declare function makePositiveInteger(value: unknown, field?: string): Result<PositiveInteger, PrimitiveValidationError>;
|
|
41
|
+
export declare function makeNonNegativeInteger(value: unknown, field?: string): Result<NonNegativeInteger, PrimitiveValidationError>;
|
|
42
|
+
export declare function makeNonEmptyArray<T>(value: T[], field?: string): Result<NonEmptyArray<T>, PrimitiveValidationError>;
|
|
43
|
+
export declare function makeSingleItemArray<T>(value: T[], field?: string): Result<SingleItemArray<T>, PrimitiveValidationError>;
|
|
44
|
+
export declare function makeDomainId<T extends string>(value: unknown, field: string): Result<Brand<string, T>, PrimitiveValidationError>;
|
|
45
|
+
export declare function makeRequestId(value: unknown): Result<Brand<string, "RequestId">, PrimitiveValidationError>;
|
|
46
|
+
export declare function makeDestinationId(value: unknown): Result<Brand<string, "DestinationId">, PrimitiveValidationError>;
|
|
47
|
+
export declare function makeMoveId(value: unknown): Result<Brand<string, "MoveId">, PrimitiveValidationError>;
|
|
48
|
+
export declare function makeHunsuId(value: unknown): Result<Brand<string, "HunsuId">, PrimitiveValidationError>;
|
|
49
|
+
export declare function makeHunsuDraftId(value: unknown): Result<Brand<string, "HunsuDraftId">, PrimitiveValidationError>;
|
|
50
|
+
export declare function makeLineId(value: unknown): Result<Brand<string, "LineId">, PrimitiveValidationError>;
|
|
51
|
+
export declare function makeNodeId(value: unknown): Result<Brand<string, "NodeId">, PrimitiveValidationError>;
|
|
52
|
+
export declare function makeArtifactId(value: unknown): Result<Brand<string, "ArtifactId">, PrimitiveValidationError>;
|
|
53
|
+
export declare function makeArtifactActionId(value: unknown): Result<Brand<string, "ArtifactActionId">, PrimitiveValidationError>;
|
|
54
|
+
export declare function makeTeamId(value: unknown): Result<Brand<string, "TeamId">, PrimitiveValidationError>;
|
|
55
|
+
export declare function makeSkillDraftId(value: unknown): Result<Brand<string, "SkillDraftId">, PrimitiveValidationError>;
|
|
56
|
+
export declare function makeAgentConversationHash(value: unknown): Result<Brand<string, "AgentConversationHash">, PrimitiveValidationError>;
|
|
57
|
+
export declare function makeExecuteId(value: unknown): Result<Brand<string, "ExecuteId">, PrimitiveValidationError>;
|
|
58
|
+
export declare function makeRouteId(value: unknown): Result<Brand<string, "RouteId">, PrimitiveValidationError>;
|
|
59
|
+
export declare function makeWorktreeHash(value: unknown): Result<Brand<string, "WorktreeHash">, PrimitiveValidationError>;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { err, ok } from "./result.js";
|
|
2
|
+
export function makeNonEmptyText(value, field = "text") {
|
|
3
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
4
|
+
return invalid(field, `${field} must be a non-empty string`);
|
|
5
|
+
}
|
|
6
|
+
return ok(value);
|
|
7
|
+
}
|
|
8
|
+
export function makeRequestTitle(value) {
|
|
9
|
+
return makeTextBrand(value, "title");
|
|
10
|
+
}
|
|
11
|
+
export function makeRequestGoal(value) {
|
|
12
|
+
return makeTextBrand(value, "goal");
|
|
13
|
+
}
|
|
14
|
+
export function makeDestinationTitle(value, field = "title") {
|
|
15
|
+
return makeTextBrand(value, field);
|
|
16
|
+
}
|
|
17
|
+
export function makeDestinationAcceptanceCriterion(value, field = "acceptanceCriterion") {
|
|
18
|
+
return makeTextBrand(value, field);
|
|
19
|
+
}
|
|
20
|
+
export function makeDestinationConstraint(value, field = "constraint") {
|
|
21
|
+
return makeTextBrand(value, field);
|
|
22
|
+
}
|
|
23
|
+
export function makeDestinationNotes(value, field = "notes") {
|
|
24
|
+
return makeTextBrand(value, field);
|
|
25
|
+
}
|
|
26
|
+
export function makeSummary(value, field = "summary") {
|
|
27
|
+
return makeTextBrand(value, field);
|
|
28
|
+
}
|
|
29
|
+
export function makeEvidenceText(value, field = "evidence") {
|
|
30
|
+
return makeTextBrand(value, field);
|
|
31
|
+
}
|
|
32
|
+
export function makeFailureReason(value, field = "failureReason") {
|
|
33
|
+
return makeTextBrand(value, field);
|
|
34
|
+
}
|
|
35
|
+
export function makeRiskText(value, field = "risk") {
|
|
36
|
+
return makeTextBrand(value, field);
|
|
37
|
+
}
|
|
38
|
+
export function makeMoveCommit(value, field = "commit") {
|
|
39
|
+
return makeTextBrand(value, field);
|
|
40
|
+
}
|
|
41
|
+
export function makeTeamName(value, field = "teamName") {
|
|
42
|
+
return makeTextBrand(value, field);
|
|
43
|
+
}
|
|
44
|
+
export function makePositiveInteger(value, field = "number") {
|
|
45
|
+
if (!Number.isInteger(value) || Number(value) < 1) {
|
|
46
|
+
return invalid(field, `${field} must be a positive integer`);
|
|
47
|
+
}
|
|
48
|
+
return ok(value);
|
|
49
|
+
}
|
|
50
|
+
export function makeNonNegativeInteger(value, field = "number") {
|
|
51
|
+
if (!Number.isInteger(value) || Number(value) < 0) {
|
|
52
|
+
return invalid(field, `${field} must be a non-negative integer`);
|
|
53
|
+
}
|
|
54
|
+
return ok(value);
|
|
55
|
+
}
|
|
56
|
+
export function makeNonEmptyArray(value, field = "array") {
|
|
57
|
+
if (value.length === 0) {
|
|
58
|
+
return invalid(field, `${field} must include at least one item`);
|
|
59
|
+
}
|
|
60
|
+
return ok(value);
|
|
61
|
+
}
|
|
62
|
+
export function makeSingleItemArray(value, field = "array") {
|
|
63
|
+
if (value.length !== 1) {
|
|
64
|
+
return invalid(field, `${field} must include exactly one item`);
|
|
65
|
+
}
|
|
66
|
+
return ok(value);
|
|
67
|
+
}
|
|
68
|
+
export function makeDomainId(value, field) {
|
|
69
|
+
const text = makeNonEmptyText(value, field);
|
|
70
|
+
if (!text.ok) {
|
|
71
|
+
return text;
|
|
72
|
+
}
|
|
73
|
+
if (/\s/.test(text.value)) {
|
|
74
|
+
return invalid(field, `${field} must not contain whitespace`);
|
|
75
|
+
}
|
|
76
|
+
return ok(text.value);
|
|
77
|
+
}
|
|
78
|
+
export function makeRequestId(value) {
|
|
79
|
+
return makeDomainId(value, "requestId");
|
|
80
|
+
}
|
|
81
|
+
export function makeDestinationId(value) {
|
|
82
|
+
return makeDomainId(value, "destinationId");
|
|
83
|
+
}
|
|
84
|
+
export function makeMoveId(value) {
|
|
85
|
+
return makeDomainId(value, "moveId");
|
|
86
|
+
}
|
|
87
|
+
export function makeHunsuId(value) {
|
|
88
|
+
return makeDomainId(value, "hunsuId");
|
|
89
|
+
}
|
|
90
|
+
export function makeHunsuDraftId(value) {
|
|
91
|
+
return makeDomainId(value, "hunsuDraftId");
|
|
92
|
+
}
|
|
93
|
+
export function makeLineId(value) {
|
|
94
|
+
return makeDomainId(value, "lineId");
|
|
95
|
+
}
|
|
96
|
+
export function makeNodeId(value) {
|
|
97
|
+
return makeDomainId(value, "nodeId");
|
|
98
|
+
}
|
|
99
|
+
export function makeArtifactId(value) {
|
|
100
|
+
return makeDomainId(value, "artifactId");
|
|
101
|
+
}
|
|
102
|
+
export function makeArtifactActionId(value) {
|
|
103
|
+
return makeDomainId(value, "artifactActionId");
|
|
104
|
+
}
|
|
105
|
+
export function makeTeamId(value) {
|
|
106
|
+
return makeDomainId(value, "teamId");
|
|
107
|
+
}
|
|
108
|
+
export function makeSkillDraftId(value) {
|
|
109
|
+
return makeDomainId(value, "skillDraftId");
|
|
110
|
+
}
|
|
111
|
+
export function makeAgentConversationHash(value) {
|
|
112
|
+
return makeDomainId(value, "agentConversationHash");
|
|
113
|
+
}
|
|
114
|
+
export function makeExecuteId(value) {
|
|
115
|
+
return makeDomainId(value, "executeId");
|
|
116
|
+
}
|
|
117
|
+
export function makeRouteId(value) {
|
|
118
|
+
return makeDomainId(value, "routeId");
|
|
119
|
+
}
|
|
120
|
+
export function makeWorktreeHash(value) {
|
|
121
|
+
return makeDomainId(value, "worktreeHash");
|
|
122
|
+
}
|
|
123
|
+
function invalid(field, message) {
|
|
124
|
+
return err({ type: "PrimitiveValidationError", field, message });
|
|
125
|
+
}
|
|
126
|
+
function makeTextBrand(value, field) {
|
|
127
|
+
const text = makeNonEmptyText(value, field);
|
|
128
|
+
return text.ok ? ok(text.value) : text;
|
|
129
|
+
}
|
|
130
|
+
function makeStringBrand(value, field) {
|
|
131
|
+
if (typeof value !== "string") {
|
|
132
|
+
return invalid(field, `${field} must be a string`);
|
|
133
|
+
}
|
|
134
|
+
return ok(value);
|
|
135
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type DomainWorkflowError } from "./errors.ts";
|
|
2
|
+
import type { BoardProjection, DomainEvent } from "./model.ts";
|
|
3
|
+
import { type Result } from "./result.ts";
|
|
4
|
+
export declare function emptyBoardProjection(): BoardProjection;
|
|
5
|
+
export declare function projectBoard(events: DomainEvent[]): BoardProjection;
|
|
6
|
+
export declare function tryProjectBoard(events: DomainEvent[]): Result<BoardProjection, DomainWorkflowError>;
|
|
7
|
+
export declare function validateEventStream(events: DomainEvent[]): Result<DomainEvent[], DomainWorkflowError>;
|
|
8
|
+
export declare function projectEvent(state: BoardProjection, event: DomainEvent): BoardProjection;
|