@contractspec/bundle.lifecycle-managed 3.7.16 → 3.7.18

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.
@@ -1,217 +1,5 @@
1
- // src/agents/lifecycle-advisor-agent.ts
2
- import { defineAgent } from "@contractspec/lib.contracts-spec/agent";
3
- var LifecycleAdvisorAgent = defineAgent({
4
- meta: {
5
- key: "lifecycle.advisor",
6
- version: "1.0.0",
7
- title: "Lifecycle Advisor Agent",
8
- description: "Guides artisans through lifecycle detection, focus areas, and ceremonies.",
9
- owners: ["team-lifecycle"],
10
- domain: "operations",
11
- tags: ["guide", "lifecycle", "ops"],
12
- stability: "experimental"
13
- },
14
- description: "Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",
15
- instructions: `You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
1
+ import{defineAgent as f}from"@contractspec/lib.contracts-spec/agent";var z=f({meta:{key:"lifecycle.advisor",version:"1.0.0",title:"Lifecycle Advisor Agent",description:"Guides artisans through lifecycle detection, focus areas, and ceremonies.",owners:["team-lifecycle"],domain:"operations",tags:["guide","lifecycle","ops"],stability:"experimental"},description:"Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",instructions:`You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
16
2
  - Prioritize simple, mobile-friendly instructions.
17
3
  - When in early stages, focus on learning loops, not heavy infra.
18
4
  - When in later stages, emphasize repeatability, telemetry, and managed ceremonies.
19
- - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,
20
- tools: [
21
- {
22
- name: "run_assessment",
23
- description: "Trigger a lifecycle assessment for a tenant.",
24
- schema: {
25
- type: "object",
26
- properties: {
27
- tenantId: { type: "string" },
28
- questionnaire: { type: "object", additionalProperties: true }
29
- },
30
- required: ["tenantId"]
31
- },
32
- automationSafe: true
33
- },
34
- {
35
- name: "fetch_playbook",
36
- description: "Retrieve stage-specific playbook (actions, ceremonies, libraries).",
37
- schema: {
38
- type: "object",
39
- properties: {
40
- stage: {
41
- type: "integer",
42
- minimum: 0,
43
- maximum: 6,
44
- description: "Lifecycle stage number (0-6)"
45
- }
46
- },
47
- required: ["stage"]
48
- },
49
- automationSafe: true
50
- }
51
- ],
52
- memory: {
53
- maxEntries: 25,
54
- ttlMinutes: 120
55
- },
56
- policy: {
57
- confidence: { min: 0.7 },
58
- escalation: {
59
- confidenceThreshold: 0.5,
60
- approvalWorkflow: "ops.lifecycle.escalation"
61
- },
62
- flags: ["lifecycle_advisor"]
63
- }
64
- });
65
- // src/api/rest-handlers.ts
66
- var createLifecycleHandlers = (service) => ({
67
- runAssessment: async (req) => {
68
- const payload = {
69
- ...req.body ?? {},
70
- transport: req.body?.transport ?? req.transportPreferences?.preferredTransport,
71
- authMethod: req.body?.authMethod ?? req.transportPreferences?.preferredAuthMethod
72
- };
73
- const result = await service.runAssessment(payload);
74
- return { status: 200, body: result };
75
- },
76
- getPlaybook: async (req) => {
77
- const stage = Number(req.params?.stage ?? 0);
78
- const result = service.getStagePlaybook(stage);
79
- return { status: 200, body: result };
80
- }
81
- });
82
- // src/events/lifecycle-events.ts
83
- import { lifecycleEventNames } from "@contractspec/lib.analytics";
84
-
85
- class LifecycleEventBridge {
86
- publisher;
87
- constructor(publisher) {
88
- this.publisher = publisher;
89
- }
90
- forward(event) {
91
- if (!this.publisher)
92
- return;
93
- switch (event.type) {
94
- case "assessment.recorded":
95
- this.publisher({
96
- name: lifecycleEventNames.assessmentRun,
97
- properties: {
98
- tenantId: event.payload.tenantId,
99
- stage: event.payload.stage
100
- }
101
- });
102
- break;
103
- case "stage.changed":
104
- this.publisher({
105
- name: lifecycleEventNames.stageChanged,
106
- properties: {
107
- tenantId: event.payload.tenantId,
108
- previousStage: event.payload.previousStage,
109
- nextStage: event.payload.nextStage
110
- }
111
- });
112
- break;
113
- case "confidence.low":
114
- this.publisher({
115
- name: `${lifecycleEventNames.assessmentRun}.low_confidence`,
116
- properties: {
117
- tenantId: event.payload.tenantId,
118
- confidence: event.payload.confidence
119
- }
120
- });
121
- break;
122
- }
123
- }
124
- }
125
- // src/services/assessment-service.ts
126
- import {
127
- CapitalPhase,
128
- CompanyPhase,
129
- ProductPhase
130
- } from "@contractspec/lib.lifecycle";
131
- import {
132
- LifecycleKpiPipeline
133
- } from "@contractspec/lib.observability";
134
- import {
135
- ContractSpecLibraryRecommender,
136
- LifecycleCeremonyDesigner,
137
- LifecycleRecommendationEngine
138
- } from "@contractspec/module.lifecycle-advisor";
139
- import {
140
- LifecycleMilestonePlanner,
141
- LifecycleOrchestrator,
142
- StageScorer,
143
- StageSignalCollector
144
- } from "@contractspec/module.lifecycle-core";
145
-
146
- class LifecycleAssessmentService {
147
- orchestrator;
148
- recommendationEngine;
149
- libraryRecommender;
150
- ceremonyDesigner;
151
- pipeline;
152
- eventBridge;
153
- constructor(options) {
154
- const collector = new StageSignalCollector(options.collector);
155
- const scorer = new StageScorer;
156
- const milestonePlanner = new LifecycleMilestonePlanner;
157
- this.orchestrator = new LifecycleOrchestrator({
158
- collector,
159
- scorer,
160
- milestonePlanner
161
- });
162
- this.recommendationEngine = options.recommendationEngine ?? new LifecycleRecommendationEngine;
163
- this.libraryRecommender = options.libraryRecommender ?? new ContractSpecLibraryRecommender;
164
- this.ceremonyDesigner = options.ceremonyDesigner ?? new LifecycleCeremonyDesigner;
165
- this.pipeline = options.pipeline ?? new LifecycleKpiPipeline;
166
- this.eventBridge = options.eventBridge;
167
- if (options.onPipelineEvent) {
168
- this.pipeline.on(options.onPipelineEvent);
169
- }
170
- if (this.eventBridge) {
171
- this.pipeline.on((event) => this.eventBridge?.forward(event));
172
- }
173
- }
174
- async runAssessment(request) {
175
- const assessment = await this.orchestrator.run(request);
176
- const upcoming = this.orchestrator.getUpcomingMilestones(assessment.stage, request.completedMilestones);
177
- this.pipeline.recordAssessment(assessment, request.tenantId);
178
- const recommendation = this.recommendationEngine.generate(assessment, {
179
- upcomingMilestones: upcoming
180
- });
181
- const libraries = this.libraryRecommender.recommend(assessment.stage);
182
- const ceremony = this.ceremonyDesigner.design(assessment.stage);
183
- return {
184
- assessment,
185
- recommendation,
186
- libraries,
187
- ceremony
188
- };
189
- }
190
- getStagePlaybook(stage) {
191
- const recommendation = this.recommendationEngine.generate({
192
- stage,
193
- confidence: 1,
194
- axes: {
195
- product: ProductPhase.Mvp,
196
- company: CompanyPhase.TinyTeam,
197
- capital: CapitalPhase.Seed
198
- },
199
- signals: [],
200
- gaps: [],
201
- focusAreas: [],
202
- scorecard: [],
203
- generatedAt: new Date().toISOString()
204
- }, { upcomingMilestones: this.orchestrator.getUpcomingMilestones(stage) });
205
- return {
206
- recommendation,
207
- libraries: this.libraryRecommender.recommend(stage),
208
- ceremony: this.ceremonyDesigner.design(stage)
209
- };
210
- }
211
- }
212
- export {
213
- createLifecycleHandlers,
214
- LifecycleEventBridge,
215
- LifecycleAssessmentService,
216
- LifecycleAdvisorAgent
217
- };
5
+ - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,tools:[{name:"run_assessment",description:"Trigger a lifecycle assessment for a tenant.",schema:{type:"object",properties:{tenantId:{type:"string"},questionnaire:{type:"object",additionalProperties:!0}},required:["tenantId"]},automationSafe:!0},{name:"fetch_playbook",description:"Retrieve stage-specific playbook (actions, ceremonies, libraries).",schema:{type:"object",properties:{stage:{type:"integer",minimum:0,maximum:6,description:"Lifecycle stage number (0-6)"}},required:["stage"]},automationSafe:!0}],memory:{maxEntries:25,ttlMinutes:120},policy:{confidence:{min:0.7},escalation:{confidenceThreshold:0.5,approvalWorkflow:"ops.lifecycle.escalation"},flags:["lifecycle_advisor"]}});var G=(d)=>({runAssessment:async(b)=>{let a={...b.body??{},transport:b.body?.transport??b.transportPreferences?.preferredTransport,authMethod:b.body?.authMethod??b.transportPreferences?.preferredAuthMethod};return{status:200,body:await d.runAssessment(a)}},getPlaybook:async(b)=>{let a=Number(b.params?.stage??0);return{status:200,body:d.getStagePlaybook(a)}}});import{lifecycleEventNames as y}from"@contractspec/lib.analytics";class p{publisher;constructor(d){this.publisher=d}forward(d){if(!this.publisher)return;switch(d.type){case"assessment.recorded":this.publisher({name:y.assessmentRun,properties:{tenantId:d.payload.tenantId,stage:d.payload.stage}});break;case"stage.changed":this.publisher({name:y.stageChanged,properties:{tenantId:d.payload.tenantId,previousStage:d.payload.previousStage,nextStage:d.payload.nextStage}});break;case"confidence.low":this.publisher({name:`${y.assessmentRun}.low_confidence`,properties:{tenantId:d.payload.tenantId,confidence:d.payload.confidence}});break}}}import{CapitalPhase as w,CompanyPhase as x,ProductPhase as k}from"@contractspec/lib.lifecycle";import{LifecycleKpiPipeline as u}from"@contractspec/lib.observability";import{ContractSpecLibraryRecommender as l,LifecycleCeremonyDesigner as B,LifecycleRecommendationEngine as L}from"@contractspec/module.lifecycle-advisor";import{LifecycleMilestonePlanner as M,LifecycleOrchestrator as N,StageScorer as R,StageSignalCollector as _}from"@contractspec/module.lifecycle-core";class ${orchestrator;recommendationEngine;libraryRecommender;ceremonyDesigner;pipeline;eventBridge;constructor(d){let b=new _(d.collector),a=new R,h=new M;if(this.orchestrator=new N({collector:b,scorer:a,milestonePlanner:h}),this.recommendationEngine=d.recommendationEngine??new L,this.libraryRecommender=d.libraryRecommender??new l,this.ceremonyDesigner=d.ceremonyDesigner??new B,this.pipeline=d.pipeline??new u,this.eventBridge=d.eventBridge,d.onPipelineEvent)this.pipeline.on(d.onPipelineEvent);if(this.eventBridge)this.pipeline.on((E)=>this.eventBridge?.forward(E))}async runAssessment(d){let b=await this.orchestrator.run(d),a=this.orchestrator.getUpcomingMilestones(b.stage,d.completedMilestones);this.pipeline.recordAssessment(b,d.tenantId);let h=this.recommendationEngine.generate(b,{upcomingMilestones:a}),E=this.libraryRecommender.recommend(b.stage),I=this.ceremonyDesigner.design(b.stage);return{assessment:b,recommendation:h,libraries:E,ceremony:I}}getStagePlaybook(d){return{recommendation:this.recommendationEngine.generate({stage:d,confidence:1,axes:{product:k.Mvp,company:x.TinyTeam,capital:w.Seed},signals:[],gaps:[],focusAreas:[],scorecard:[],generatedAt:new Date().toISOString()},{upcomingMilestones:this.orchestrator.getUpcomingMilestones(d)}),libraries:this.libraryRecommender.recommend(d),ceremony:this.ceremonyDesigner.design(d)}}}export{G as createLifecycleHandlers,p as LifecycleEventBridge,$ as LifecycleAssessmentService,z as LifecycleAdvisorAgent};
package/dist/index.js CHANGED
@@ -1,218 +1,6 @@
1
1
  // @bun
