Skip to content

Commit 188f4e5

Browse files
G9Pedrocursoragent
andauthored
feat: company context graph primitives + orientation upgrade
* feat(kernel): add company context primitives and brief model Co-authored-by: G9Pedro <G9Pedro@users.noreply.github.com> * feat(mcp): add company context and context-capture tools Co-authored-by: G9Pedro <G9Pedro@users.noreply.github.com> * test(kernel): refresh schema snapshot and webhook outbox assertions Co-authored-by: G9Pedro <G9Pedro@users.noreply.github.com> * test(kernel): keep decision seed policy-compliant Co-authored-by: G9Pedro <G9Pedro@users.noreply.github.com> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: G9Pedro <G9Pedro@users.noreply.github.com>
1 parent 4915cd8 commit 188f4e5

16 files changed

Lines changed: 926 additions & 7 deletions

packages/kernel/src/__snapshots__/schema-drift-regression.test.ts.snap

Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,117 @@ exports[`schema drift regression > locks MCP tool metadata and input schemas 1`]
11191119
"name": "workgraph_checkpoint_create",
11201120
"title": "Checkpoint Create",
11211121
},
1122+
{
1123+
"annotations": {
1124+
"idempotentHint": true,
1125+
"readOnlyHint": true,
1126+
},
1127+
"description": "Return company context graph view for an actor.",
1128+
"inputSchema": {
1129+
"$schema": "http://json-schema.org/draft-07/schema#",
1130+
"properties": {
1131+
"actor": {
1132+
"type": "string",
1133+
},
1134+
},
1135+
"type": "object",
1136+
},
1137+
"name": "workgraph_company_context",
1138+
"title": "Workgraph Company Context",
1139+
},
1140+
{
1141+
"annotations": {
1142+
"destructiveHint": true,
1143+
"idempotentHint": false,
1144+
},
1145+
"description": "Create a decision primitive with rationale, participants, and alternatives.",
1146+
"inputSchema": {
1147+
"$schema": "http://json-schema.org/draft-07/schema#",
1148+
"properties": {
1149+
"actor": {
1150+
"type": "string",
1151+
},
1152+
"alternatives": {
1153+
"items": {
1154+
"type": "string",
1155+
},
1156+
"type": "array",
1157+
},
1158+
"body": {
1159+
"type": "string",
1160+
},
1161+
"consequences": {
1162+
"items": {
1163+
"type": "string",
1164+
},
1165+
"type": "array",
1166+
},
1167+
"contextRefs": {
1168+
"items": {
1169+
"type": "string",
1170+
},
1171+
"type": "array",
1172+
},
1173+
"date": {
1174+
"type": "string",
1175+
},
1176+
"decidedBy": {
1177+
"type": "string",
1178+
},
1179+
"externalLinks": {
1180+
"items": {
1181+
"type": "string",
1182+
},
1183+
"type": "array",
1184+
},
1185+
"participants": {
1186+
"items": {
1187+
"type": "string",
1188+
},
1189+
"type": "array",
1190+
},
1191+
"rationale": {
1192+
"type": "string",
1193+
},
1194+
"relatedRefs": {
1195+
"items": {
1196+
"type": "string",
1197+
},
1198+
"type": "array",
1199+
},
1200+
"status": {
1201+
"enum": [
1202+
"draft",
1203+
"proposed",
1204+
"approved",
1205+
"active",
1206+
"superseded",
1207+
"reverted",
1208+
],
1209+
"type": "string",
1210+
},
1211+
"supersedes": {
1212+
"type": "string",
1213+
},
1214+
"tags": {
1215+
"items": {
1216+
"type": "string",
1217+
},
1218+
"type": "array",
1219+
},
1220+
"title": {
1221+
"minLength": 1,
1222+
"type": "string",
1223+
},
1224+
},
1225+
"required": [
1226+
"title",
1227+
],
1228+
"type": "object",
1229+
},
1230+
"name": "workgraph_create_decision",
1231+
"title": "Decision Create",
1232+
},
11221233
{
11231234
"annotations": {
11241235
"destructiveHint": true,
@@ -1807,6 +1918,136 @@ exports[`schema drift regression > locks MCP tool metadata and input schemas 1`]
18071918
"name": "workgraph_query",
18081919
"title": "Workgraph Query",
18091920
},
1921+
{
1922+
"annotations": {
1923+
"destructiveHint": true,
1924+
"idempotentHint": false,
1925+
},
1926+
"description": "Record a lesson with severity and source event context.",
1927+
"inputSchema": {
1928+
"$schema": "http://json-schema.org/draft-07/schema#",
1929+
"properties": {
1930+
"actor": {
1931+
"type": "string",
1932+
},
1933+
"appliesTo": {
1934+
"items": {
1935+
"type": "string",
1936+
},
1937+
"type": "array",
1938+
},
1939+
"body": {
1940+
"type": "string",
1941+
},
1942+
"confidence": {
1943+
"type": "string",
1944+
},
1945+
"contextRefs": {
1946+
"items": {
1947+
"type": "string",
1948+
},
1949+
"type": "array",
1950+
},
1951+
"date": {
1952+
"type": "string",
1953+
},
1954+
"relatedRefs": {
1955+
"items": {
1956+
"type": "string",
1957+
},
1958+
"type": "array",
1959+
},
1960+
"severity": {
1961+
"enum": [
1962+
"critical",
1963+
"important",
1964+
"minor",
1965+
],
1966+
"type": "string",
1967+
},
1968+
"sourceEvent": {
1969+
"type": "string",
1970+
},
1971+
"tags": {
1972+
"items": {
1973+
"type": "string",
1974+
},
1975+
"type": "array",
1976+
},
1977+
"title": {
1978+
"minLength": 1,
1979+
"type": "string",
1980+
},
1981+
},
1982+
"required": [
1983+
"title",
1984+
],
1985+
"type": "object",
1986+
},
1987+
"name": "workgraph_record_lesson",
1988+
"title": "Lesson Record",
1989+
},
1990+
{
1991+
"annotations": {
1992+
"destructiveHint": true,
1993+
"idempotentHint": false,
1994+
},
1995+
"description": "Record a reusable pattern with steps and exceptions.",
1996+
"inputSchema": {
1997+
"$schema": "http://json-schema.org/draft-07/schema#",
1998+
"properties": {
1999+
"actor": {
2000+
"type": "string",
2001+
},
2002+
"appliesTo": {
2003+
"items": {
2004+
"type": "string",
2005+
},
2006+
"type": "array",
2007+
},
2008+
"body": {
2009+
"type": "string",
2010+
},
2011+
"description": {
2012+
"type": "string",
2013+
},
2014+
"exceptions": {
2015+
"items": {
2016+
"type": "string",
2017+
},
2018+
"type": "array",
2019+
},
2020+
"relatedRefs": {
2021+
"items": {
2022+
"type": "string",
2023+
},
2024+
"type": "array",
2025+
},
2026+
"steps": {
2027+
"items": {
2028+
"type": "string",
2029+
},
2030+
"type": "array",
2031+
},
2032+
"tags": {
2033+
"items": {
2034+
"type": "string",
2035+
},
2036+
"type": "array",
2037+
},
2038+
"title": {
2039+
"minLength": 1,
2040+
"type": "string",
2041+
},
2042+
},
2043+
"required": [
2044+
"title",
2045+
],
2046+
"type": "object",
2047+
},
2048+
"name": "workgraph_record_pattern",
2049+
"title": "Pattern Record",
2050+
},
18102051
{
18112052
"annotations": {
18122053
"destructiveHint": true,

packages/kernel/src/orientation.test.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ describe('orientation core module', () => {
7474
expect(brief.blockedThreads.map((entry) => entry.path)).toContain('threads/someone-else.md');
7575
expect(brief.nextReadyThreads).toHaveLength(1);
7676
expect(brief.recentActivity).toHaveLength(1);
77+
expect(brief.companyContext.teams).toEqual([]);
78+
expect(brief.companyContext.clients).toEqual([]);
79+
expect(brief.companyContext.recentDecisions).toEqual([]);
80+
expect(brief.companyContext.patterns).toEqual([]);
7781
});
7882

7983
it('creates checkpoint primitives with explicit next/blocked sections', () => {
@@ -139,4 +143,83 @@ describe('orientation core module', () => {
139143
expect(brief.myOpenThreads).toEqual([]);
140144
expect(brief.nextReadyThreads.length).toBeGreaterThanOrEqual(1);
141145
});
146+
147+
it('includes company context in actor brief', () => {
148+
const now = new Date().toISOString();
149+
store.create(
150+
workspacePath,
151+
'org',
152+
{
153+
title: 'Versatly',
154+
mission: 'Make autonomous coordination reliable.',
155+
strategy: 'Invest in company context graph primitives.',
156+
},
157+
'Org context',
158+
'agent-seed',
159+
);
160+
store.create(
161+
workspacePath,
162+
'team',
163+
{
164+
title: 'Platform',
165+
members: ['agent-focus', 'agent-other'],
166+
responsibilities: ['runtime', 'mcp'],
167+
},
168+
'Team context',
169+
'agent-seed',
170+
);
171+
store.create(
172+
workspacePath,
173+
'client',
174+
{
175+
name: 'Acme Corp',
176+
status: 'active',
177+
description: 'Strategic customer',
178+
},
179+
'Client context',
180+
'agent-seed',
181+
);
182+
store.create(
183+
workspacePath,
184+
'decision',
185+
{
186+
title: 'Adopt company context graph',
187+
date: now,
188+
status: 'draft',
189+
decided_by: 'agent-focus',
190+
},
191+
'Decision context',
192+
'agent-seed',
193+
);
194+
store.create(
195+
workspacePath,
196+
'pattern',
197+
{
198+
title: 'Weekly context sync',
199+
description: 'Capture and refresh context every Friday',
200+
},
201+
'Pattern context',
202+
'agent-seed',
203+
);
204+
store.create(
205+
workspacePath,
206+
'agent',
207+
{
208+
name: 'agent-focus',
209+
capabilities: ['briefing', 'coordination'],
210+
permissions: ['mcp:write'],
211+
},
212+
'Agent profile',
213+
'agent-seed',
214+
);
215+
216+
const brief = orientation.brief(workspacePath, 'agent-focus');
217+
expect(brief.companyContext.org?.title).toBe('Versatly');
218+
expect(brief.companyContext.teams[0]?.title).toBe('Platform');
219+
expect(brief.companyContext.clients[0]?.title).toBe('Acme Corp');
220+
expect(brief.companyContext.recentDecisions[0]?.decidedBy).toBe('agent-focus');
221+
expect(brief.companyContext.patterns[0]?.title).toBe('Weekly context sync');
222+
expect(brief.companyContext.agentProfile?.name).toBe('agent-focus');
223+
expect(brief.companyContext.agentProfile?.permissions).toEqual(['mcp:write']);
224+
});
142225
});

0 commit comments

Comments
 (0)