Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .trajectories/completed/2026-05/traj_rdhqus1o0ci8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"id": "traj_rdhqus1o0ci8",
"version": 1,
"task": {
"title": "Add typed ProactiveCapabilities to persona-kit PersonaSpec"
},
"status": "completed",
"startedAt": "2026-05-31T10:29:26.181Z",
"completedAt": "2026-05-31T10:32:51.807Z",
"agents": [
{
"name": "default",
"role": "lead",
"joinedAt": "2026-05-31T10:29:31.307Z"
}
],
"chapters": [
{
"id": "chap_19bcnrc6w4th",
"title": "Work",
"agentName": "default",
"startedAt": "2026-05-31T10:29:31.307Z",
"endedAt": "2026-05-31T10:32:51.807Z",
"events": [
{
"ts": 1780223371308,
"type": "decision",
"content": "Preserve capabilities in parsePersonaSpec: Preserve capabilities in parsePersonaSpec",
"raw": {
"question": "Preserve capabilities in parsePersonaSpec",
"chosen": "Preserve capabilities in parsePersonaSpec",
"alternatives": [],
"reasoning": "parsePersonaSpec reconstructs PersonaSpec and drops unknown top-level fields, so the new optional field needs parser support for define/parse round-trip"
},
"significance": "high"
}
]
}
],
"retrospective": {
"summary": "Added optional typed proactive capabilities to persona-kit PersonaSpec, exported the canonical types, preserved capabilities through define/parse, regenerated schema, bumped package version to 3.0.34, and validated build/typecheck/test.",
"approach": "Standard approach",
"confidence": 0.9
},
"commits": [],
"filesChanged": [],
"projectId": "/private/tmp/wt-pk",
"tags": [],
"_trace": {
"startRef": "a380c74cc90bbe0d9f1bc897b1cbb36808586eea",
"endRef": "a380c74cc90bbe0d9f1bc897b1cbb36808586eea"
}
}
31 changes: 31 additions & 0 deletions .trajectories/completed/2026-05/traj_rdhqus1o0ci8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Trajectory: Add typed ProactiveCapabilities to persona-kit PersonaSpec

> **Status:** ✅ Completed
> **Confidence:** 90%
> **Started:** May 31, 2026 at 12:29 PM
> **Completed:** May 31, 2026 at 12:32 PM

---

## Summary

Added optional typed proactive capabilities to persona-kit PersonaSpec, exported the canonical types, preserved capabilities through define/parse, regenerated schema, bumped package version to 3.0.34, and validated build/typecheck/test.

**Approach:** Standard approach

---

## Key Decisions

### Preserve capabilities in parsePersonaSpec
- **Chose:** Preserve capabilities in parsePersonaSpec
- **Reasoning:** parsePersonaSpec reconstructs PersonaSpec and drops unknown top-level fields, so the new optional field needs parser support for define/parse round-trip

---

## Chapters

### 1. Work
*Agent: default*

- Preserve capabilities in parsePersonaSpec: Preserve capabilities in parsePersonaSpec
9 changes: 8 additions & 1 deletion .trajectories/index.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"lastUpdated": "2026-05-28T07:47:24.572Z",
"lastUpdated": "2026-05-31T10:32:51.951Z",
"trajectories": {
"traj_1775734701264_ba65c69b": {
"title": "finish-npm-provenance-persona-workflow",
Expand Down Expand Up @@ -43,6 +43,13 @@
"startedAt": "2026-05-28T07:46:09.716Z",
"completedAt": "2026-05-28T07:47:24.475Z",
"path": "/Users/khaliqgant/Projects/AgentWorkforce/workforce-issue-154/.trajectories/completed/2026-05/traj_61qz5tibb2lm.json"
},
"traj_rdhqus1o0ci8": {
"title": "Add typed ProactiveCapabilities to persona-kit PersonaSpec",
"status": "completed",
"startedAt": "2026-05-31T10:29:26.181Z",
"completedAt": "2026-05-31T10:32:51.807Z",
"path": "/private/tmp/wt-pk/.trajectories/completed/2026-05/traj_rdhqus1o0ci8.json"
}
}
}
6 changes: 6 additions & 0 deletions packages/persona-kit/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.0.34] - 2026-05-31

