ex-workflow 0.0.0-stage → 0.2.0-stage
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 +24 -0
- package/LICENSE +21 -0
- package/README.md +153 -2
- package/dist/adapters/index.cjs +2 -0
- package/dist/adapters/index.cjs.map +1 -0
- package/dist/adapters/index.d.cts +17 -0
- package/dist/adapters/index.d.ts +17 -0
- package/dist/adapters/index.mjs +2 -0
- package/dist/adapters/index.mjs.map +1 -0
- package/dist/chunk-2FRRD6A3.mjs +2 -0
- package/dist/chunk-2FRRD6A3.mjs.map +1 -0
- package/dist/chunk-472WEDPJ.cjs +2 -0
- package/dist/chunk-472WEDPJ.cjs.map +1 -0
- package/dist/chunk-6R3YFUUV.cjs +6 -0
- package/dist/chunk-6R3YFUUV.cjs.map +1 -0
- package/dist/chunk-D4HNETUL.cjs +2 -0
- package/dist/chunk-D4HNETUL.cjs.map +1 -0
- package/dist/chunk-DBR24RTX.cjs +2 -0
- package/dist/chunk-DBR24RTX.cjs.map +1 -0
- package/dist/chunk-IBRC36PE.mjs +2 -0
- package/dist/chunk-IBRC36PE.mjs.map +1 -0
- package/dist/chunk-JDVE7DQR.cjs +2 -0
- package/dist/chunk-JDVE7DQR.cjs.map +1 -0
- package/dist/chunk-KIQOUUEZ.mjs +2 -0
- package/dist/chunk-KIQOUUEZ.mjs.map +1 -0
- package/dist/chunk-NQU5TH3A.mjs +2 -0
- package/dist/chunk-NQU5TH3A.mjs.map +1 -0
- package/dist/chunk-NRAPI3GV.cjs +2 -0
- package/dist/chunk-NRAPI3GV.cjs.map +1 -0
- package/dist/chunk-PD5FBDN7.mjs +2 -0
- package/dist/chunk-PD5FBDN7.mjs.map +1 -0
- package/dist/chunk-PO2SPQJP.cjs +2 -0
- package/dist/chunk-PO2SPQJP.cjs.map +1 -0
- package/dist/chunk-QDT35LXB.cjs +2 -0
- package/dist/chunk-QDT35LXB.cjs.map +1 -0
- package/dist/chunk-S3BXVHO7.cjs +2 -0
- package/dist/chunk-S3BXVHO7.cjs.map +1 -0
- package/dist/chunk-VGD4V5BA.mjs +6 -0
- package/dist/chunk-VGD4V5BA.mjs.map +1 -0
- package/dist/chunk-VN2UYV2O.mjs +2 -0
- package/dist/chunk-VN2UYV2O.mjs.map +1 -0
- package/dist/chunk-XSXHEEJX.mjs +2 -0
- package/dist/chunk-XSXHEEJX.mjs.map +1 -0
- package/dist/chunk-YJNDBKIG.mjs +2 -0
- package/dist/chunk-YJNDBKIG.mjs.map +1 -0
- package/dist/cli/bin.cjs +5 -0
- package/dist/cli/bin.cjs.map +1 -0
- package/dist/cli/bin.d.cts +1 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.mjs +5 -0
- package/dist/cli/bin.mjs.map +1 -0
- package/dist/cli/index.cjs +2 -0
- package/dist/cli/index.cjs.map +1 -0
- package/dist/cli/index.d.cts +13 -0
- package/dist/cli/index.d.ts +13 -0
- package/dist/cli/index.mjs +2 -0
- package/dist/cli/index.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +134 -0
- package/dist/index.d.ts +134 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kanban/index.cjs +2 -0
- package/dist/kanban/index.cjs.map +1 -0
- package/dist/kanban/index.d.cts +225 -0
- package/dist/kanban/index.d.ts +225 -0
- package/dist/kanban/index.mjs +2 -0
- package/dist/kanban/index.mjs.map +1 -0
- package/dist/roles-BLBRKhUZ.d.ts +14 -0
- package/dist/roles-aneKYJ3Z.d.cts +14 -0
- package/dist/scrum/index.cjs +2 -0
- package/dist/scrum/index.cjs.map +1 -0
- package/dist/scrum/index.d.cts +59 -0
- package/dist/scrum/index.d.ts +59 -0
- package/dist/scrum/index.mjs +2 -0
- package/dist/scrum/index.mjs.map +1 -0
- package/dist/types.cjs +2 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +330 -0
- package/dist/types.d.ts +330 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +146 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ErrorCode, WorkflowState, MethodologyName, Stage, Role, Event, WorkItem, Evidence, NewItem, ItemStatus, Policy, Violation, Gate, Transition, PendingHuman, Budget, Accounting, Iteration, Methodology, Brief, Handoff, ApplyResult, Rule, Action } from './types.cjs';
|
|
2
|
+
export { Baseline, Blocker, Capability, Ceremony, CeremonyInput, ClassOfService, CoreTerm, GateRequirement, ItemType, Lesson, LessonChange, ModelTier, Phase, PlannerOptions, Verdict } from './types.cjs';
|
|
3
|
+
export { a as approversFor, c as canDo, h as hasCapability, r as registerRole, b as requireCap, d as requireCapabilities, e as retireRole, f as rolesWith, s as separationLost } from './roles-aneKYJ3Z.cjs';
|
|
4
|
+
import { ExNode } from 'ex-flow';
|
|
5
|
+
|
|
6
|
+
interface WorkflowErrorExtra {
|
|
7
|
+
items?: string[];
|
|
8
|
+
rule?: string;
|
|
9
|
+
}
|
|
10
|
+
declare class WorkflowError extends Error {
|
|
11
|
+
readonly code: ErrorCode;
|
|
12
|
+
readonly fix: string;
|
|
13
|
+
readonly items?: string[];
|
|
14
|
+
readonly rule?: string;
|
|
15
|
+
constructor(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra);
|
|
16
|
+
toJSON(): {
|
|
17
|
+
code: ErrorCode;
|
|
18
|
+
message: string;
|
|
19
|
+
fix: string;
|
|
20
|
+
items?: string[];
|
|
21
|
+
rule?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare function fail(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra): never;
|
|
25
|
+
/** Ids become object keys and file names: letters, digits, `.`, `_`, `-`; no `..`, no prototype names. */
|
|
26
|
+
declare function assertId(id: unknown, what: string): void;
|
|
27
|
+
|
|
28
|
+
declare function nowOf(now?: string): string;
|
|
29
|
+
interface CreateStateInput {
|
|
30
|
+
methodology: MethodologyName;
|
|
31
|
+
config: unknown;
|
|
32
|
+
stages: Stage[];
|
|
33
|
+
roles: Role[];
|
|
34
|
+
now?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function createState(input: CreateStateInput): WorkflowState;
|
|
37
|
+
declare function appendEvent(state: WorkflowState, type: string, by: string, payload: unknown, now?: string): WorkflowState;
|
|
38
|
+
declare function lastEvent(state: WorkflowState, type?: string): Event | undefined;
|
|
39
|
+
|
|
40
|
+
declare function stageOf(state: WorkflowState, stageId: string): Stage;
|
|
41
|
+
declare function nextStageOf(state: WorkflowState, stageId: string): Stage | undefined;
|
|
42
|
+
declare function isTerminalStage(state: WorkflowState, stageId: string): boolean;
|
|
43
|
+
declare function getItem(state: WorkflowState, id: string): WorkItem;
|
|
44
|
+
declare function addItem(state: WorkflowState, input: NewItem, by: string, now?: string): WorkflowState;
|
|
45
|
+
type ItemPatch = Partial<Omit<WorkItem, "id" | "stage" | "status" | "transitions" | "evidence" | "blockers">>;
|
|
46
|
+
declare function editItem(state: WorkflowState, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState;
|
|
47
|
+
declare function moveItem(state: WorkflowState, id: string, to: {
|
|
48
|
+
stage?: string;
|
|
49
|
+
status: ItemStatus;
|
|
50
|
+
}, by: string, now?: string): WorkflowState;
|
|
51
|
+
declare function addEvidence(state: WorkflowState, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState;
|
|
52
|
+
declare function raiseBlocker(state: WorkflowState, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState;
|
|
53
|
+
declare function clearBlocker(state: WorkflowState, id: string, blockerId: string, by: string, now?: string): WorkflowState;
|
|
54
|
+
|
|
55
|
+
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
56
|
+
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
57
|
+
|
|
58
|
+
type GateResult = {
|
|
59
|
+
outcome: "pass";
|
|
60
|
+
} | {
|
|
61
|
+
outcome: "human";
|
|
62
|
+
} | {
|
|
63
|
+
outcome: "fail";
|
|
64
|
+
violations: Violation[];
|
|
65
|
+
};
|
|
66
|
+
/** Last in_progress dispatch made from a stage that comes STRICTLY BEFORE the item's current stage in `state.stages` order (unknown stage ids count as not-before). */
|
|
67
|
+
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
68
|
+
/** Role that did the work the gate guards: the last dispatch made from a stage strictly before the current one (so a reviewer dispatched into the gated stage is not its author); else the last dispatch of any stage; undefined if never dispatched. */
|
|
69
|
+
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
70
|
+
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
71
|
+
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
72
|
+
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string): WorkflowState;
|
|
73
|
+
|
|
74
|
+
declare const ZERO_SPENT: Required<Budget>;
|
|
75
|
+
declare function addSpent(spent: Required<Budget>, acc: Accounting): Required<Budget>;
|
|
76
|
+
declare function remaining(budget: Budget, spent: Required<Budget>): Budget;
|
|
77
|
+
declare function isExhausted(budget: Budget, spent: Required<Budget>): boolean;
|
|
78
|
+
declare function estimateTokens(state: WorkflowState, weight: number | undefined, fallbackPerWeight?: number): number;
|
|
79
|
+
|
|
80
|
+
type NodeData = {
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
84
|
+
declare function assignRole(state: WorkflowState, item: WorkItem): Role;
|
|
85
|
+
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
86
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined): ExNode<NodeData>[];
|
|
87
|
+
interface PlanOptions {
|
|
88
|
+
max?: number;
|
|
89
|
+
now?: string;
|
|
90
|
+
fallbackTokensPerWeight?: number;
|
|
91
|
+
}
|
|
92
|
+
type PlanReason = "no-candidates" | "budget-exhausted" | "wip-full" | "policy-blocked";
|
|
93
|
+
/** A ready item the planner did not pull, and why. */
|
|
94
|
+
interface Skipped {
|
|
95
|
+
id: string;
|
|
96
|
+
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
97
|
+
detail: string;
|
|
98
|
+
}
|
|
99
|
+
interface PlanResult {
|
|
100
|
+
state: WorkflowState;
|
|
101
|
+
dispatched: WorkItem[];
|
|
102
|
+
skipped: Skipped[];
|
|
103
|
+
reason?: PlanReason;
|
|
104
|
+
}
|
|
105
|
+
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
106
|
+
|
|
107
|
+
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
108
|
+
interface NextResult {
|
|
109
|
+
state: WorkflowState;
|
|
110
|
+
briefs: Brief[];
|
|
111
|
+
skipped: Skipped[];
|
|
112
|
+
reason?: PlanReason;
|
|
113
|
+
}
|
|
114
|
+
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
115
|
+
|
|
116
|
+
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
117
|
+
|
|
118
|
+
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
119
|
+
|
|
120
|
+
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
121
|
+
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
122
|
+
interface InitInput<C> {
|
|
123
|
+
methodology: Methodology<C>;
|
|
124
|
+
config: unknown;
|
|
125
|
+
roles?: Role[];
|
|
126
|
+
stages?: Stage[];
|
|
127
|
+
by?: string;
|
|
128
|
+
now?: string;
|
|
129
|
+
}
|
|
130
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
131
|
+
|
|
132
|
+
declare const VERSION = "0.2.0-stage";
|
|
133
|
+
|
|
134
|
+
export { Accounting, Action, ApplyResult, Brief, Budget, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, type ItemPatch, ItemStatus, Iteration, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, ZERO_SPENT, addEvidence, addItem, addSpent, appendEvent, applyAction, assertId, assertPolicies, assignRole, authorOf, checkGate, clearBlocker, complete, coreRulesFor, createState, decide, editItem, estimateTokens, evaluatePolicies, fail, getItem, init, isExhausted, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, plan, raiseBlocker, raisePending, remaining, resourceCapsFor, stageOf, synthesizeBrief, toExNodes, validateAction };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { ErrorCode, WorkflowState, MethodologyName, Stage, Role, Event, WorkItem, Evidence, NewItem, ItemStatus, Policy, Violation, Gate, Transition, PendingHuman, Budget, Accounting, Iteration, Methodology, Brief, Handoff, ApplyResult, Rule, Action } from './types.js';
|
|
2
|
+
export { Baseline, Blocker, Capability, Ceremony, CeremonyInput, ClassOfService, CoreTerm, GateRequirement, ItemType, Lesson, LessonChange, ModelTier, Phase, PlannerOptions, Verdict } from './types.js';
|
|
3
|
+
export { a as approversFor, c as canDo, h as hasCapability, r as registerRole, b as requireCap, d as requireCapabilities, e as retireRole, f as rolesWith, s as separationLost } from './roles-BLBRKhUZ.js';
|
|
4
|
+
import { ExNode } from 'ex-flow';
|
|
5
|
+
|
|
6
|
+
interface WorkflowErrorExtra {
|
|
7
|
+
items?: string[];
|
|
8
|
+
rule?: string;
|
|
9
|
+
}
|
|
10
|
+
declare class WorkflowError extends Error {
|
|
11
|
+
readonly code: ErrorCode;
|
|
12
|
+
readonly fix: string;
|
|
13
|
+
readonly items?: string[];
|
|
14
|
+
readonly rule?: string;
|
|
15
|
+
constructor(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra);
|
|
16
|
+
toJSON(): {
|
|
17
|
+
code: ErrorCode;
|
|
18
|
+
message: string;
|
|
19
|
+
fix: string;
|
|
20
|
+
items?: string[];
|
|
21
|
+
rule?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
declare function fail(code: ErrorCode, message: string, fix: string, extra?: WorkflowErrorExtra): never;
|
|
25
|
+
/** Ids become object keys and file names: letters, digits, `.`, `_`, `-`; no `..`, no prototype names. */
|
|
26
|
+
declare function assertId(id: unknown, what: string): void;
|
|
27
|
+
|
|
28
|
+
declare function nowOf(now?: string): string;
|
|
29
|
+
interface CreateStateInput {
|
|
30
|
+
methodology: MethodologyName;
|
|
31
|
+
config: unknown;
|
|
32
|
+
stages: Stage[];
|
|
33
|
+
roles: Role[];
|
|
34
|
+
now?: string;
|
|
35
|
+
}
|
|
36
|
+
declare function createState(input: CreateStateInput): WorkflowState;
|
|
37
|
+
declare function appendEvent(state: WorkflowState, type: string, by: string, payload: unknown, now?: string): WorkflowState;
|
|
38
|
+
declare function lastEvent(state: WorkflowState, type?: string): Event | undefined;
|
|
39
|
+
|
|
40
|
+
declare function stageOf(state: WorkflowState, stageId: string): Stage;
|
|
41
|
+
declare function nextStageOf(state: WorkflowState, stageId: string): Stage | undefined;
|
|
42
|
+
declare function isTerminalStage(state: WorkflowState, stageId: string): boolean;
|
|
43
|
+
declare function getItem(state: WorkflowState, id: string): WorkItem;
|
|
44
|
+
declare function addItem(state: WorkflowState, input: NewItem, by: string, now?: string): WorkflowState;
|
|
45
|
+
type ItemPatch = Partial<Omit<WorkItem, "id" | "stage" | "status" | "transitions" | "evidence" | "blockers">>;
|
|
46
|
+
declare function editItem(state: WorkflowState, id: string, patch: ItemPatch, by: string, now?: string): WorkflowState;
|
|
47
|
+
declare function moveItem(state: WorkflowState, id: string, to: {
|
|
48
|
+
stage?: string;
|
|
49
|
+
status: ItemStatus;
|
|
50
|
+
}, by: string, now?: string): WorkflowState;
|
|
51
|
+
declare function addEvidence(state: WorkflowState, id: string, evidence: Omit<Evidence, "at">, now?: string): WorkflowState;
|
|
52
|
+
declare function raiseBlocker(state: WorkflowState, id: string, reason: string, owner: string, by: string, now?: string): WorkflowState;
|
|
53
|
+
declare function clearBlocker(state: WorkflowState, id: string, blockerId: string, by: string, now?: string): WorkflowState;
|
|
54
|
+
|
|
55
|
+
declare function evaluatePolicies(state: WorkflowState, item: WorkItem, policies: Policy[]): Violation[];
|
|
56
|
+
declare function assertPolicies(state: WorkflowState, item: WorkItem, policies: Policy[], context: string): void;
|
|
57
|
+
|
|
58
|
+
type GateResult = {
|
|
59
|
+
outcome: "pass";
|
|
60
|
+
} | {
|
|
61
|
+
outcome: "human";
|
|
62
|
+
} | {
|
|
63
|
+
outcome: "fail";
|
|
64
|
+
violations: Violation[];
|
|
65
|
+
};
|
|
66
|
+
/** Last in_progress dispatch made from a stage that comes STRICTLY BEFORE the item's current stage in `state.stages` order (unknown stage ids count as not-before). */
|
|
67
|
+
declare function lastDispatchBefore(state: WorkflowState, item: WorkItem): Transition | undefined;
|
|
68
|
+
/** Role that did the work the gate guards: the last dispatch made from a stage strictly before the current one (so a reviewer dispatched into the gated stage is not its author); else the last dispatch of any stage; undefined if never dispatched. */
|
|
69
|
+
declare function authorOf(state: WorkflowState, item: WorkItem): string | undefined;
|
|
70
|
+
declare function checkGate(state: WorkflowState, item: WorkItem, gate: Gate, by: string): GateResult;
|
|
71
|
+
declare function raisePending(state: WorkflowState, pending: Omit<PendingHuman, "id" | "raisedAt">, now?: string): WorkflowState;
|
|
72
|
+
declare function decide(state: WorkflowState, pendingId: string, decision: "approve" | "reject", by: string, note: string, now?: string): WorkflowState;
|
|
73
|
+
|
|
74
|
+
declare const ZERO_SPENT: Required<Budget>;
|
|
75
|
+
declare function addSpent(spent: Required<Budget>, acc: Accounting): Required<Budget>;
|
|
76
|
+
declare function remaining(budget: Budget, spent: Required<Budget>): Budget;
|
|
77
|
+
declare function isExhausted(budget: Budget, spent: Required<Budget>): boolean;
|
|
78
|
+
declare function estimateTokens(state: WorkflowState, weight: number | undefined, fallbackPerWeight?: number): number;
|
|
79
|
+
|
|
80
|
+
type NodeData = {
|
|
81
|
+
id: string;
|
|
82
|
+
};
|
|
83
|
+
declare function openIteration(state: WorkflowState): Iteration | undefined;
|
|
84
|
+
declare function assignRole(state: WorkflowState, item: WorkItem): Role;
|
|
85
|
+
declare function resourceCapsFor(state: WorkflowState): Record<string, number>;
|
|
86
|
+
declare function toExNodes(items: WorkItem[], state: WorkflowState, priorityOf?: (item: WorkItem) => number | undefined): ExNode<NodeData>[];
|
|
87
|
+
interface PlanOptions {
|
|
88
|
+
max?: number;
|
|
89
|
+
now?: string;
|
|
90
|
+
fallbackTokensPerWeight?: number;
|
|
91
|
+
}
|
|
92
|
+
type PlanReason = "no-candidates" | "budget-exhausted" | "wip-full" | "policy-blocked";
|
|
93
|
+
/** A ready item the planner did not pull, and why. */
|
|
94
|
+
interface Skipped {
|
|
95
|
+
id: string;
|
|
96
|
+
reason: "entry-policy" | "wip" | "resource-cap" | "budget";
|
|
97
|
+
detail: string;
|
|
98
|
+
}
|
|
99
|
+
interface PlanResult {
|
|
100
|
+
state: WorkflowState;
|
|
101
|
+
dispatched: WorkItem[];
|
|
102
|
+
skipped: Skipped[];
|
|
103
|
+
reason?: PlanReason;
|
|
104
|
+
}
|
|
105
|
+
declare function plan(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): PlanResult;
|
|
106
|
+
|
|
107
|
+
declare function synthesizeBrief(state: WorkflowState, methodology: Methodology, item: WorkItem): Brief;
|
|
108
|
+
interface NextResult {
|
|
109
|
+
state: WorkflowState;
|
|
110
|
+
briefs: Brief[];
|
|
111
|
+
skipped: Skipped[];
|
|
112
|
+
reason?: PlanReason;
|
|
113
|
+
}
|
|
114
|
+
declare function next(state: WorkflowState, methodology: Methodology, opts?: PlanOptions): NextResult;
|
|
115
|
+
|
|
116
|
+
declare function complete(state: WorkflowState, methodology: Methodology, handoff: Handoff, acc: Accounting, now?: string): ApplyResult;
|
|
117
|
+
|
|
118
|
+
declare function coreRulesFor(methodology: Pick<Methodology, "requiredCapabilities">): Rule[];
|
|
119
|
+
|
|
120
|
+
declare function validateAction(state: WorkflowState, methodology: Methodology, action: Action): Violation[];
|
|
121
|
+
declare function applyAction(state: WorkflowState, methodology: Methodology, action: Action, reduce: (s: WorkflowState) => WorkflowState): ApplyResult;
|
|
122
|
+
interface InitInput<C> {
|
|
123
|
+
methodology: Methodology<C>;
|
|
124
|
+
config: unknown;
|
|
125
|
+
roles?: Role[];
|
|
126
|
+
stages?: Stage[];
|
|
127
|
+
by?: string;
|
|
128
|
+
now?: string;
|
|
129
|
+
}
|
|
130
|
+
declare function init<C>(input: InitInput<C>): ApplyResult;
|
|
131
|
+
|
|
132
|
+
declare const VERSION = "0.2.0-stage";
|
|
133
|
+
|
|
134
|
+
export { Accounting, Action, ApplyResult, Brief, Budget, ErrorCode, Event, Evidence, Gate, type GateResult, Handoff, type InitInput, type ItemPatch, ItemStatus, Iteration, Methodology, MethodologyName, NewItem, type NextResult, PendingHuman, type PlanOptions, type PlanReason, type PlanResult, Policy, Role, Rule, type Skipped, Stage, Transition, VERSION, Violation, WorkItem, WorkflowError, WorkflowState, ZERO_SPENT, addEvidence, addItem, addSpent, appendEvent, applyAction, assertId, assertPolicies, assignRole, authorOf, checkGate, clearBlocker, complete, coreRulesFor, createState, decide, editItem, estimateTokens, evaluatePolicies, fail, getItem, init, isExhausted, isTerminalStage, lastDispatchBefore, lastEvent, moveItem, next, nextStageOf, nowOf, openIteration, plan, raiseBlocker, raisePending, remaining, resourceCapsFor, stageOf, synthesizeBrief, toExNodes, validateAction };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import'./chunk-KIQOUUEZ.mjs';export{c as complete,b as next,a as synthesizeBrief}from'./chunk-VN2UYV2O.mjs';export{a as ZERO_SPENT,b as addSpent,g as assignRole,e as estimateTokens,d as isExhausted,f as openIteration,j as plan,c as remaining,h as resourceCapsFor,i as toExNodes}from'./chunk-PD5FBDN7.mjs';export{y as addEvidence,v as addItem,c as appendEvent,M as applyAction,k as approversFor,E as assertPolicies,G as authorOf,n as canDo,H as checkGate,A as clearBlocker,K as coreRulesFor,b as createState,J as decide,w as editItem,D as evaluatePolicies,u as getItem,h as hasCapability,N as init,r as isTerminalStage,F as lastDispatchBefore,d as lastEvent,x as moveItem,q as nextStageOf,a as nowOf,z as raiseBlocker,I as raisePending,f as registerRole,o as requireCap,l as requireCapabilities,g as retireRole,i as rolesWith,m as separationLost,p as stageOf,L as validateAction}from'./chunk-NQU5TH3A.mjs';export{a as WorkflowError,c as assertId,b as fail}from'./chunk-2FRRD6A3.mjs';var U="0.2.0-stage";export{U as VERSION};//# sourceMappingURL=index.mjs.map
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["VERSION"],"mappings":"s9BAAO,IAAMA,CAAAA,CAAU","file":"index.mjs","sourcesContent":["export const VERSION = \"0.2.0-stage\";\nexport * from \"./types.ts\";\nexport { WorkflowError, fail } from \"./errors.ts\";\nexport { createState, appendEvent, lastEvent, nowOf } from \"./state.ts\";\nexport {\n registerRole,\n retireRole,\n hasCapability,\n rolesWith,\n approversFor,\n requireCapabilities,\n separationLost,\n canDo,\n requireCap,\n} from \"./roles.ts\";\nexport {\n assertId,\n stageOf,\n nextStageOf,\n isTerminalStage,\n getItem,\n addItem,\n editItem,\n moveItem,\n addEvidence,\n raiseBlocker,\n clearBlocker,\n} from \"./items.ts\";\nexport type { ItemPatch } from \"./items.ts\";\nexport { evaluatePolicies, assertPolicies } from \"./policies.ts\";\nexport { checkGate, authorOf, lastDispatchBefore, raisePending, decide } from \"./gates.ts\";\nexport type { GateResult } from \"./gates.ts\";\nexport { ZERO_SPENT, addSpent, remaining, isExhausted, estimateTokens } from \"./budget.ts\";\nexport { plan, toExNodes, assignRole, resourceCapsFor, openIteration } from \"./planner.ts\";\nexport type { PlanOptions, PlanReason, PlanResult, Skipped } from \"./planner.ts\";\nexport { synthesizeBrief, next } from \"./brief.ts\";\nexport type { NextResult } from \"./brief.ts\";\nexport { complete } from \"./complete.ts\";\nexport { coreRulesFor } from \"./rules.ts\";\nexport { applyAction, validateAction, init } from \"./methodology.ts\";\nexport type { InitInput } from \"./methodology.ts\";\n"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkD4HNETUL_cjs=require('../chunk-D4HNETUL.cjs');require('../chunk-JDVE7DQR.cjs'),require('../chunk-S3BXVHO7.cjs');Object.defineProperty(exports,"ACTIVE",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.a}});Object.defineProperty(exports,"CADENCE_EVENT",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.s}});Object.defineProperty(exports,"CLASSES",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.k}});Object.defineProperty(exports,"DAY_MS",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.l}});Object.defineProperty(exports,"DEFAULT_COLUMNS",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.n}});Object.defineProperty(exports,"KANBAN_CADENCES",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.j}});Object.defineProperty(exports,"KANBAN_VOCABULARY",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.F}});Object.defineProperty(exports,"OPEN",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.b}});Object.defineProperty(exports,"activeExpedites",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.h}});Object.defineProperty(exports,"addedAt",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.p}});Object.defineProperty(exports,"board",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.r}});Object.defineProperty(exports,"byClassThenAge",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.H}});Object.defineProperty(exports,"cadencesDue",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.t}});Object.defineProperty(exports,"cardAge",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.q}});Object.defineProperty(exports,"columnIndex",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.f}});Object.defineProperty(exports,"columnStays",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.w}});Object.defineProperty(exports,"commitmentColumn",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.d}});Object.defineProperty(exports,"configOf",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.m}});Object.defineProperty(exports,"deliveryColumn",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.e}});Object.defineProperty(exports,"enteredStageAt",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.i}});Object.defineProperty(exports,"kanban",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.I}});Object.defineProperty(exports,"kanbanCeremonies",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.B}});Object.defineProperty(exports,"kanbanMetrics",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.x}});Object.defineProperty(exports,"kanbanRoles",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.C}});Object.defineProperty(exports,"kanbanRules",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.D}});Object.defineProperty(exports,"kanbanStages",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.E}});Object.defineProperty(exports,"onBoard",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.g}});Object.defineProperty(exports,"opsReport",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.y}});Object.defineProperty(exports,"optionsColumn",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.c}});Object.defineProperty(exports,"percentile",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.v}});Object.defineProperty(exports,"priorityByClass",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.G}});Object.defineProperty(exports,"replay",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.u}});Object.defineProperty(exports,"riskReport",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.z}});Object.defineProperty(exports,"validateKanbanConfig",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.o}});Object.defineProperty(exports,"wantItems",{enumerable:true,get:function(){return chunkD4HNETUL_cjs.A}});//# sourceMappingURL=index.cjs.map
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { ClassOfService, Policy, WorkflowState, Role, Stage, Rule, Methodology, Ceremony, CeremonyInput, ItemStatus, WorkItem, Event, CoreTerm } from '../types.cjs';
|
|
2
|
+
|
|
3
|
+
type KanbanCadence = "replenishment" | "delivery-planning" | "service-delivery-review" | "operations-review" | "risk-review" | "strategy-review";
|
|
4
|
+
declare const KANBAN_CADENCES: readonly KanbanCadence[];
|
|
5
|
+
declare const CLASSES: readonly ClassOfService[];
|
|
6
|
+
declare const DAY_MS = 86400000;
|
|
7
|
+
interface KanbanColumn {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
wipLimit?: number;
|
|
11
|
+
/** Explicit policies a card must satisfy before it LEAVES the column (checked by complete()). */
|
|
12
|
+
policies: Policy[];
|
|
13
|
+
commitmentPoint?: boolean;
|
|
14
|
+
deliveryPoint?: boolean;
|
|
15
|
+
/** Cards entering this column wait for a reviewer (status "review"). */
|
|
16
|
+
review?: boolean;
|
|
17
|
+
}
|
|
18
|
+
interface ServiceLevel {
|
|
19
|
+
percentile: number;
|
|
20
|
+
targetMs: number;
|
|
21
|
+
}
|
|
22
|
+
interface ClassConfig {
|
|
23
|
+
wipBypass?: number;
|
|
24
|
+
sle?: ServiceLevel;
|
|
25
|
+
}
|
|
26
|
+
interface KanbanConfig {
|
|
27
|
+
columns: KanbanColumn[];
|
|
28
|
+
classesOfService: Partial<Record<ClassOfService, ClassConfig>>;
|
|
29
|
+
fairness: {
|
|
30
|
+
aging: boolean;
|
|
31
|
+
maxDeferralRounds: number;
|
|
32
|
+
};
|
|
33
|
+
cadences: Partial<Record<KanbanCadence, {
|
|
34
|
+
everyTurns?: number;
|
|
35
|
+
}>>;
|
|
36
|
+
throughputWindowMs: number;
|
|
37
|
+
maxExpedite: number;
|
|
38
|
+
}
|
|
39
|
+
declare function configOf(state: WorkflowState): KanbanConfig;
|
|
40
|
+
declare const DEFAULT_COLUMNS: KanbanColumn[];
|
|
41
|
+
declare function validateKanbanConfig(raw: unknown): KanbanConfig;
|
|
42
|
+
|
|
43
|
+
declare function kanbanRoles(): Role[];
|
|
44
|
+
|
|
45
|
+
declare function kanbanStages(config: KanbanConfig): Stage[];
|
|
46
|
+
|
|
47
|
+
declare function kanbanRules(): Rule[];
|
|
48
|
+
|
|
49
|
+
/** input.items as a non-empty, duplicate-free string[] of existing item ids. */
|
|
50
|
+
declare function wantItems(state: WorkflowState, input: CeremonyInput, cadence: string): string[];
|
|
51
|
+
declare function kanbanCeremonies(methodology: () => Methodology): Record<string, Ceremony>;
|
|
52
|
+
|
|
53
|
+
/** Statuses that hold a WIP slot. */
|
|
54
|
+
declare const ACTIVE: ReadonlySet<ItemStatus>;
|
|
55
|
+
/** Every status but done and dropped: the cards on the board. */
|
|
56
|
+
declare const OPEN: ReadonlySet<ItemStatus>;
|
|
57
|
+
declare function optionsColumn(state: WorkflowState): Stage;
|
|
58
|
+
declare function commitmentColumn(state: WorkflowState): Stage;
|
|
59
|
+
declare function deliveryColumn(state: WorkflowState): Stage;
|
|
60
|
+
declare function columnIndex(state: WorkflowState, stageId: string): number;
|
|
61
|
+
/** Committed and not yet delivered: column index in [commitment, delivery). */
|
|
62
|
+
declare function onBoard(state: WorkflowState, item: WorkItem): boolean;
|
|
63
|
+
declare function activeExpedites(state: WorkflowState): string[];
|
|
64
|
+
/** ISO time the item last entered its current column; undefined when it was added there and never moved. */
|
|
65
|
+
declare function enteredStageAt(item: WorkItem): string | undefined;
|
|
66
|
+
|
|
67
|
+
interface BoardCard {
|
|
68
|
+
id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
type: string;
|
|
71
|
+
status: ItemStatus;
|
|
72
|
+
classOfService: string;
|
|
73
|
+
role: string | null;
|
|
74
|
+
ageMs: number;
|
|
75
|
+
blocked: boolean;
|
|
76
|
+
deadline: string | null;
|
|
77
|
+
}
|
|
78
|
+
interface BoardColumn {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
wipLimit: number | null;
|
|
82
|
+
active: number;
|
|
83
|
+
queued: number;
|
|
84
|
+
overLimit: boolean;
|
|
85
|
+
commitmentPoint: boolean;
|
|
86
|
+
deliveryPoint: boolean;
|
|
87
|
+
cards: BoardCard[];
|
|
88
|
+
}
|
|
89
|
+
/** Time the item was added (its item.added event), else the first event's time. */
|
|
90
|
+
declare function addedAt(state: WorkflowState, id: string): string;
|
|
91
|
+
declare function cardAge(state: WorkflowState, item: WorkItem, now: string): number;
|
|
92
|
+
declare function board(state: WorkflowState, now: string): BoardColumn[];
|
|
93
|
+
declare const CADENCE_EVENT: (c: KanbanCadence) => string;
|
|
94
|
+
interface CadenceStatus {
|
|
95
|
+
cadence: KanbanCadence;
|
|
96
|
+
everyTurns: number | null;
|
|
97
|
+
lastAt: string | null;
|
|
98
|
+
turnsSince: number;
|
|
99
|
+
due: boolean;
|
|
100
|
+
}
|
|
101
|
+
declare function cadencesDue(state: WorkflowState): CadenceStatus[];
|
|
102
|
+
|
|
103
|
+
interface OpsReport {
|
|
104
|
+
blockers: Array<{
|
|
105
|
+
item: string;
|
|
106
|
+
blocker: string;
|
|
107
|
+
owner: string;
|
|
108
|
+
reason: string;
|
|
109
|
+
ageMs: number;
|
|
110
|
+
}>;
|
|
111
|
+
agingWip: Array<{
|
|
112
|
+
item: string;
|
|
113
|
+
column: string;
|
|
114
|
+
status: string;
|
|
115
|
+
ageMs: number;
|
|
116
|
+
p85Ms: number | null;
|
|
117
|
+
overP85: boolean;
|
|
118
|
+
}>;
|
|
119
|
+
queued: Record<string, number>;
|
|
120
|
+
active: Record<string, number>;
|
|
121
|
+
}
|
|
122
|
+
declare function opsReport(state: WorkflowState, now: string): OpsReport;
|
|
123
|
+
interface RiskReport {
|
|
124
|
+
fixedDate: Array<{
|
|
125
|
+
item: string;
|
|
126
|
+
deadline: string;
|
|
127
|
+
timeLeftMs: number;
|
|
128
|
+
projectedRemainingMs: number | null;
|
|
129
|
+
atRisk: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
staleBlockers: Array<{
|
|
132
|
+
item: string;
|
|
133
|
+
blocker: string;
|
|
134
|
+
owner: string;
|
|
135
|
+
ageMs: number;
|
|
136
|
+
}>;
|
|
137
|
+
expediteActive: string[];
|
|
138
|
+
}
|
|
139
|
+
declare function riskReport(state: WorkflowState, now: string, staleAfterMs: number): RiskReport;
|
|
140
|
+
|
|
141
|
+
interface Stay {
|
|
142
|
+
stage: string;
|
|
143
|
+
enteredAt: string;
|
|
144
|
+
leftAt?: string;
|
|
145
|
+
}
|
|
146
|
+
interface ReplayedItem {
|
|
147
|
+
id: string;
|
|
148
|
+
/** item type from item.added; "question" items are escalations, not deliveries */
|
|
149
|
+
type: string;
|
|
150
|
+
stage: string;
|
|
151
|
+
status: ItemStatus;
|
|
152
|
+
/** one entry per contiguous visit to a column; status changes inside a column do not end a stay */
|
|
153
|
+
stays: Stay[];
|
|
154
|
+
/** first entry into the commitment column */
|
|
155
|
+
committedAt?: string;
|
|
156
|
+
/** first entry into the delivery column */
|
|
157
|
+
deliveredAt?: string;
|
|
158
|
+
/** from the replenishment payload; "standard" when never replenished */
|
|
159
|
+
classOfService: ClassOfService;
|
|
160
|
+
deadline?: string;
|
|
161
|
+
/** closed in_progress intervals */
|
|
162
|
+
activeMs: number;
|
|
163
|
+
/** closed blocked intervals */
|
|
164
|
+
blockedMs: number;
|
|
165
|
+
/** the open status interval */
|
|
166
|
+
since: {
|
|
167
|
+
status: ItemStatus;
|
|
168
|
+
at: string;
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
interface ReplayedBlocker {
|
|
172
|
+
item: string;
|
|
173
|
+
blocker: string;
|
|
174
|
+
raisedAt: string;
|
|
175
|
+
clearedAt?: string;
|
|
176
|
+
}
|
|
177
|
+
interface Replay {
|
|
178
|
+
items: Map<string, ReplayedItem>;
|
|
179
|
+
blockers: ReplayedBlocker[];
|
|
180
|
+
/** time of the last event: the clock every "still open" measurement uses */
|
|
181
|
+
lastAt: string;
|
|
182
|
+
}
|
|
183
|
+
declare function replay(events: Event[], commitment: string, delivery: string): Replay;
|
|
184
|
+
|
|
185
|
+
interface KanbanMetrics {
|
|
186
|
+
leadTimeMs: number[];
|
|
187
|
+
leadTimeP50: number;
|
|
188
|
+
leadTimeP85: number;
|
|
189
|
+
cycleTimeMsByColumn: Record<string, number>;
|
|
190
|
+
throughput: number[];
|
|
191
|
+
wipByColumn: Record<string, number>;
|
|
192
|
+
flowEfficiency: number;
|
|
193
|
+
agingWipMs: Record<string, number>;
|
|
194
|
+
cumulativeFlow: Record<string, number>;
|
|
195
|
+
sleCompliance: Record<string, number>;
|
|
196
|
+
blockerTimeMs: number;
|
|
197
|
+
meanBlockerTimeMs: number;
|
|
198
|
+
}
|
|
199
|
+
/** Nearest-rank percentile; 0 for an empty list. */
|
|
200
|
+
declare function percentile(values: number[], p: number): number;
|
|
201
|
+
/** Completed stay durations per column. */
|
|
202
|
+
declare function columnStays(state: WorkflowState): Record<string, number[]>;
|
|
203
|
+
declare function kanbanMetrics(state: WorkflowState): KanbanMetrics;
|
|
204
|
+
|
|
205
|
+
declare const KANBAN_VOCABULARY: Record<CoreTerm, string>;
|
|
206
|
+
|
|
207
|
+
/** What the priority function needs besides the card: how long it has been passed over, and the fairness config. */
|
|
208
|
+
interface PriorityContext {
|
|
209
|
+
/** next() rounds that resolved since the card entered its column */
|
|
210
|
+
deferrals: number;
|
|
211
|
+
aging: boolean;
|
|
212
|
+
maxDeferralRounds: number;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Class band x 1e15 + an in-band offset. Bands: question 5, expedite 4, fixed-date 3, standard 2,
|
|
216
|
+
* intangible 1. Fixed-date: earlier deadline = larger offset. Others: own priority (clamped to +-1e9)
|
|
217
|
+
* plus, with aging, 4e9 per full window of maxDeferralRounds deferrals (priority decides within a window). An intangible card deferred that many
|
|
218
|
+
* times is scored in the standard band, so it overtakes fresh standard cards.
|
|
219
|
+
*/
|
|
220
|
+
declare function priorityByClass(item: WorkItem, ctx: PriorityContext): number;
|
|
221
|
+
/** Class rank, then the card that has waited longest in its column, then id (FIFO by aging). */
|
|
222
|
+
declare function byClassThenAge(a: WorkItem, b: WorkItem): number;
|
|
223
|
+
declare function kanban(): Methodology<KanbanConfig>;
|
|
224
|
+
|
|
225
|
+
export { ACTIVE, type BoardCard, type BoardColumn, CADENCE_EVENT, CLASSES, type CadenceStatus, type ClassConfig, DAY_MS, DEFAULT_COLUMNS, KANBAN_CADENCES, KANBAN_VOCABULARY, type KanbanCadence, type KanbanColumn, type KanbanConfig, type KanbanMetrics, OPEN, type OpsReport, type PriorityContext, type Replay, type ReplayedBlocker, type ReplayedItem, type RiskReport, type ServiceLevel, type Stay, activeExpedites, addedAt, board, byClassThenAge, cadencesDue, cardAge, columnIndex, columnStays, commitmentColumn, configOf, deliveryColumn, enteredStageAt, kanban, kanbanCeremonies, kanbanMetrics, kanbanRoles, kanbanRules, kanbanStages, onBoard, opsReport, optionsColumn, percentile, priorityByClass, replay, riskReport, validateKanbanConfig, wantItems };
|