@contractspec/example.product-intent 3.7.19 → 3.7.21
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/.turbo/turbo-build.log +33 -32
- package/CHANGELOG.md +33 -0
- package/dist/example.d.ts +3 -2
- package/dist/example.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- package/dist/node/example.js +1 -1
- package/dist/node/index.js +3 -3
- package/dist/node/product-intent.feature.js +1 -1
- package/dist/product-intent.feature.js +1 -1
- package/package.json +8 -8
- package/src/example.ts +15 -19
- package/src/index.ts +1 -0
- package/src/product-intent.feature.ts +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
./
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
./
|
|
13
|
-
./
|
|
14
|
-
./
|
|
15
|
-
./
|
|
16
|
-
./product-intent.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
./
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
./
|
|
27
|
-
./
|
|
28
|
-
./
|
|
29
|
-
./
|
|
30
|
-
./product-intent.
|
|
31
|
-
|
|
32
|
-
|
|
1
|
+
|
|
2
|
+
[0m[2m[35m$[0m [2m[1mcontractspec-bun-build prebuild[0m
|
|
3
|
+
[0m[2m[35m$[0m [2m[1mbun run build:bundle && bun run build:types[0m
|
|
4
|
+
[0m[2m[35m$[0m [2m[1mcontractspec-bun-build transpile[0m
|
|
5
|
+
[contractspec-bun-build] transpile target=bun root=src entries=10 noBundle=false
|
|
6
|
+
[32mBundled 10 modules in 25ms[0m
|
|
7
|
+
|
|
8
|
+
[34mdocs/index.js[0m 1.23 KB [2m(entry point)[0m
|
|
9
|
+
[34m./script.js[0m 9.32 KB [2m(entry point)[0m
|
|
10
|
+
[34m./sync-actions.js[0m 9.22 KB [2m(entry point)[0m
|
|
11
|
+
[34mdocs/product-intent.docblock.js[0m 1.23 KB [2m(entry point)[0m
|
|
12
|
+
[34m./index.js[0m 8.91 KB [2m(entry point)[0m
|
|
13
|
+
[34m./example.js[0m 0.65 KB [2m(entry point)[0m
|
|
14
|
+
[34m./load-evidence.js[0m 5.33 KB [2m(entry point)[0m
|
|
15
|
+
[34m./posthog-signals.js[0m 4.34 KB [2m(entry point)[0m
|
|
16
|
+
[34m./product-intent.discovery.js[0m 2.44 KB [2m(entry point)[0m
|
|
17
|
+
[34m./product-intent.feature.js[0m 470 bytes [2m(entry point)[0m
|
|
18
|
+
|
|
19
|
+
[contractspec-bun-build] transpile target=node root=src entries=10 noBundle=false
|
|
20
|
+
[32mBundled 10 modules in 13ms[0m
|
|
21
|
+
|
|
22
|
+
[34mdocs/index.js[0m 1.22 KB [2m(entry point)[0m
|
|
23
|
+
[34m./script.js[0m 9.33 KB [2m(entry point)[0m
|
|
24
|
+
[34m./sync-actions.js[0m 9.22 KB [2m(entry point)[0m
|
|
25
|
+
[34mdocs/product-intent.docblock.js[0m 1.22 KB [2m(entry point)[0m
|
|
26
|
+
[34m./index.js[0m 8.91 KB [2m(entry point)[0m
|
|
27
|
+
[34m./example.js[0m 0.64 KB [2m(entry point)[0m
|
|
28
|
+
[34m./load-evidence.js[0m 5.34 KB [2m(entry point)[0m
|
|
29
|
+
[34m./posthog-signals.js[0m 4.33 KB [2m(entry point)[0m
|
|
30
|
+
[34m./product-intent.discovery.js[0m 2.43 KB [2m(entry point)[0m
|
|
31
|
+
[34m./product-intent.feature.js[0m 462 bytes [2m(entry point)[0m
|
|
32
|
+
|
|
33
|
+
[0m[2m[35m$[0m [2m[1mcontractspec-bun-build types[0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
# @contractspec/example.product-intent
|
|
2
2
|
|
|
3
|
+
## 3.7.21
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- chore: auto-bump internal dependents
|
|
8
|
+
- Updated dependencies because of chore: auto-bump internal dependents
|
|
9
|
+
- Updated dependencies because of Add FormSpec layout hints, semantic field rendering, and portable text/textarea input-group addons.
|
|
10
|
+
- Updated dependencies because of Add ThemeSpec light/dark modes and a design-system Tailwind bridge for CSS variables, presets, CSS text, and OKLCH color pass-through.
|
|
11
|
+
- Updated dependencies because of Add a canonical typed result system for ContractSpec success and failure propagation across operations, workflows, jobs, server adapters, MCP, GraphQL, and React clients.
|
|
12
|
+
- @contractspec/integration.providers-impls@3.8.13
|
|
13
|
+
- @contractspec/lib.ai-agent@8.0.9
|
|
14
|
+
- @contractspec/lib.analytics@3.7.21
|
|
15
|
+
- @contractspec/lib.contracts-integrations@3.8.13
|
|
16
|
+
- @contractspec/lib.product-intent-utils@3.7.21
|
|
17
|
+
- @contractspec/lib.contracts-spec@5.5.0
|
|
18
|
+
|
|
19
|
+
## 3.7.20
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- chore: auto-bump internal dependents
|
|
24
|
+
- Updated dependencies because of Add a family-aware ContractSpec Adoption Engine, expand contract authoring targets across CLI and VS Code tooling, and refresh release-facing schema and policy artifacts for downstream workspaces.
|
|
25
|
+
- Updated dependencies because of chore: auto-bump internal dependents
|
|
26
|
+
- Updated dependencies because of Improve app-config, theme, and feature authoring with explicit validation APIs, first-class theme discovery and scaffolding, and key-based app-config generation across contracts, workspace tooling, and the CLI.
|
|
27
|
+
- Updated dependencies because of Refresh root, package, website, and LLM-facing docs so Connect, Builder, release capsules, and the current contracts-spec export surface stay aligned.
|
|
28
|
+
- Updated dependencies because of Persist canonical knowledge payload text during indexing and align the retrieval/query docs with the corrected behavior.
|
|
29
|
+
- @contractspec/lib.contracts-spec@5.4.0
|
|
30
|
+
- @contractspec/integration.providers-impls@3.8.12
|
|
31
|
+
- @contractspec/lib.ai-agent@8.0.8
|
|
32
|
+
- @contractspec/lib.analytics@3.7.20
|
|
33
|
+
- @contractspec/lib.contracts-integrations@3.8.12
|
|
34
|
+
- @contractspec/lib.product-intent-utils@3.7.20
|
|
35
|
+
|
|
3
36
|
## 3.7.19
|
|
4
37
|
|
|
5
38
|
### Patch Changes
|
package/dist/example.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const ExamplesProductIntentExample: import("@contractspec/lib.contracts-spec").ExampleSpec;
|
|
2
|
+
export default ExamplesProductIntentExample;
|
|
3
|
+
export { ExamplesProductIntentExample };
|
package/dist/example.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{defineExample as g}from"@contractspec/lib.contracts-spec/examples";var h=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent
|
|
2
|
+
import{defineExample as g}from"@contractspec/lib.contracts-spec/examples";var h=g({meta:{key:"examples.product-intent",version:"1.0.0",title:"Product Intent",description:"Product intent example: evidence ingestion and prompt-ready outputs.",kind:"template",visibility:"experimental",stability:"experimental",owners:["@contractspec-core"],tags:["package","examples","product-intent"]},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["playground","specs"]},studio:{enabled:!1,installable:!1},mcp:{enabled:!1}},entrypoints:{packageName:"@contractspec/example.product-intent"}}),q=h;export{q as default,h as ExamplesProductIntentExample};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './example';
|
|
1
2
|
export { default as example } from './example';
|
|
2
3
|
export type { EvidenceLoadOptions, EvidenceLoadWithSignalsOptions, } from './load-evidence';
|
|
3
4
|
export { DEFAULT_CHUNK_SIZE, DEFAULT_EVIDENCE_ROOT, DEFAULT_TRANSCRIPT_DIRS, loadEvidenceChunks, loadEvidenceChunksWithSignals, } from './load-evidence';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{defineExample as C}from"@contractspec/lib.contracts-spec/examples";var
|
|
2
|
+
import{defineExample as C}from"@contractspec/lib.contracts-spec/examples";var D=C({meta:{key:"examples.product-intent",version:"1.0.0",title:"Product Intent",description:"Product intent example: evidence ingestion and prompt-ready outputs.",kind:"template",visibility:"experimental",stability:"experimental",owners:["@contractspec-core"],tags:["package","examples","product-intent"]},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["playground","specs"]},studio:{enabled:!1,installable:!1},mcp:{enabled:!1}},entrypoints:{packageName:"@contractspec/example.product-intent"}}),x=D;import{PosthogAnalyticsProvider as I}from"@contractspec/integration.providers-impls/impls/posthog";import{FunnelAnalyzer as F}from"@contractspec/lib.analytics/funnel";async function Y(O){let W=[],q=w(O.dateRange),G=await S(O,q);if(G)W.push(G);let H=await E(O,q);if(H)W.push(H);let J=await y(O);if(J)W.push(J);return W}async function S(O,W){if(!O.reader.queryHogQL)return null;let q=b(O.eventNames),G=O.limit??10,H=await O.reader.queryHogQL({query:["select"," event as eventName,"," count() as total","from events","where timestamp >= {dateFrom} and timestamp < {dateTo}",q.clause?`and ${q.clause}`:"","group by eventName","order by total desc",`limit ${G}`].filter(Boolean).join(`
|
|
3
3
|
`),values:{dateFrom:W.from.toISOString(),dateTo:W.to.toISOString(),...q.values}}),J=R(H);if(J.length===0)return null;let V=J.map((Q)=>{let Z=N(Q.eventName)??"unknown",X=h(Q.total);return`- ${Z}: ${X}`});return{chunkId:`posthog:event_summary:${W.from.toISOString()}`,text:[`PostHog event summary (${W.from.toISOString()} \u2192 ${W.to.toISOString()}):`,...V].join(`
|
|
4
|
-
`),meta:{source:"posthog",kind:"event_summary",dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function
|
|
4
|
+
`),meta:{source:"posthog",kind:"event_summary",dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function E(O,W){if(!O.funnel)return null;if(!O.reader.getEvents)return null;let q=[],G=O.funnel.steps.map((Q)=>Q.eventName);for(let Q of G)(await O.reader.getEvents({event:Q,dateRange:{from:W.from,to:W.to},limit:O.limit??500})).results.forEach((X)=>{q.push({name:X.event,userId:X.distinctId,tenantId:typeof X.properties?.tenantId==="string"?X.properties.tenantId:void 0,timestamp:X.timestamp,properties:X.properties})});if(q.length===0)return null;let V=new F().analyze(q,O.funnel).steps.map((Q)=>{return`- ${Q.step.eventName}: ${Q.count} (conversion ${Q.conversionRate}, drop-off ${Q.dropOffRate})`});return{chunkId:`posthog:funnel:${O.funnel.name}`,text:[`PostHog funnel analysis \u2014 ${O.funnel.name}:`,...V].join(`
|
|
5
5
|
`),meta:{source:"posthog",kind:"funnel",funnelName:O.funnel.name,dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function y(O){if(!O.includeFeatureFlags)return null;if(!O.reader.getFeatureFlags)return null;let W=await O.reader.getFeatureFlags({limit:10});if(!W.results.length)return null;return{chunkId:"posthog:feature_flags",text:["PostHog feature flags:",...W.results.map((G)=>{let H=G.key??"unknown",J=G.active?"active":"inactive";return`- ${H}: ${J}`})].join(`
|
|
6
|
-
`),meta:{source:"posthog",kind:"feature_flags"}}}function w(O){let W=new Date,q=O?.from instanceof Date?O.from:O?.from?new Date(O.from):new Date(W.getTime()-2592000000),G=O?.to instanceof Date?O.to:O?.to?new Date(O.to):W;return{from:q,to:G}}function b(O){if(!O||O.length===0)return{};if(O.length===1)return{clause:"event = {event0}",values:{event0:O[0]}};let W={};return{clause:`(${O.map((G,H)=>{return W[`event${H}`]=G,`event = {event${H}}`}).join(" or ")})`,values:W}}function R(O){if(!Array.isArray(O.results)||!Array.isArray(O.columns))return[];let W=O.columns;return O.results.flatMap((q)=>{if(!Array.isArray(q))return[];let G={};return W.forEach((H,J)=>{G[H]=q[J]}),[G]})}function N(O){if(typeof O==="string"&&O.trim())return O;if(typeof O==="number")return String(O);return null}function h(O){if(typeof O==="number"&&Number.isFinite(O))return O;if(typeof O==="string"&&O.trim()){let W=Number(O);if(Number.isFinite(W))return W}return 0}function k(O={}){let W=process.env.POSTHOG_PROJECT_ID,q=process.env.POSTHOG_PERSONAL_API_KEY;if(!W||!q)return null;let G=U("POSTHOG_EVIDENCE_LOOKBACK_DAYS",O.defaultLookbackDays??30),H=U("POSTHOG_EVIDENCE_LIMIT",O.defaultLimit??10),J=new Date,V=new Date(J.getTime()-G*24*60*60*1000),Q=T("POSTHOG_EVIDENCE_EVENTS"),Z=T("POSTHOG_EVIDENCE_FUNNEL_STEPS"),X=Z&&Z.length?{name:"posthog-evidence-funnel",steps:Z.map((B,L)=>({id:`step_${L+1}`,eventName:B}))}:void 0;return{reader:new I({host:process.env.POSTHOG_HOST,projectId:W,personalApiKey:q}),dateRange:{from:V,to:J},eventNames:Q,limit:H,funnel:X,includeFeatureFlags:m("POSTHOG_EVIDENCE_FEATURE_FLAGS",!0)}}function T(O){let W=process.env[O];if(!W)return;return W.split(",").map((q)=>q.trim()).filter(Boolean)}function U(O,W){let q=process.env[O];if(!q)return W;let G=Number(q);return Number.isFinite(G)?G:W}function m(O,W){let q=process.env[O];if(q===void 0)return W;return q.toLowerCase()==="true"}import _ from"fs";import $ from"path";import{fileURLToPath as f}from"url";var g=$.dirname(f(import.meta.url)),j=$.join(g,"../evidence"),M=["interviews","tickets","public"],
|
|
6
|
+
`),meta:{source:"posthog",kind:"feature_flags"}}}function w(O){let W=new Date,q=O?.from instanceof Date?O.from:O?.from?new Date(O.from):new Date(W.getTime()-2592000000),G=O?.to instanceof Date?O.to:O?.to?new Date(O.to):W;return{from:q,to:G}}function b(O){if(!O||O.length===0)return{};if(O.length===1)return{clause:"event = {event0}",values:{event0:O[0]}};let W={};return{clause:`(${O.map((G,H)=>{return W[`event${H}`]=G,`event = {event${H}}`}).join(" or ")})`,values:W}}function R(O){if(!Array.isArray(O.results)||!Array.isArray(O.columns))return[];let W=O.columns;return O.results.flatMap((q)=>{if(!Array.isArray(q))return[];let G={};return W.forEach((H,J)=>{G[H]=q[J]}),[G]})}function N(O){if(typeof O==="string"&&O.trim())return O;if(typeof O==="number")return String(O);return null}function h(O){if(typeof O==="number"&&Number.isFinite(O))return O;if(typeof O==="string"&&O.trim()){let W=Number(O);if(Number.isFinite(W))return W}return 0}function k(O={}){let W=process.env.POSTHOG_PROJECT_ID,q=process.env.POSTHOG_PERSONAL_API_KEY;if(!W||!q)return null;let G=U("POSTHOG_EVIDENCE_LOOKBACK_DAYS",O.defaultLookbackDays??30),H=U("POSTHOG_EVIDENCE_LIMIT",O.defaultLimit??10),J=new Date,V=new Date(J.getTime()-G*24*60*60*1000),Q=T("POSTHOG_EVIDENCE_EVENTS"),Z=T("POSTHOG_EVIDENCE_FUNNEL_STEPS"),X=Z&&Z.length?{name:"posthog-evidence-funnel",steps:Z.map((B,L)=>({id:`step_${L+1}`,eventName:B}))}:void 0;return{reader:new I({host:process.env.POSTHOG_HOST,projectId:W,personalApiKey:q}),dateRange:{from:V,to:J},eventNames:Q,limit:H,funnel:X,includeFeatureFlags:m("POSTHOG_EVIDENCE_FEATURE_FLAGS",!0)}}function T(O){let W=process.env[O];if(!W)return;return W.split(",").map((q)=>q.trim()).filter(Boolean)}function U(O,W){let q=process.env[O];if(!q)return W;let G=Number(q);return Number.isFinite(G)?G:W}function m(O,W){let q=process.env[O];if(q===void 0)return W;return q.toLowerCase()==="true"}import _ from"fs";import $ from"path";import{fileURLToPath as f}from"url";var g=$.dirname(f(import.meta.url)),j=$.join(g,"../evidence"),M=["interviews","tickets","public"],A=800;function d(O){let W=O.indexOf("---");if(W===-1)return O;let q=O.indexOf("---",W+3);if(q===-1)return O;return O.slice(q+3).trimStart()}function c(O,W,q){let G=[],H=W.trim();for(let J=0,V=0;J<H.length;V+=1){let Q=H.slice(J,J+q);G.push({chunkId:`${O}#c_${String(V).padStart(2,"0")}`,text:Q,meta:{source:O}}),J+=q}return G}function P(O={}){let W=O.evidenceRoot??j,q=O.transcriptDirs??M,G=O.chunkSize??A,H=[];for(let J of q){let V=$.join(W,J);if(!_.existsSync(V))continue;for(let Q of _.readdirSync(V)){if($.extname(Q).toLowerCase()!==".md")continue;let X=$.join(V,Q),K=_.readFileSync(X,"utf8"),B=d(K),L=$.parse(Q).name,z=c(L,B,G);H.push(...z)}}return H}async function v(O={}){let W=P(O);if(!O.posthog)return W;let q=await Y(O.posthog);return[...W,...q]}import{OwnersEnum as u,StabilityEnum as p}from"@contractspec/lib.contracts-spec/ownership";import{defineProductIntentSpec as r}from"@contractspec/lib.contracts-spec/product-intent/spec";var JO=r({id:"product-intent.discovery.activation",meta:{key:"product-intent.discovery.activation",version:"1.0.0",title:"Product Intent Discovery",description:"Discovery contract for activation friction using transcripts, analytics signals, and generated tasks.",domain:"product",owners:[u.PlatformCore],tags:["product-intent","discovery","activation","analytics"],stability:p.Experimental,goal:"Prioritize the next activation improvement with grounded evidence.",context:"Evidence is collected from interview transcripts, support tickets, and PostHog funnels before turning into task-ready outputs."},question:"Which activation and onboarding friction should we prioritize next?",runtimeContext:{evidenceRoot:"packages/examples/product-intent/evidence",analyticsProvider:"posthog"},tickets:{tickets:[{ticketId:"PI-101",title:"Add a guided onboarding checklist",summary:"Give new users an explicit checklist after signup so they can see the next activation milestone.",evidenceIds:["INT-002","INT-014","PH-dropoff-checkout"],acceptanceCriteria:["Users see a checklist within the first session.","Checklist completion is tracked in analytics."],priority:"high",tags:["activation","onboarding"]}]},tasks:{packId:"product-intent.discovery.activation.tasks",patchId:"product-intent.discovery.activation.patch",overview:"Introduce a checklist-driven onboarding path and instrument it for activation measurement.",tasks:[{id:"task-ui-checklist",title:"Model the onboarding checklist surface",surface:["ui","docs"],why:"The product intent needs a visible activation guide and matching contract docs.",acceptance:["A checklist surface is defined in contracts.","Documentation explains the activation milestone mapping."],agentPrompt:"Add the onboarding checklist contract surface and document the milestone states."},{id:"task-analytics-checklist",title:"Track checklist completion events",surface:["api","tests"],why:"Success must be measurable after rollout.",acceptance:["Checklist completion emits analytics events.","Tests cover the event contract and payload shape."],agentPrompt:"Emit activation checklist events and add test coverage for the telemetry payloads.",dependsOn:["task-ui-checklist"]}]}});import{defineFeature as i}from"@contractspec/lib.contracts-spec/features";var XO=i({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{k as resolvePosthogEvidenceOptionsFromEnv,Y as loadPosthogEvidenceChunks,v as loadEvidenceChunksWithSignals,P as loadEvidenceChunks,x as example,XO as ProductIntentFeature,JO as ProductIntentDiscoverySpec,D as ExamplesProductIntentExample,M as DEFAULT_TRANSCRIPT_DIRS,j as DEFAULT_EVIDENCE_ROOT,A as DEFAULT_CHUNK_SIZE};
|
package/dist/node/example.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineExample as g}from"@contractspec/lib.contracts-spec/examples";var h=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent
|
|
1
|
+
import{defineExample as g}from"@contractspec/lib.contracts-spec/examples";var h=g({meta:{key:"examples.product-intent",version:"1.0.0",title:"Product Intent",description:"Product intent example: evidence ingestion and prompt-ready outputs.",kind:"template",visibility:"experimental",stability:"experimental",owners:["@contractspec-core"],tags:["package","examples","product-intent"]},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["playground","specs"]},studio:{enabled:!1,installable:!1},mcp:{enabled:!1}},entrypoints:{packageName:"@contractspec/example.product-intent"}}),q=h;export{q as default,h as ExamplesProductIntentExample};
|
package/dist/node/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{defineExample as C}from"@contractspec/lib.contracts-spec/examples";var
|
|
1
|
+
import{defineExample as C}from"@contractspec/lib.contracts-spec/examples";var D=C({meta:{key:"examples.product-intent",version:"1.0.0",title:"Product Intent",description:"Product intent example: evidence ingestion and prompt-ready outputs.",kind:"template",visibility:"experimental",stability:"experimental",owners:["@contractspec-core"],tags:["package","examples","product-intent"]},surfaces:{templates:!0,sandbox:{enabled:!0,modes:["playground","specs"]},studio:{enabled:!1,installable:!1},mcp:{enabled:!1}},entrypoints:{packageName:"@contractspec/example.product-intent"}}),x=D;import{PosthogAnalyticsProvider as I}from"@contractspec/integration.providers-impls/impls/posthog";import{FunnelAnalyzer as F}from"@contractspec/lib.analytics/funnel";async function Y(O){let W=[],q=w(O.dateRange),G=await S(O,q);if(G)W.push(G);let H=await E(O,q);if(H)W.push(H);let J=await y(O);if(J)W.push(J);return W}async function S(O,W){if(!O.reader.queryHogQL)return null;let q=b(O.eventNames),G=O.limit??10,H=await O.reader.queryHogQL({query:["select"," event as eventName,"," count() as total","from events","where timestamp >= {dateFrom} and timestamp < {dateTo}",q.clause?`and ${q.clause}`:"","group by eventName","order by total desc",`limit ${G}`].filter(Boolean).join(`
|
|
2
2
|
`),values:{dateFrom:W.from.toISOString(),dateTo:W.to.toISOString(),...q.values}}),J=R(H);if(J.length===0)return null;let V=J.map((Q)=>{let Z=N(Q.eventName)??"unknown",X=h(Q.total);return`- ${Z}: ${X}`});return{chunkId:`posthog:event_summary:${W.from.toISOString()}`,text:[`PostHog event summary (${W.from.toISOString()} → ${W.to.toISOString()}):`,...V].join(`
|
|
3
|
-
`),meta:{source:"posthog",kind:"event_summary",dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function
|
|
3
|
+
`),meta:{source:"posthog",kind:"event_summary",dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function E(O,W){if(!O.funnel)return null;if(!O.reader.getEvents)return null;let q=[],G=O.funnel.steps.map((Q)=>Q.eventName);for(let Q of G)(await O.reader.getEvents({event:Q,dateRange:{from:W.from,to:W.to},limit:O.limit??500})).results.forEach((X)=>{q.push({name:X.event,userId:X.distinctId,tenantId:typeof X.properties?.tenantId==="string"?X.properties.tenantId:void 0,timestamp:X.timestamp,properties:X.properties})});if(q.length===0)return null;let V=new F().analyze(q,O.funnel).steps.map((Q)=>{return`- ${Q.step.eventName}: ${Q.count} (conversion ${Q.conversionRate}, drop-off ${Q.dropOffRate})`});return{chunkId:`posthog:funnel:${O.funnel.name}`,text:[`PostHog funnel analysis — ${O.funnel.name}:`,...V].join(`
|
|
4
4
|
`),meta:{source:"posthog",kind:"funnel",funnelName:O.funnel.name,dateFrom:W.from.toISOString(),dateTo:W.to.toISOString()}}}async function y(O){if(!O.includeFeatureFlags)return null;if(!O.reader.getFeatureFlags)return null;let W=await O.reader.getFeatureFlags({limit:10});if(!W.results.length)return null;return{chunkId:"posthog:feature_flags",text:["PostHog feature flags:",...W.results.map((G)=>{let H=G.key??"unknown",J=G.active?"active":"inactive";return`- ${H}: ${J}`})].join(`
|
|
5
|
-
`),meta:{source:"posthog",kind:"feature_flags"}}}function w(O){let W=new Date,q=O?.from instanceof Date?O.from:O?.from?new Date(O.from):new Date(W.getTime()-2592000000),G=O?.to instanceof Date?O.to:O?.to?new Date(O.to):W;return{from:q,to:G}}function b(O){if(!O||O.length===0)return{};if(O.length===1)return{clause:"event = {event0}",values:{event0:O[0]}};let W={};return{clause:`(${O.map((G,H)=>{return W[`event${H}`]=G,`event = {event${H}}`}).join(" or ")})`,values:W}}function R(O){if(!Array.isArray(O.results)||!Array.isArray(O.columns))return[];let W=O.columns;return O.results.flatMap((q)=>{if(!Array.isArray(q))return[];let G={};return W.forEach((H,J)=>{G[H]=q[J]}),[G]})}function N(O){if(typeof O==="string"&&O.trim())return O;if(typeof O==="number")return String(O);return null}function h(O){if(typeof O==="number"&&Number.isFinite(O))return O;if(typeof O==="string"&&O.trim()){let W=Number(O);if(Number.isFinite(W))return W}return 0}function k(O={}){let W=process.env.POSTHOG_PROJECT_ID,q=process.env.POSTHOG_PERSONAL_API_KEY;if(!W||!q)return null;let G=U("POSTHOG_EVIDENCE_LOOKBACK_DAYS",O.defaultLookbackDays??30),H=U("POSTHOG_EVIDENCE_LIMIT",O.defaultLimit??10),J=new Date,V=new Date(J.getTime()-G*24*60*60*1000),Q=T("POSTHOG_EVIDENCE_EVENTS"),Z=T("POSTHOG_EVIDENCE_FUNNEL_STEPS"),X=Z&&Z.length?{name:"posthog-evidence-funnel",steps:Z.map((B,L)=>({id:`step_${L+1}`,eventName:B}))}:void 0;return{reader:new I({host:process.env.POSTHOG_HOST,projectId:W,personalApiKey:q}),dateRange:{from:V,to:J},eventNames:Q,limit:H,funnel:X,includeFeatureFlags:m("POSTHOG_EVIDENCE_FEATURE_FLAGS",!0)}}function T(O){let W=process.env[O];if(!W)return;return W.split(",").map((q)=>q.trim()).filter(Boolean)}function U(O,W){let q=process.env[O];if(!q)return W;let G=Number(q);return Number.isFinite(G)?G:W}function m(O,W){let q=process.env[O];if(q===void 0)return W;return q.toLowerCase()==="true"}import _ from"node:fs";import $ from"node:path";import{fileURLToPath as f}from"node:url";var g=$.dirname(f(import.meta.url)),j=$.join(g,"../evidence"),M=["interviews","tickets","public"],
|
|
5
|
+
`),meta:{source:"posthog",kind:"feature_flags"}}}function w(O){let W=new Date,q=O?.from instanceof Date?O.from:O?.from?new Date(O.from):new Date(W.getTime()-2592000000),G=O?.to instanceof Date?O.to:O?.to?new Date(O.to):W;return{from:q,to:G}}function b(O){if(!O||O.length===0)return{};if(O.length===1)return{clause:"event = {event0}",values:{event0:O[0]}};let W={};return{clause:`(${O.map((G,H)=>{return W[`event${H}`]=G,`event = {event${H}}`}).join(" or ")})`,values:W}}function R(O){if(!Array.isArray(O.results)||!Array.isArray(O.columns))return[];let W=O.columns;return O.results.flatMap((q)=>{if(!Array.isArray(q))return[];let G={};return W.forEach((H,J)=>{G[H]=q[J]}),[G]})}function N(O){if(typeof O==="string"&&O.trim())return O;if(typeof O==="number")return String(O);return null}function h(O){if(typeof O==="number"&&Number.isFinite(O))return O;if(typeof O==="string"&&O.trim()){let W=Number(O);if(Number.isFinite(W))return W}return 0}function k(O={}){let W=process.env.POSTHOG_PROJECT_ID,q=process.env.POSTHOG_PERSONAL_API_KEY;if(!W||!q)return null;let G=U("POSTHOG_EVIDENCE_LOOKBACK_DAYS",O.defaultLookbackDays??30),H=U("POSTHOG_EVIDENCE_LIMIT",O.defaultLimit??10),J=new Date,V=new Date(J.getTime()-G*24*60*60*1000),Q=T("POSTHOG_EVIDENCE_EVENTS"),Z=T("POSTHOG_EVIDENCE_FUNNEL_STEPS"),X=Z&&Z.length?{name:"posthog-evidence-funnel",steps:Z.map((B,L)=>({id:`step_${L+1}`,eventName:B}))}:void 0;return{reader:new I({host:process.env.POSTHOG_HOST,projectId:W,personalApiKey:q}),dateRange:{from:V,to:J},eventNames:Q,limit:H,funnel:X,includeFeatureFlags:m("POSTHOG_EVIDENCE_FEATURE_FLAGS",!0)}}function T(O){let W=process.env[O];if(!W)return;return W.split(",").map((q)=>q.trim()).filter(Boolean)}function U(O,W){let q=process.env[O];if(!q)return W;let G=Number(q);return Number.isFinite(G)?G:W}function m(O,W){let q=process.env[O];if(q===void 0)return W;return q.toLowerCase()==="true"}import _ from"node:fs";import $ from"node:path";import{fileURLToPath as f}from"node:url";var g=$.dirname(f(import.meta.url)),j=$.join(g,"../evidence"),M=["interviews","tickets","public"],A=800;function d(O){let W=O.indexOf("---");if(W===-1)return O;let q=O.indexOf("---",W+3);if(q===-1)return O;return O.slice(q+3).trimStart()}function c(O,W,q){let G=[],H=W.trim();for(let J=0,V=0;J<H.length;V+=1){let Q=H.slice(J,J+q);G.push({chunkId:`${O}#c_${String(V).padStart(2,"0")}`,text:Q,meta:{source:O}}),J+=q}return G}function P(O={}){let W=O.evidenceRoot??j,q=O.transcriptDirs??M,G=O.chunkSize??A,H=[];for(let J of q){let V=$.join(W,J);if(!_.existsSync(V))continue;for(let Q of _.readdirSync(V)){if($.extname(Q).toLowerCase()!==".md")continue;let X=$.join(V,Q),K=_.readFileSync(X,"utf8"),B=d(K),L=$.parse(Q).name,z=c(L,B,G);H.push(...z)}}return H}async function v(O={}){let W=P(O);if(!O.posthog)return W;let q=await Y(O.posthog);return[...W,...q]}import{OwnersEnum as u,StabilityEnum as p}from"@contractspec/lib.contracts-spec/ownership";import{defineProductIntentSpec as r}from"@contractspec/lib.contracts-spec/product-intent/spec";var JO=r({id:"product-intent.discovery.activation",meta:{key:"product-intent.discovery.activation",version:"1.0.0",title:"Product Intent Discovery",description:"Discovery contract for activation friction using transcripts, analytics signals, and generated tasks.",domain:"product",owners:[u.PlatformCore],tags:["product-intent","discovery","activation","analytics"],stability:p.Experimental,goal:"Prioritize the next activation improvement with grounded evidence.",context:"Evidence is collected from interview transcripts, support tickets, and PostHog funnels before turning into task-ready outputs."},question:"Which activation and onboarding friction should we prioritize next?",runtimeContext:{evidenceRoot:"packages/examples/product-intent/evidence",analyticsProvider:"posthog"},tickets:{tickets:[{ticketId:"PI-101",title:"Add a guided onboarding checklist",summary:"Give new users an explicit checklist after signup so they can see the next activation milestone.",evidenceIds:["INT-002","INT-014","PH-dropoff-checkout"],acceptanceCriteria:["Users see a checklist within the first session.","Checklist completion is tracked in analytics."],priority:"high",tags:["activation","onboarding"]}]},tasks:{packId:"product-intent.discovery.activation.tasks",patchId:"product-intent.discovery.activation.patch",overview:"Introduce a checklist-driven onboarding path and instrument it for activation measurement.",tasks:[{id:"task-ui-checklist",title:"Model the onboarding checklist surface",surface:["ui","docs"],why:"The product intent needs a visible activation guide and matching contract docs.",acceptance:["A checklist surface is defined in contracts.","Documentation explains the activation milestone mapping."],agentPrompt:"Add the onboarding checklist contract surface and document the milestone states."},{id:"task-analytics-checklist",title:"Track checklist completion events",surface:["api","tests"],why:"Success must be measurable after rollout.",acceptance:["Checklist completion emits analytics events.","Tests cover the event contract and payload shape."],agentPrompt:"Emit activation checklist events and add test coverage for the telemetry payloads.",dependsOn:["task-ui-checklist"]}]}});import{defineFeature as i}from"@contractspec/lib.contracts-spec/features";var XO=i({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{k as resolvePosthogEvidenceOptionsFromEnv,Y as loadPosthogEvidenceChunks,v as loadEvidenceChunksWithSignals,P as loadEvidenceChunks,x as example,XO as ProductIntentFeature,JO as ProductIntentDiscoverySpec,D as ExamplesProductIntentExample,M as DEFAULT_TRANSCRIPT_DIRS,j as DEFAULT_EVIDENCE_ROOT,A as DEFAULT_CHUNK_SIZE};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineFeature as g}from"@contractspec/lib.contracts-spec";var j=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{j as ProductIntentFeature};
|
|
1
|
+
import{defineFeature as g}from"@contractspec/lib.contracts-spec/features";var j=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{j as ProductIntentFeature};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{defineFeature as g}from"@contractspec/lib.contracts-spec";var j=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{j as ProductIntentFeature};
|
|
2
|
+
import{defineFeature as g}from"@contractspec/lib.contracts-spec/features";var j=g({meta:{key:"product-intent",version:"1.0.0",title:"Product Intent",description:"Evidence ingestion, PostHog signals, and transcript-to-tickets discovery workflow",domain:"product",owners:["@examples"],tags:["product","intent","evidence","posthog"],stability:"experimental"},telemetry:[{key:"product-intent.telemetry",version:"1.0.0"}],docs:[]});export{j as ProductIntentFeature};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contractspec/example.product-intent",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.21",
|
|
4
4
|
"description": "Product intent example: evidence ingestion and prompt-ready outputs.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"contractspec",
|
|
@@ -89,17 +89,17 @@
|
|
|
89
89
|
"typecheck": "tsc --noEmit"
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
|
-
"@contractspec/lib.analytics": "3.7.
|
|
93
|
-
"@contractspec/lib.contracts-spec": "5.
|
|
94
|
-
"@contractspec/lib.contracts-integrations": "3.8.
|
|
95
|
-
"@contractspec/lib.ai-agent": "8.0.
|
|
96
|
-
"@contractspec/lib.product-intent-utils": "3.7.
|
|
97
|
-
"@contractspec/integration.providers-impls": "3.8.
|
|
92
|
+
"@contractspec/lib.analytics": "3.7.21",
|
|
93
|
+
"@contractspec/lib.contracts-spec": "5.5.0",
|
|
94
|
+
"@contractspec/lib.contracts-integrations": "3.8.13",
|
|
95
|
+
"@contractspec/lib.ai-agent": "8.0.9",
|
|
96
|
+
"@contractspec/lib.product-intent-utils": "3.7.21",
|
|
97
|
+
"@contractspec/integration.providers-impls": "3.8.13"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@contractspec/tool.typescript": "3.7.13",
|
|
101
101
|
"typescript": "^5.9.3",
|
|
102
|
-
"@contractspec/tool.bun": "3.7.
|
|
102
|
+
"@contractspec/tool.bun": "3.7.15"
|
|
103
103
|
},
|
|
104
104
|
"publishConfig": {
|
|
105
105
|
"access": "public",
|
package/src/example.ts
CHANGED
|
@@ -1,32 +1,28 @@
|
|
|
1
1
|
import { defineExample } from '@contractspec/lib.contracts-spec/examples';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const ExamplesProductIntentExample = defineExample({
|
|
4
4
|
meta: {
|
|
5
|
-
key: 'product-intent',
|
|
5
|
+
key: 'examples.product-intent',
|
|
6
6
|
version: '1.0.0',
|
|
7
|
-
title: 'Product Intent
|
|
7
|
+
title: 'Product Intent',
|
|
8
8
|
description:
|
|
9
|
-
'
|
|
10
|
-
kind: '
|
|
11
|
-
visibility: '
|
|
9
|
+
'Product intent example: evidence ingestion and prompt-ready outputs.',
|
|
10
|
+
kind: 'template',
|
|
11
|
+
visibility: 'experimental',
|
|
12
12
|
stability: 'experimental',
|
|
13
|
-
owners: ['@
|
|
14
|
-
tags: ['
|
|
15
|
-
},
|
|
16
|
-
docs: {
|
|
17
|
-
rootDocId: 'docs.examples.product-intent',
|
|
18
|
-
usageDocId: 'docs.examples.product-intent.usage',
|
|
19
|
-
},
|
|
20
|
-
entrypoints: {
|
|
21
|
-
packageName: '@contractspec/example.product-intent',
|
|
22
|
-
docs: './docs',
|
|
13
|
+
owners: ['@contractspec-core'],
|
|
14
|
+
tags: ['package', 'examples', 'product-intent'],
|
|
23
15
|
},
|
|
24
16
|
surfaces: {
|
|
25
|
-
templates:
|
|
26
|
-
sandbox: { enabled:
|
|
17
|
+
templates: true,
|
|
18
|
+
sandbox: { enabled: true, modes: ['playground', 'specs'] },
|
|
27
19
|
studio: { enabled: false, installable: false },
|
|
28
20
|
mcp: { enabled: false },
|
|
29
21
|
},
|
|
22
|
+
entrypoints: {
|
|
23
|
+
packageName: '@contractspec/example.product-intent',
|
|
24
|
+
},
|
|
30
25
|
});
|
|
31
26
|
|
|
32
|
-
export default
|
|
27
|
+
export default ExamplesProductIntentExample;
|
|
28
|
+
export { ExamplesProductIntentExample };
|
package/src/index.ts
CHANGED