### Added

- Add typed proactive capabilities to `PersonaSpec`.

## [3.0.33] - 2026-05-29

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion packages/persona-kit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agentworkforce/persona-kit",
"version": "3.0.33",
"version": "3.0.34",
"private": false,
"type": "module",
"main": "dist/index.js",
Expand Down
42 changes: 42 additions & 0 deletions packages/persona-kit/schemas/persona.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@
},
"description": "Relayfile-change listeners for proactive cloud personas."
},
"capabilities": {
"$ref": "#/definitions/ProactiveCapabilities",
"description": "Portable proactive capability declarations. A capability is enabled when its value is `true` or an object whose `.enabled !== false` (`{}` is enabled; `{ enabled: false }` is disabled). `pullRequest` is the legacy alias of `review`; both map to the review capability."
},
"memory": {
"$ref": "#/definitions/PersonaMemory",
"description": "Memory subsystem opt-in. Wires the agent-assistant memory adapter at runtime; the persona spec only declares intent, not implementation details (api keys, adapter type, etc. come from workforce env)."
Expand Down Expand Up @@ -561,6 +565,44 @@
"deleted"
]
},
"ProactiveCapabilities": {
"type": "object",
"properties": {
"review": {
"$ref": "#/definitions/CapabilityValue",
"description": "Review a PR/MR diff and post a review."
},
"issueClaim": {
"$ref": "#/definitions/CapabilityValue",
"description": "Claim an issue and open a change request."
},
"conflictAutofix": {
"$ref": "#/definitions/CapabilityValue",
"description": "Rebase a dirty PR/MR."
},
"pullRequest": {
"$ref": "#/definitions/CapabilityValue",
"description": "Legacy alias of `review`."
}
},
"description": "Portable proactive capability declarations.\n\nA capability is enabled when its value is `true` or an object whose `.enabled !== false` (`{}` is enabled; `{ enabled: false }` is disabled). `pullRequest` is the legacy alias of `review`; both map to the review capability."
},
"CapabilityValue": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "object",
"properties": {
"enabled": {
"type": "boolean"
}
},
"additionalProperties": {}
}
]
},
"PersonaMemory": {
"anyOf": [
{
Expand Down
6 changes: 6 additions & 0 deletions packages/persona-kit/src/__fixtures__/personas/full.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@
}
},
"schedules": [{ "name": "daily-review", "cron": "0 14 * * 1-5", "tz": "UTC" }],
"capabilities": {
"review": true,
"issueClaim": {},
"conflictAutofix": { "enabled": false },
"pullRequest": { "enabled": true }
},
"memory": {
"enabled": true,
"scopes": ["workspace", "user", "global"],
Expand Down
8 changes: 8 additions & 0 deletions packages/persona-kit/src/define.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ test('definePersona returns authored specs that parse successfully', () => {
jira: { triggers: [{ on: 'comment.created' }] },
customProvider: { triggers: [{ on: 'custom.event' }] }
},
capabilities: {
review: true,
conflictAutofix: { enabled: false }
},
onEvent: './agent.ts',
harnessSettings: { reasoning: 'medium', timeoutSeconds: 300 }
});
Expand All @@ -42,6 +46,10 @@ test('definePersona returns authored specs that parse successfully', () => {
'off_registry.github_event'
);
assert.equal(parsed.integrations?.customProvider.triggers?.[0].on, 'custom.event');
assert.deepEqual(parsed.capabilities, {
review: true,
conflictAutofix: { enabled: false }
});
});