2
- // src/agents/lifecycle-advisor-agent.ts
3
- import { defineAgent } from "@contractspec/lib.contracts-spec/agent";
4
- var LifecycleAdvisorAgent = defineAgent({
5
- meta: {
6
- key: "lifecycle.advisor",
7
- version: "1.0.0",
8
- title: "Lifecycle Advisor Agent",
9
- description: "Guides artisans through lifecycle detection, focus areas, and ceremonies.",
10
- owners: ["team-lifecycle"],
11
- domain: "operations",
12
- tags: ["guide", "lifecycle", "ops"],
13
- stability: "experimental"
14
- },
15
- description: "Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",
16
- instructions: `You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
2
+ import{defineAgent as f}from"@contractspec/lib.contracts-spec/agent";var z=f({meta:{key:"lifecycle.advisor",version:"1.0.0",title:"Lifecycle Advisor Agent",description:"Guides artisans through lifecycle detection, focus areas, and ceremonies.",owners:["team-lifecycle"],domain:"operations",tags:["guide","lifecycle","ops"],stability:"experimental"},description:"Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",instructions:`You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
17
3
  - Prioritize simple, mobile-friendly instructions.
18
4
  - When in early stages, focus on learning loops, not heavy infra.
19
5
  - When in later stages, emphasize repeatability, telemetry, and managed ceremonies.
20
- - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,
21
- tools: [
22
- {
23
- name: "run_assessment",
24
- description: "Trigger a lifecycle assessment for a tenant.",
25
- schema: {
26
- type: "object",
27
- properties: {
28
- tenantId: { type: "string" },
29
- questionnaire: { type: "object", additionalProperties: true }
30
- },
31
- required: ["tenantId"]
32
- },
33
- automationSafe: true
34
- },
35
- {
36
- name: "fetch_playbook",
37
- description: "Retrieve stage-specific playbook (actions, ceremonies, libraries).",
38
- schema: {
39
- type: "object",
40
- properties: {
41
- stage: {
42
- type: "integer",
43
- minimum: 0,
44
- maximum: 6,
45
- description: "Lifecycle stage number (0-6)"
46
- }
47
- },
48
- required: ["stage"]
49
- },
50
- automationSafe: true
51
- }
52
- ],
53
- memory: {
54
- maxEntries: 25,
55
- ttlMinutes: 120
56
- },
57
- policy: {
58
- confidence: { min: 0.7 },
59
- escalation: {
60
- confidenceThreshold: 0.5,
61
- approvalWorkflow: "ops.lifecycle.escalation"
62
- },
63
- flags: ["lifecycle_advisor"]
64
- }
65
- });
66
- // src/api/rest-handlers.ts
67
- var createLifecycleHandlers = (service) => ({
68
- runAssessment: async (req) => {
69
- const payload = {
70
- ...req.body ?? {},
71
- transport: req.body?.transport ?? req.transportPreferences?.preferredTransport,
72
- authMethod: req.body?.authMethod ?? req.transportPreferences?.preferredAuthMethod
73
- };
74
- const result = await service.runAssessment(payload);
75
- return { status: 200, body: result };
76
- },
77
- getPlaybook: async (req) => {
78
- const stage = Number(req.params?.stage ?? 0);
79
- const result = service.getStagePlaybook(stage);
80
- return { status: 200, body: result };
81
- }
82
- });
83
- // src/events/lifecycle-events.ts
84
- import { lifecycleEventNames } from "@contractspec/lib.analytics";
85
-
86
- class LifecycleEventBridge {
87
- publisher;
88
- constructor(publisher) {
89
- this.publisher = publisher;
90
- }
91
- forward(event) {
92
- if (!this.publisher)
93
- return;
94
- switch (event.type) {
95
- case "assessment.recorded":
96
- this.publisher({
97
- name: lifecycleEventNames.assessmentRun,
98
- properties: {
99
- tenantId: event.payload.tenantId,
100
- stage: event.payload.stage
101
- }
102
- });
103
- break;
104
- case "stage.changed":
105
- this.publisher({
106
- name: lifecycleEventNames.stageChanged,
107
- properties: {
108
- tenantId: event.payload.tenantId,
109
- previousStage: event.payload.previousStage,
110
- nextStage: event.payload.nextStage
111
- }
112
- });
113
- break;
114
- case "confidence.low":
115
- this.publisher({
116
- name: `${lifecycleEventNames.assessmentRun}.low_confidence`,
117
- properties: {
118
- tenantId: event.payload.tenantId,
119
- confidence: event.payload.confidence
120
- }
121
- });
122
- break;
123
- }
124
- }
125
- }
126
- // src/services/assessment-service.ts
127
- import {
128
- CapitalPhase,
129
- CompanyPhase,
130
- ProductPhase
131
- } from "@contractspec/lib.lifecycle";
132
- import {
133
- LifecycleKpiPipeline
134
- } from "@contractspec/lib.observability";
135
- import {
136
- ContractSpecLibraryRecommender,
137
- LifecycleCeremonyDesigner,
138
- LifecycleRecommendationEngine
139
- } from "@contractspec/module.lifecycle-advisor";
140
- import {
141
- LifecycleMilestonePlanner,
142
- LifecycleOrchestrator,
143
- StageScorer,
144
- StageSignalCollector
145
- } from "@contractspec/module.lifecycle-core";
146
-
147
- class LifecycleAssessmentService {
148
- orchestrator;
149
- recommendationEngine;
150
- libraryRecommender;
151
- ceremonyDesigner;
152
- pipeline;
153
- eventBridge;
154
- constructor(options) {
155
- const collector = new StageSignalCollector(options.collector);
156
- const scorer = new StageScorer;
157
- const milestonePlanner = new LifecycleMilestonePlanner;
158
- this.orchestrator = new LifecycleOrchestrator({
159
- collector,
160
- scorer,
161
- milestonePlanner
162
- });
163
- this.recommendationEngine = options.recommendationEngine ?? new LifecycleRecommendationEngine;
164
- this.libraryRecommender = options.libraryRecommender ?? new ContractSpecLibraryRecommender;
165
- this.ceremonyDesigner = options.ceremonyDesigner ?? new LifecycleCeremonyDesigner;
166
- this.pipeline = options.pipeline ?? new LifecycleKpiPipeline;
167
- this.eventBridge = options.eventBridge;
168
- if (options.onPipelineEvent) {
169
- this.pipeline.on(options.onPipelineEvent);
170
- }
171
- if (this.eventBridge) {
172
- this.pipeline.on((event) => this.eventBridge?.forward(event));
173
- }
174
- }
175
- async runAssessment(request) {
176
- const assessment = await this.orchestrator.run(request);
177
- const upcoming = this.orchestrator.getUpcomingMilestones(assessment.stage, request.completedMilestones);
178
- this.pipeline.recordAssessment(assessment, request.tenantId);
179
- const recommendation = this.recommendationEngine.generate(assessment, {
180
- upcomingMilestones: upcoming
181
- });
182
- const libraries = this.libraryRecommender.recommend(assessment.stage);
183
- const ceremony = this.ceremonyDesigner.design(assessment.stage);
184
- return {
185
- assessment,
186
- recommendation,
187
- libraries,
188
- ceremony
189
- };
190
- }
191
- getStagePlaybook(stage) {
192
- const recommendation = this.recommendationEngine.generate({
193
- stage,
194
- confidence: 1,
195
- axes: {
196
- product: ProductPhase.Mvp,
197
- company: CompanyPhase.TinyTeam,
198
- capital: CapitalPhase.Seed
199
- },
200
- signals: [],
201
- gaps: [],
202
- focusAreas: [],
203
- scorecard: [],
204
- generatedAt: new Date().toISOString()
205
- }, { upcomingMilestones: this.orchestrator.getUpcomingMilestones(stage) });
206
- return {
207
- recommendation,
208
- libraries: this.libraryRecommender.recommend(stage),
209
- ceremony: this.ceremonyDesigner.design(stage)
210
- };
211
- }
212
- }
213
- export {
214
- createLifecycleHandlers,
215
- LifecycleEventBridge,
216
- LifecycleAssessmentService,
217
- LifecycleAdvisorAgent
218
- };
6
+ - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,tools:[{name:"run_assessment",description:"Trigger a lifecycle assessment for a tenant.",schema:{type:"object",properties:{tenantId:{type:"string"},questionnaire:{type:"object",additionalProperties:!0}},required:["tenantId"]},automationSafe:!0},{name:"fetch_playbook",description:"Retrieve stage-specific playbook (actions, ceremonies, libraries).",schema:{type:"object",properties:{stage:{type:"integer",minimum:0,maximum:6,description:"Lifecycle stage number (0-6)"}},required:["stage"]},automationSafe:!0}],memory:{maxEntries:25,ttlMinutes:120},policy:{confidence:{min:0.7},escalation:{confidenceThreshold:0.5,approvalWorkflow:"ops.lifecycle.escalation"},flags:["lifecycle_advisor"]}});var G=(d)=>({runAssessment:async(b)=>{let a={...b.body??{},transport:b.body?.transport??b.transportPreferences?.preferredTransport,authMethod:b.body?.authMethod??b.transportPreferences?.preferredAuthMethod};return{status:200,body:await d.runAssessment(a)}},getPlaybook:async(b)=>{let a=Number(b.params?.stage??0);return{status:200,body:d.getStagePlaybook(a)}}});import{lifecycleEventNames as y}from"@contractspec/lib.analytics";class p{publisher;constructor(d){this.publisher=d}forward(d){if(!this.publisher)return;switch(d.type){case"assessment.recorded":this.publisher({name:y.assessmentRun,properties:{tenantId:d.payload.tenantId,stage:d.payload.stage}});break;case"stage.changed":this.publisher({name:y.stageChanged,properties:{tenantId:d.payload.tenantId,previousStage:d.payload.previousStage,nextStage:d.payload.nextStage}});break;case"confidence.low":this.publisher({name:`${y.assessmentRun}.low_confidence`,properties:{tenantId:d.payload.tenantId,confidence:d.payload.confidence}});break}}}import{CapitalPhase as w,CompanyPhase as x,ProductPhase as k}from"@contractspec/lib.lifecycle";import{LifecycleKpiPipeline as u}from"@contractspec/lib.observability";import{ContractSpecLibraryRecommender as l,LifecycleCeremonyDesigner as B,LifecycleRecommendationEngine as L}from"@contractspec/module.lifecycle-advisor";import{LifecycleMilestonePlanner as M,LifecycleOrchestrator as N,StageScorer as R,StageSignalCollector as _}from"@contractspec/module.lifecycle-core";class ${orchestrator;recommendationEngine;libraryRecommender;ceremonyDesigner;pipeline;eventBridge;constructor(d){let b=new _(d.collector),a=new R,h=new M;if(this.orchestrator=new N({collector:b,scorer:a,milestonePlanner:h}),this.recommendationEngine=d.recommendationEngine??new L,this.libraryRecommender=d.libraryRecommender??new l,this.ceremonyDesigner=d.ceremonyDesigner??new B,this.pipeline=d.pipeline??new u,this.eventBridge=d.eventBridge,d.onPipelineEvent)this.pipeline.on(d.onPipelineEvent);if(this.eventBridge)this.pipeline.on((E)=>this.eventBridge?.forward(E))}async runAssessment(d){let b=await this.orchestrator.run(d),a=this.orchestrator.getUpcomingMilestones(b.stage,d.completedMilestones);this.pipeline.recordAssessment(b,d.tenantId);let h=this.recommendationEngine.generate(b,{upcomingMilestones:a}),E=this.libraryRecommender.recommend(b.stage),I=this.ceremonyDesigner.design(b.stage);return{assessment:b,recommendation:h,libraries:E,ceremony:I}}getStagePlaybook(d){return{recommendation:this.recommendationEngine.generate({stage:d,confidence:1,axes:{product:k.Mvp,company:x.TinyTeam,capital:w.Seed},signals:[],gaps:[],focusAreas:[],scorecard:[],generatedAt:new Date().toISOString()},{upcomingMilestones:this.orchestrator.getUpcomingMilestones(d)}),libraries:this.libraryRecommender.recommend(d),ceremony:this.ceremonyDesigner.design(d)}}}export{G as createLifecycleHandlers,p as LifecycleEventBridge,$ as LifecycleAssessmentService,z as LifecycleAdvisorAgent};
@@ -1,217 +1,5 @@
1
- // src/agents/lifecycle-advisor-agent.ts
2
- import { defineAgent } from "@contractspec/lib.contracts-spec/agent";
3
- var LifecycleAdvisorAgent = defineAgent({
4
- meta: {
5
- key: "lifecycle.advisor",
6
- version: "1.0.0",
7
- title: "Lifecycle Advisor Agent",
8
- description: "Guides artisans through lifecycle detection, focus areas, and ceremonies.",
9
- owners: ["team-lifecycle"],
10
- domain: "operations",
11
- tags: ["guide", "lifecycle", "ops"],
12
- stability: "experimental"
13
- },
14
- description: "Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",
15
- instructions: `You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
1
+ import{defineAgent as f}from"@contractspec/lib.contracts-spec/agent";var z=f({meta:{key:"lifecycle.advisor",version:"1.0.0",title:"Lifecycle Advisor Agent",description:"Guides artisans through lifecycle detection, focus areas, and ceremonies.",owners:["team-lifecycle"],domain:"operations",tags:["guide","lifecycle","ops"],stability:"experimental"},description:"Guides users through lifecycle assessments, highlights gaps, and recommends actions tied to ContractSpec libraries.",instructions:`You are the Lifecycle Advisor. Always clarify the user's current stage, confidence, and blockers before suggesting actions.
16
2
  - Prioritize simple, mobile-friendly instructions.
17
3
  - When in early stages, focus on learning loops, not heavy infra.
18
4
  - When in later stages, emphasize repeatability, telemetry, and managed ceremonies.
19
- - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,
20
- tools: [
21
- {
22
- name: "run_assessment",
23
- description: "Trigger a lifecycle assessment for a tenant.",
24
- schema: {
25
- type: "object",
26
- properties: {
27
- tenantId: { type: "string" },
28
- questionnaire: { type: "object", additionalProperties: true }
29
- },
30
- required: ["tenantId"]
31
- },
32
- automationSafe: true
33
- },
34
- {
35
- name: "fetch_playbook",
36
- description: "Retrieve stage-specific playbook (actions, ceremonies, libraries).",
37
- schema: {
38
- type: "object",
39
- properties: {
40
- stage: {
41
- type: "integer",
42
- minimum: 0,
43
- maximum: 6,
44
- description: "Lifecycle stage number (0-6)"
45
- }
46
- },
47
- required: ["stage"]
48
- },
49
- automationSafe: true
50
- }
51
- ],
52
- memory: {
53
- maxEntries: 25,
54
- ttlMinutes: 120
55
- },
56
- policy: {
57
- confidence: { min: 0.7 },
58
- escalation: {
59
- confidenceThreshold: 0.5,
60
- approvalWorkflow: "ops.lifecycle.escalation"
61
- },
62
- flags: ["lifecycle_advisor"]
63
- }
64
- });
65
- // src/api/rest-handlers.ts
66
- var createLifecycleHandlers = (service) => ({
67
- runAssessment: async (req) => {
68
- const payload = {
69
- ...req.body ?? {},
70
- transport: req.body?.transport ?? req.transportPreferences?.preferredTransport,
71
- authMethod: req.body?.authMethod ?? req.transportPreferences?.preferredAuthMethod
72
- };
73
- const result = await service.runAssessment(payload);
74
- return { status: 200, body: result };
75
- },
76
- getPlaybook: async (req) => {
77
- const stage = Number(req.params?.stage ?? 0);
78
- const result = service.getStagePlaybook(stage);
79
- return { status: 200, body: result };
80
- }
81
- });
82
- // src/events/lifecycle-events.ts
83
- import { lifecycleEventNames } from "@contractspec/lib.analytics";
84
-
85
- class LifecycleEventBridge {
86
- publisher;
87
- constructor(publisher) {
88
- this.publisher = publisher;
89
- }
90
- forward(event) {
91
- if (!this.publisher)
92
- return;
93
- switch (event.type) {
94
- case "assessment.recorded":
95
- this.publisher({
96
- name: lifecycleEventNames.assessmentRun,
97
- properties: {
98
- tenantId: event.payload.tenantId,
99
- stage: event.payload.stage
100
- }
101
- });
102
- break;
103
- case "stage.changed":
104
- this.publisher({
105
- name: lifecycleEventNames.stageChanged,
106
- properties: {
107
- tenantId: event.payload.tenantId,
108
- previousStage: event.payload.previousStage,
109
- nextStage: event.payload.nextStage
110
- }
111
- });
112
- break;
113
- case "confidence.low":
114
- this.publisher({
115
- name: `${lifecycleEventNames.assessmentRun}.low_confidence`,
116
- properties: {
117
- tenantId: event.payload.tenantId,
118
- confidence: event.payload.confidence
119
- }
120
- });
121
- break;
122
- }
123
- }
124
- }
125
- // src/services/assessment-service.ts
126
- import {
127
- CapitalPhase,
128
- CompanyPhase,
129
- ProductPhase
130
- } from "@contractspec/lib.lifecycle";
131
- import {
132
- LifecycleKpiPipeline
133
- } from "@contractspec/lib.observability";
134
- import {
135
- ContractSpecLibraryRecommender,
136
- LifecycleCeremonyDesigner,
137
- LifecycleRecommendationEngine
138
- } from "@contractspec/module.lifecycle-advisor";
139
- import {
140
- LifecycleMilestonePlanner,
141
- LifecycleOrchestrator,
142
- StageScorer,
143
- StageSignalCollector
144
- } from "@contractspec/module.lifecycle-core";
145
-
146
- class LifecycleAssessmentService {
147
- orchestrator;
148
- recommendationEngine;
149
- libraryRecommender;
150
- ceremonyDesigner;
151
- pipeline;
152
- eventBridge;
153
- constructor(options) {
154
- const collector = new StageSignalCollector(options.collector);
155
- const scorer = new StageScorer;
156
- const milestonePlanner = new LifecycleMilestonePlanner;
157
- this.orchestrator = new LifecycleOrchestrator({
158
- collector,
159
- scorer,
160
- milestonePlanner
161
- });
162
- this.recommendationEngine = options.recommendationEngine ?? new LifecycleRecommendationEngine;
163
- this.libraryRecommender = options.libraryRecommender ?? new ContractSpecLibraryRecommender;
164
- this.ceremonyDesigner = options.ceremonyDesigner ?? new LifecycleCeremonyDesigner;
165
- this.pipeline = options.pipeline ?? new LifecycleKpiPipeline;
166
- this.eventBridge = options.eventBridge;
167
- if (options.onPipelineEvent) {
168
- this.pipeline.on(options.onPipelineEvent);
169
- }
170
- if (this.eventBridge) {
171
- this.pipeline.on((event) => this.eventBridge?.forward(event));
172
- }
173
- }
174
- async runAssessment(request) {
175
- const assessment = await this.orchestrator.run(request);
176
- const upcoming = this.orchestrator.getUpcomingMilestones(assessment.stage, request.completedMilestones);
177
- this.pipeline.recordAssessment(assessment, request.tenantId);
178
- const recommendation = this.recommendationEngine.generate(assessment, {
179
- upcomingMilestones: upcoming
180
- });
181
- const libraries = this.libraryRecommender.recommend(assessment.stage);
182
- const ceremony = this.ceremonyDesigner.design(assessment.stage);
183
- return {
184
- assessment,
185
- recommendation,
186
- libraries,
187
- ceremony
188
- };
189
- }
190
- getStagePlaybook(stage) {
191
- const recommendation = this.recommendationEngine.generate({
192
- stage,
193
- confidence: 1,
194
- axes: {
195
- product: ProductPhase.Mvp,
196
- company: CompanyPhase.TinyTeam,
197
- capital: CapitalPhase.Seed
198
- },
199
- signals: [],
200
- gaps: [],
201
- focusAreas: [],
202
- scorecard: [],
203
- generatedAt: new Date().toISOString()
204
- }, { upcomingMilestones: this.orchestrator.getUpcomingMilestones(stage) });
205
- return {
206
- recommendation,
207
- libraries: this.libraryRecommender.recommend(stage),
208
- ceremony: this.ceremonyDesigner.design(stage)
209
- };
210
- }
211
- }
212
- export {
213
- createLifecycleHandlers,
214
- LifecycleEventBridge,
215
- LifecycleAssessmentService,
216
- LifecycleAdvisorAgent
217
- };
5
+ - Suggest at most 3 actions at a time. Reference ContractSpec libraries or modules when relevant.`,tools:[{name:"run_assessment",description:"Trigger a lifecycle assessment for a tenant.",schema:{type:"object",properties:{tenantId:{type:"string"},questionnaire:{type:"object",additionalProperties:!0}},required:["tenantId"]},automationSafe:!0},{name:"fetch_playbook",description:"Retrieve stage-specific playbook (actions, ceremonies, libraries).",schema:{type:"object",properties:{stage:{type:"integer",minimum:0,maximum:6,description:"Lifecycle stage number (0-6)"}},required:["stage"]},automationSafe:!0}],memory:{maxEntries:25,ttlMinutes:120},policy:{confidence:{min:0.7},escalation:{confidenceThreshold:0.5,approvalWorkflow:"ops.lifecycle.escalation"},flags:["lifecycle_advisor"]}});var G=(d)=>({runAssessment:async(b)=>{let a={...b.body??{},transport:b.body?.transport??b.transportPreferences?.preferredTransport,authMethod:b.body?.authMethod??b.transportPreferences?.preferredAuthMethod};return{status:200,body:await d.runAssessment(a)}},getPlaybook:async(b)=>{let a=Number(b.params?.stage??0);return{status:200,body:d.getStagePlaybook(a)}}});import{lifecycleEventNames as y}from"@contractspec/lib.analytics";class p{publisher;constructor(d){this.publisher=d}forward(d){if(!this.publisher)return;switch(d.type){case"assessment.recorded":this.publisher({name:y.assessmentRun,properties:{tenantId:d.payload.tenantId,stage:d.payload.stage}});break;case"stage.changed":this.publisher({name:y.stageChanged,properties:{tenantId:d.payload.tenantId,previousStage:d.payload.previousStage,nextStage:d.payload.nextStage}});break;case"confidence.low":this.publisher({name:`${y.assessmentRun}.low_confidence`,properties:{tenantId:d.payload.tenantId,confidence:d.payload.confidence}});break}}}import{CapitalPhase as w,CompanyPhase as x,ProductPhase as k}from"@contractspec/lib.lifecycle";import{LifecycleKpiPipeline as u}from"@contractspec/lib.observability";import{ContractSpecLibraryRecommender as l,LifecycleCeremonyDesigner as B,LifecycleRecommendationEngine as L}from"@contractspec/module.lifecycle-advisor";import{LifecycleMilestonePlanner as M,LifecycleOrchestrator as N,StageScorer as R,StageSignalCollector as _}from"@contractspec/module.lifecycle-core";class ${orchestrator;recommendationEngine;libraryRecommender;ceremonyDesigner;pipeline;eventBridge;constructor(d){let b=new _(d.collector),a=new R,h=new M;if(this.orchestrator=new N({collector:b,scorer:a,milestonePlanner:h}),this.recommendationEngine=d.recommendationEngine??new L,this.libraryRecommender=d.libraryRecommender??new l,this.ceremonyDesigner=d.ceremonyDesigner??new B,this.pipeline=d.pipeline??new u,this.eventBridge=d.eventBridge,d.onPipelineEvent)this.pipeline.on(d.onPipelineEvent);if(this.eventBridge)this.pipeline.on((E)=>this.eventBridge?.forward(E))}async runAssessment(d){let b=await this.orchestrator.run(d),a=this.orchestrator.getUpcomingMilestones(b.stage,d.completedMilestones);this.pipeline.recordAssessment(b,d.tenantId);let h=this.recommendationEngine.generate(b,{upcomingMilestones:a}),E=this.libraryRecommender.recommend(b.stage),I=this.ceremonyDesigner.design(b.stage);return{assessment:b,recommendation:h,libraries:E,ceremony:I}}getStagePlaybook(d){return{recommendation:this.recommendationEngine.generate({stage:d,confidence:1,axes:{product:k.Mvp,company:x.TinyTeam,capital:w.Seed},signals:[],gaps:[],focusAreas:[],scorecard:[],generatedAt:new Date().toISOString()},{upcomingMilestones:this.orchestrator.getUpcomingMilestones(d)}),libraries:this.libraryRecommender.recommend(d),ceremony:this.ceremonyDesigner.design(d)}}}export{G as createLifecycleHandlers,p as LifecycleEventBridge,$ as LifecycleAssessmentService,z as LifecycleAdvisorAgent};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contractspec/bundle.lifecycle-managed",
3
- "version": "3.7.16",
3
+ "version": "3.7.18",
4
4
  "description": "Lifecycle management bundle with analytics and AI advisor",
5
5
  "keywords": [
6
6
  "contractspec",
@@ -25,24 +25,24 @@
25
25
  "dev": "contractspec-bun-build dev",
26
26
  "clean": "rimraf dist .turbo",
27
27
  "lint": "bun lint:fix",
28
- "lint:fix": "biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .",
29
- "lint:check": "biome check .",
28
+ "lint:fix": "node ../../../scripts/biome.cjs check --write --unsafe --only=nursery/useSortedClasses . && node ../../../scripts/biome.cjs check --write .",
29
+ "lint:check": "node ../../../scripts/biome.cjs check .",
30
30
  "test": "bun test",
31
31
  "prebuild": "contractspec-bun-build prebuild",
32
32
  "typecheck": "tsc --noEmit"
33
33
  },
34
34
  "dependencies": {
35
- "@contractspec/lib.analytics": "3.7.16",
36
- "@contractspec/lib.contracts-spec": "5.0.4",
37
- "@contractspec/lib.lifecycle": "3.7.16",
38
- "@contractspec/lib.observability": "3.7.16",
39
- "@contractspec/module.lifecycle-advisor": "3.7.15",
40
- "@contractspec/module.lifecycle-core": "3.7.15"
35
+ "@contractspec/lib.analytics": "3.7.18",
36
+ "@contractspec/lib.contracts-spec": "5.2.0",
37
+ "@contractspec/lib.lifecycle": "3.7.18",
38
+ "@contractspec/lib.observability": "3.7.18",
39
+ "@contractspec/module.lifecycle-advisor": "3.7.17",
40
+ "@contractspec/module.lifecycle-core": "3.7.17"
41
41
  },
42
42
  "devDependencies": {
43
- "@contractspec/tool.typescript": "3.7.12",
43
+ "@contractspec/tool.typescript": "3.7.13",
44
44
  "typescript": "^5.9.3",
45
- "@contractspec/tool.bun": "3.7.12"
45
+ "@contractspec/tool.bun": "3.7.14"
46
46
  },
47
47
  "exports": {
48
48
  ".": {