test('definePersona types tags against the closed PersonaTag vocabulary', () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/persona-kit/src/define.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type {
ProactiveCapabilities,
Harness,
HarnessSettings,
IntegrationSource,
Expand Down Expand Up @@ -62,6 +63,7 @@ export interface PersonaDefinitionBase {
integrations?: TypedIntegrations;
schedules?: readonly PersonaSchedule[];
watch?: readonly WatchRule[];
capabilities?: ProactiveCapabilities;
memory?: PersonaMemory;
}

Expand Down
3 changes: 3 additions & 0 deletions packages/persona-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type { KnownPersonaTag } from './constants.js';

// Types
export type {
CapabilityValue,
CodexApprovalPolicy,
CodexSandboxMode,
Harness,
Expand All @@ -40,6 +41,7 @@ export type {
PersonaSkill,
PersonaSpec,
PersonaTag,
ProactiveCapabilities,
SidecarMdMode,
SkillInstall,
SkillMaterializationOptions,
Expand Down Expand Up @@ -71,6 +73,7 @@ export {
isObject,
isSidecarMode,
isTag,
parseCapabilities,
parseHarnessSettings,
parseInputs,
parseIntegrationConfig,
Expand Down
46 changes: 46 additions & 0 deletions packages/persona-kit/src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
SIDECAR_MD_MODES
} from './constants.js';
import type {
CapabilityValue,
CodexApprovalPolicy,
CodexSandboxMode,
Harness,
Expand All @@ -29,6 +30,7 @@ import type {
PersonaSkill,
PersonaSpec,
PersonaTag,
ProactiveCapabilities,
SidecarMdMode,
WatchEvent,
WatchRule
Expand Down Expand Up @@ -851,6 +853,44 @@ export function parseMemory(value: unknown, context: string): PersonaMemory | un
return out;
}

function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Top-level capabilities accepts array. Invalid config gets silently ignored. Reject array input.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/persona-kit/src/parse.ts, line 858:

<comment>Top-level capabilities accepts array. Invalid config gets silently ignored. Reject array input.</comment>

<file context>
@@ -851,6 +853,44 @@ export function parseMemory(value: unknown, context: string): PersonaMemory | un
 
+function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
+  if (typeof value === 'boolean') return value;
+  if (!isObject(value)) {
+    throw new Error(`${context} must be a boolean or object if provided`);
+  }
</file context>
Suggested change
if (!isObject(value)) {
if (!isObject(value) || Array.isArray(value)) {

throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}

export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value)) {
throw new Error(`${context} must be an object if provided`);
}
Comment on lines +856 to +874
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In JavaScript/TypeScript, typeof [] is 'object' and null is already checked by isObject, but arrays will still pass the isObject check. This means that if an array is passed as a capability value (e.g., review: [true]) or for the capabilities field itself (e.g., capabilities: []), it will not throw a validation error. Instead, parseCapabilityValue will return an object representation of the array (e.g., { '0': true }), and parseCapabilities will silently ignore the array and return undefined.

To prevent this, we should explicitly check and reject arrays using Array.isArray(value).

Suggested change
function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value)) {
throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}
export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value)) {
throw new Error(`${context} must be an object if provided`);
}
function parseCapabilityValue(value: unknown, context: string): CapabilityValue {
if (typeof value === 'boolean') return value;
if (!isObject(value) || Array.isArray(value)) {
throw new Error(`${context} must be a boolean or object if provided`);
}
if (value.enabled !== undefined && typeof value.enabled !== 'boolean') {
throw new Error(`${context}.enabled must be a boolean if provided`);
}
return { ...value } as CapabilityValue;
}
export function parseCapabilities(
value: unknown,
context: string
): ProactiveCapabilities | undefined {
if (value === undefined) return undefined;
if (!isObject(value) || Array.isArray(value)) {
throw new Error(`${context} must be an object if provided`);
}


const out: ProactiveCapabilities = {};
const { review, issueClaim, conflictAutofix, pullRequest } = value;
if (review !== undefined) {
out.review = parseCapabilityValue(review, `${context}.review`);
}
if (issueClaim !== undefined) {
out.issueClaim = parseCapabilityValue(issueClaim, `${context}.issueClaim`);
}
if (conflictAutofix !== undefined) {
out.conflictAutofix = parseCapabilityValue(conflictAutofix, `${context}.conflictAutofix`);
}
if (pullRequest !== undefined) {
out.pullRequest = parseCapabilityValue(pullRequest, `${context}.pullRequest`);
}

return Object.keys(out).length > 0 ? out : undefined;
}

export function parseOnEvent(value: unknown, context: string): string | undefined {
if (value === undefined) return undefined;
return assertOnEventPath(value, context);
Expand Down Expand Up @@ -893,6 +933,7 @@ export function parsePersonaSpec(value: unknown, expectedIntent: PersonaIntent):
integrations,
schedules,
watch,
capabilities,
memory,
onEvent
} = value;
Expand Down Expand Up @@ -998,6 +1039,10 @@ export function parsePersonaSpec(value: unknown, expectedIntent: PersonaIntent):
);
const parsedSchedules = parseSchedules(schedules, `persona[${expectedIntent}].schedules`);
const parsedWatch = parseWatch(watch, `persona[${expectedIntent}].watch`);
const parsedCapabilities = parseCapabilities(
capabilities,
`persona[${expectedIntent}].capabilities`
);
const parsedMemory = parseMemory(memory, `persona[${expectedIntent}].memory`);
const parsedOnEvent = parseOnEvent(onEvent, `persona[${expectedIntent}].onEvent`);
const parsedSandbox = parseSandbox(sandbox, `persona[${expectedIntent}].sandbox`);
Expand Down Expand Up @@ -1029,6 +1074,7 @@ export function parsePersonaSpec(value: unknown, expectedIntent: PersonaIntent):
...(parsedIntegrations ? { integrations: parsedIntegrations } : {}),
...(parsedSchedules ? { schedules: parsedSchedules } : {}),
...(parsedWatch ? { watch: parsedWatch } : {}),
...(parsedCapabilities ? { capabilities: parsedCapabilities } : {}),
...(parsedMemory !== undefined ? { memory: parsedMemory } : {}),
...(parsedOnEvent !== undefined ? { onEvent: parsedOnEvent } : {})
};
Expand Down
30 changes: 30 additions & 0 deletions packages/persona-kit/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,29 @@ export interface PersonaMemoryConfig {

export type PersonaMemory = boolean | PersonaMemoryConfig;

export type CapabilityValue =
| boolean
| { enabled?: boolean; [k: string]: unknown };

/**
* Portable proactive capability declarations.
*
* A capability is enabled when its value is `true` or an object whose
* `.enabled !== false` (`{}` is enabled; `{ enabled: false }` is disabled).
* `pullRequest` is the legacy alias of `review`; both map to the review
* capability.
*/
export interface ProactiveCapabilities {
/** Review a PR/MR diff and post a review. */
review?: CapabilityValue;
/** Claim an issue and open a change request. */
issueClaim?: CapabilityValue;
/** Rebase a dirty PR/MR. */
conflictAutofix?: CapabilityValue;
/** Legacy alias of `review`. */
pullRequest?: CapabilityValue;
}

/**
* A persona listens for events. Three listener kinds: clock (cron schedules
* through `schedules[]`), radio (RelayFile integration events through
Expand Down Expand Up @@ -421,6 +444,13 @@ export interface PersonaSpec {
schedules?: PersonaSchedule[];
/** Relayfile-change listeners for proactive cloud personas. */
watch?: WatchRule[];
/**
* Portable proactive capability declarations. A capability is enabled when
* its value is `true` or an object whose `.enabled !== false` (`{}` is
* enabled; `{ enabled: false }` is disabled). `pullRequest` is the legacy
* alias of `review`; both map to the review capability.
*/
capabilities?: ProactiveCapabilities;
/**
* Memory subsystem opt-in. Wires the agent-assistant memory adapter at
* runtime; the persona spec only declares intent, not implementation
Expand Down
Loading