@cleocode/contracts 2.0.0
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/dist/adapter.d.ts +36 -0
- package/dist/adapter.d.ts.map +1 -0
- package/dist/adapter.js +8 -0
- package/dist/adapter.js.map +1 -0
- package/dist/archive.d.ts +100 -0
- package/dist/archive.d.ts.map +1 -0
- package/dist/archive.js +7 -0
- package/dist/archive.js.map +1 -0
- package/dist/brain.d.ts +36 -0
- package/dist/brain.d.ts.map +1 -0
- package/dist/brain.js +10 -0
- package/dist/brain.js.map +1 -0
- package/dist/capabilities.d.ts +21 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +7 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/config.d.ts +118 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +12 -0
- package/dist/config.js.map +1 -0
- package/dist/context-monitor.d.ts +16 -0
- package/dist/context-monitor.d.ts.map +1 -0
- package/dist/context-monitor.js +7 -0
- package/dist/context-monitor.js.map +1 -0
- package/dist/data-accessor.d.ts +167 -0
- package/dist/data-accessor.d.ts.map +1 -0
- package/dist/data-accessor.js +18 -0
- package/dist/data-accessor.js.map +1 -0
- package/dist/discovery.d.ts +29 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +7 -0
- package/dist/discovery.js.map +1 -0
- package/dist/exit-codes.d.ts +109 -0
- package/dist/exit-codes.d.ts.map +1 -0
- package/dist/exit-codes.js +158 -0
- package/dist/exit-codes.js.map +1 -0
- package/dist/hooks.d.ts +17 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +8 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/install.d.ts +26 -0
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +8 -0
- package/dist/install.js.map +1 -0
- package/dist/lafs.d.ts +132 -0
- package/dist/lafs.d.ts.map +1 -0
- package/dist/lafs.js +26 -0
- package/dist/lafs.js.map +1 -0
- package/dist/memory.d.ts +51 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +8 -0
- package/dist/memory.js.map +1 -0
- package/dist/operations/index.d.ts +17 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +17 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/issues.d.ts +75 -0
- package/dist/operations/issues.d.ts.map +1 -0
- package/dist/operations/issues.js +10 -0
- package/dist/operations/issues.js.map +1 -0
- package/dist/operations/lifecycle.d.ts +141 -0
- package/dist/operations/lifecycle.d.ts.map +1 -0
- package/dist/operations/lifecycle.js +8 -0
- package/dist/operations/lifecycle.js.map +1 -0
- package/dist/operations/orchestrate.d.ts +202 -0
- package/dist/operations/orchestrate.d.ts.map +1 -0
- package/dist/operations/orchestrate.js +8 -0
- package/dist/operations/orchestrate.js.map +1 -0
- package/dist/operations/release.d.ts +97 -0
- package/dist/operations/release.d.ts.map +1 -0
- package/dist/operations/release.js +7 -0
- package/dist/operations/release.js.map +1 -0
- package/dist/operations/research.d.ts +126 -0
- package/dist/operations/research.d.ts.map +1 -0
- package/dist/operations/research.js +11 -0
- package/dist/operations/research.js.map +1 -0
- package/dist/operations/session.d.ts +99 -0
- package/dist/operations/session.d.ts.map +1 -0
- package/dist/operations/session.js +12 -0
- package/dist/operations/session.js.map +1 -0
- package/dist/operations/skills.d.ts +182 -0
- package/dist/operations/skills.d.ts.map +1 -0
- package/dist/operations/skills.js +10 -0
- package/dist/operations/skills.js.map +1 -0
- package/dist/operations/system.d.ts +147 -0
- package/dist/operations/system.d.ts.map +1 -0
- package/dist/operations/system.js +8 -0
- package/dist/operations/system.js.map +1 -0
- package/dist/operations/tasks.d.ts +231 -0
- package/dist/operations/tasks.d.ts.map +1 -0
- package/dist/operations/tasks.js +13 -0
- package/dist/operations/tasks.js.map +1 -0
- package/dist/operations/validate.d.ts +170 -0
- package/dist/operations/validate.d.ts.map +1 -0
- package/dist/operations/validate.js +8 -0
- package/dist/operations/validate.js.map +1 -0
- package/dist/provider-paths.d.ts +16 -0
- package/dist/provider-paths.d.ts.map +1 -0
- package/dist/provider-paths.js +7 -0
- package/dist/provider-paths.js.map +1 -0
- package/dist/results.d.ts +188 -0
- package/dist/results.d.ts.map +1 -0
- package/dist/results.js +10 -0
- package/dist/results.js.map +1 -0
- package/dist/session.d.ts +106 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +77 -0
- package/dist/session.js.map +1 -0
- package/dist/spawn-types.d.ts +119 -0
- package/dist/spawn-types.d.ts.map +1 -0
- package/dist/spawn-types.js +12 -0
- package/dist/spawn-types.js.map +1 -0
- package/dist/spawn.d.ts +30 -0
- package/dist/spawn.d.ts.map +1 -0
- package/dist/spawn.js +7 -0
- package/dist/spawn.js.map +1 -0
- package/dist/status-registry.d.ts +50 -0
- package/dist/status-registry.d.ts.map +1 -0
- package/dist/status-registry.js +125 -0
- package/dist/status-registry.js.map +1 -0
- package/dist/task-record.d.ts +67 -0
- package/dist/task-record.d.ts.map +1 -0
- package/dist/task-record.js +11 -0
- package/dist/task-record.js.map +1 -0
- package/dist/task-sync.d.ts +143 -0
- package/dist/task-sync.d.ts.map +1 -0
- package/dist/task-sync.js +11 -0
- package/dist/task-sync.js.map +1 -0
- package/dist/task.d.ts +294 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +24 -0
- package/dist/task.js.map +1 -0
- package/dist/tessera.d.ts +32 -0
- package/dist/tessera.d.ts.map +1 -0
- package/dist/tessera.js +11 -0
- package/dist/tessera.js.map +1 -0
- package/dist/todowrite.d.ts +53 -0
- package/dist/todowrite.d.ts.map +1 -0
- package/dist/todowrite.js +7 -0
- package/dist/todowrite.js.map +1 -0
- package/dist/transport.d.ts +12 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +7 -0
- package/dist/transport.js.map +1 -0
- package/dist/warp-chain.d.ts +121 -0
- package/dist/warp-chain.d.ts.map +1 -0
- package/dist/warp-chain.js +13 -0
- package/dist/warp-chain.js.map +1 -0
- package/package.json +29 -0
- package/src/adapter.ts +38 -0
- package/src/archive.ts +121 -0
- package/src/brain.ts +39 -0
- package/src/capabilities.ts +21 -0
- package/src/config.ts +135 -0
- package/src/context-monitor.ts +16 -0
- package/src/data-accessor.ts +239 -0
- package/src/discovery.ts +31 -0
- package/src/exit-codes.ts +175 -0
- package/src/hooks.ts +17 -0
- package/src/index.ts +298 -0
- package/src/install.ts +28 -0
- package/src/lafs.ts +194 -0
- package/src/memory.ts +57 -0
- package/src/operations/index.ts +17 -0
- package/src/operations/issues.ts +86 -0
- package/src/operations/lifecycle.ts +176 -0
- package/src/operations/orchestrate.ts +199 -0
- package/src/operations/release.ts +114 -0
- package/src/operations/research.ts +156 -0
- package/src/operations/session.ts +119 -0
- package/src/operations/skills.ts +210 -0
- package/src/operations/system.ts +174 -0
- package/src/operations/tasks.ts +279 -0
- package/src/operations/validate.ts +199 -0
- package/src/provider-paths.ts +16 -0
- package/src/results.ts +207 -0
- package/src/session.ts +157 -0
- package/src/spawn-types.ts +140 -0
- package/src/spawn.ts +32 -0
- package/src/status-registry.ts +166 -0
- package/src/task-record.ts +71 -0
- package/src/task-sync.ts +167 -0
- package/src/task.ts +387 -0
- package/src/tessera.ts +35 -0
- package/src/todowrite.ts +58 -0
- package/src/transport.ts +12 -0
- package/src/warp-chain.ts +174 -0
package/src/task-sync.ts
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task synchronization contracts for provider-agnostic task reconciliation.
|
|
3
|
+
*
|
|
4
|
+
* Replaces the legacy Claude Code-specific TodoWrite integration with a
|
|
5
|
+
* provider-agnostic system. Any provider adapter can implement
|
|
6
|
+
* AdapterTaskSyncProvider to sync its external task system with CLEO as SSoT.
|
|
7
|
+
*
|
|
8
|
+
* @task T5800
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// External task representation (provider-agnostic)
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/** Normalized status for tasks coming from an external provider. */
|
|
16
|
+
export type ExternalTaskStatus = 'pending' | 'active' | 'completed' | 'removed';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A task as reported by an external provider, normalized to a common shape.
|
|
20
|
+
* Provider-specific adapters translate their native format into this.
|
|
21
|
+
*/
|
|
22
|
+
export interface ExternalTask {
|
|
23
|
+
/** Provider-assigned identifier for this task (opaque to core). */
|
|
24
|
+
externalId: string;
|
|
25
|
+
/** Mapped CLEO task ID, or null if the task is new / unmatched. */
|
|
26
|
+
cleoTaskId: string | null;
|
|
27
|
+
/** Human-readable title. */
|
|
28
|
+
title: string;
|
|
29
|
+
/** Normalized status. */
|
|
30
|
+
status: ExternalTaskStatus;
|
|
31
|
+
/** Optional description text. */
|
|
32
|
+
description?: string;
|
|
33
|
+
/** Optional labels/tags from the provider. */
|
|
34
|
+
labels?: string[];
|
|
35
|
+
/** Arbitrary provider-specific metadata (opaque to core). */
|
|
36
|
+
providerMeta?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Sync session state
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Persistent state for a sync session between CLEO and a provider.
|
|
45
|
+
* Stored per-provider under `.cleo/sync/<providerId>-session.json`.
|
|
46
|
+
*/
|
|
47
|
+
export interface SyncSessionState {
|
|
48
|
+
/** CLEO task IDs that were injected into the provider's task list. */
|
|
49
|
+
injectedTaskIds: string[];
|
|
50
|
+
/** Optional phase context when tasks were injected. */
|
|
51
|
+
injectedPhase?: string;
|
|
52
|
+
/** Per-task metadata at injection time. */
|
|
53
|
+
taskMetadata?: Record<string, { phase?: string }>;
|
|
54
|
+
/** ISO timestamp of the last successful reconciliation. */
|
|
55
|
+
lastSyncAt?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ---------------------------------------------------------------------------
|
|
59
|
+
// Conflict resolution
|
|
60
|
+
// ---------------------------------------------------------------------------
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Policy for resolving conflicts between CLEO and provider state.
|
|
64
|
+
*
|
|
65
|
+
* - `cleo-wins`: CLEO state takes precedence (default).
|
|
66
|
+
* - `provider-wins`: Provider state takes precedence.
|
|
67
|
+
* - `latest-wins`: Most recently modified value wins.
|
|
68
|
+
* - `report-only`: Report conflicts without applying changes.
|
|
69
|
+
*/
|
|
70
|
+
export type ConflictPolicy = 'cleo-wins' | 'provider-wins' | 'latest-wins' | 'report-only';
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Reconciliation options and results
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
/** Options for the reconciliation engine. */
|
|
77
|
+
export interface ReconcileOptions {
|
|
78
|
+
/** Provider ID (e.g. 'claude-code', 'cursor'). */
|
|
79
|
+
providerId: string;
|
|
80
|
+
/** Working directory (project root). */
|
|
81
|
+
cwd?: string;
|
|
82
|
+
/** If true, compute actions without applying them. */
|
|
83
|
+
dryRun?: boolean;
|
|
84
|
+
/** Conflict resolution policy. Defaults to 'cleo-wins'. */
|
|
85
|
+
conflictPolicy?: ConflictPolicy;
|
|
86
|
+
/** Default phase for newly created tasks. */
|
|
87
|
+
defaultPhase?: string;
|
|
88
|
+
/** Default labels for newly created tasks. */
|
|
89
|
+
defaultLabels?: string[];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** The type of action the reconciliation engine will take. */
|
|
93
|
+
export type ReconcileActionType = 'complete' | 'activate' | 'create' | 'remove' | 'skip' | 'conflict';
|
|
94
|
+
|
|
95
|
+
/** A single reconciliation action (planned or applied). */
|
|
96
|
+
export interface ReconcileAction {
|
|
97
|
+
/** What kind of change. */
|
|
98
|
+
type: ReconcileActionType;
|
|
99
|
+
/** The CLEO task ID affected (null for creates before they happen). */
|
|
100
|
+
cleoTaskId: string | null;
|
|
101
|
+
/** The external task that triggered this action. */
|
|
102
|
+
externalId: string;
|
|
103
|
+
/** Human-readable description of the action. */
|
|
104
|
+
summary: string;
|
|
105
|
+
/** Whether this action was actually applied. */
|
|
106
|
+
applied: boolean;
|
|
107
|
+
/** Error message if the action failed during apply. */
|
|
108
|
+
error?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Result of a full reconciliation run. */
|
|
112
|
+
export interface ReconcileResult {
|
|
113
|
+
/** Whether this was a dry run. */
|
|
114
|
+
dryRun: boolean;
|
|
115
|
+
/** Provider that was reconciled. */
|
|
116
|
+
providerId: string;
|
|
117
|
+
/** Individual actions taken (or planned). */
|
|
118
|
+
actions: ReconcileAction[];
|
|
119
|
+
/** Summary counts. */
|
|
120
|
+
summary: {
|
|
121
|
+
completed: number;
|
|
122
|
+
activated: number;
|
|
123
|
+
created: number;
|
|
124
|
+
removed: number;
|
|
125
|
+
skipped: number;
|
|
126
|
+
conflicts: number;
|
|
127
|
+
applied: number;
|
|
128
|
+
};
|
|
129
|
+
/** Whether sync session state was cleared after apply. */
|
|
130
|
+
sessionCleared: boolean;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
// Provider adapter interface
|
|
135
|
+
// ---------------------------------------------------------------------------
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Interface that provider adapters implement to expose their external
|
|
139
|
+
* task system to the reconciliation engine.
|
|
140
|
+
*
|
|
141
|
+
* Provider-specific parsing lives here — core never sees native formats.
|
|
142
|
+
*/
|
|
143
|
+
export interface AdapterTaskSyncProvider {
|
|
144
|
+
/**
|
|
145
|
+
* Read the provider's current task state and return normalized ExternalTasks.
|
|
146
|
+
*
|
|
147
|
+
* @param projectDir - Project root directory.
|
|
148
|
+
* @returns Array of external tasks in normalized form.
|
|
149
|
+
*/
|
|
150
|
+
getExternalTasks(projectDir: string): Promise<ExternalTask[]>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Optionally push CLEO task state back to the provider.
|
|
154
|
+
* Not all providers support bidirectional sync.
|
|
155
|
+
*
|
|
156
|
+
* @param tasks - Current CLEO tasks to push.
|
|
157
|
+
* @param projectDir - Project root directory.
|
|
158
|
+
*/
|
|
159
|
+
pushTaskState?(tasks: ReadonlyArray<{ id: string; title: string; status: string }>, projectDir: string): Promise<void>;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Clean up provider-specific sync artifacts (e.g. state files).
|
|
163
|
+
*
|
|
164
|
+
* @param projectDir - Project root directory.
|
|
165
|
+
*/
|
|
166
|
+
cleanup?(projectDir: string): Promise<void>;
|
|
167
|
+
}
|
package/src/task.ts
ADDED
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Task type definitions matching todo.schema.json (v2.10.0).
|
|
3
|
+
*
|
|
4
|
+
* Consolidates types from src/types/task.ts and packages/contracts/src/task-types.ts.
|
|
5
|
+
*
|
|
6
|
+
* ## Type Safety Design
|
|
7
|
+
*
|
|
8
|
+
* - {@link Task} represents a fully-materialized task as stored in the database.
|
|
9
|
+
* Fields that CLEO's anti-hallucination rules require at runtime are marked as
|
|
10
|
+
* required (non-optional) so the type system enforces what the business rules demand.
|
|
11
|
+
*
|
|
12
|
+
* - {@link TaskCreate} represents the input for creating a new task. Only fields the
|
|
13
|
+
* caller MUST supply are required; everything else has sensible defaults applied
|
|
14
|
+
* by the `addTask` function.
|
|
15
|
+
*
|
|
16
|
+
* - {@link CompletedTask} and {@link CancelledTask} are discriminated union types
|
|
17
|
+
* that narrow `Task` for status-specific contexts where additional fields become
|
|
18
|
+
* required (e.g., `completedAt` is required when `status = 'done'`).
|
|
19
|
+
*
|
|
20
|
+
* @epic T4454
|
|
21
|
+
* @task T4456
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { TaskStatus } from './status-registry.js';
|
|
25
|
+
export type { TaskStatus };
|
|
26
|
+
|
|
27
|
+
/** Task priority levels. */
|
|
28
|
+
export type TaskPriority = 'critical' | 'high' | 'medium' | 'low';
|
|
29
|
+
|
|
30
|
+
/** Task type in hierarchy. */
|
|
31
|
+
export type TaskType = 'epic' | 'task' | 'subtask';
|
|
32
|
+
|
|
33
|
+
/** Task size (scope, NOT time). */
|
|
34
|
+
export type TaskSize = 'small' | 'medium' | 'large';
|
|
35
|
+
|
|
36
|
+
/** Epic lifecycle states. */
|
|
37
|
+
export type EpicLifecycle = 'backlog' | 'planning' | 'active' | 'review' | 'released' | 'archived';
|
|
38
|
+
|
|
39
|
+
/** Task origin (provenance). */
|
|
40
|
+
export type TaskOrigin =
|
|
41
|
+
| 'internal'
|
|
42
|
+
| 'bug-report'
|
|
43
|
+
| 'feature-request'
|
|
44
|
+
| 'security'
|
|
45
|
+
| 'technical-debt'
|
|
46
|
+
| 'dependency'
|
|
47
|
+
| 'regression';
|
|
48
|
+
|
|
49
|
+
/** Verification agent types. */
|
|
50
|
+
export type VerificationAgent =
|
|
51
|
+
| 'planner'
|
|
52
|
+
| 'coder'
|
|
53
|
+
| 'testing'
|
|
54
|
+
| 'qa'
|
|
55
|
+
| 'cleanup'
|
|
56
|
+
| 'security'
|
|
57
|
+
| 'docs';
|
|
58
|
+
|
|
59
|
+
/** Verification gate names. */
|
|
60
|
+
export type VerificationGate =
|
|
61
|
+
| 'implemented'
|
|
62
|
+
| 'testsPassed'
|
|
63
|
+
| 'qaPassed'
|
|
64
|
+
| 'cleanupDone'
|
|
65
|
+
| 'securityPassed'
|
|
66
|
+
| 'documented';
|
|
67
|
+
|
|
68
|
+
/** Verification failure log entry. */
|
|
69
|
+
export interface VerificationFailure {
|
|
70
|
+
round: number;
|
|
71
|
+
agent: string;
|
|
72
|
+
reason: string;
|
|
73
|
+
timestamp: string;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Task verification state. */
|
|
77
|
+
export interface TaskVerification {
|
|
78
|
+
passed: boolean;
|
|
79
|
+
round: number;
|
|
80
|
+
gates: Partial<Record<VerificationGate, boolean | null>>;
|
|
81
|
+
lastAgent: VerificationAgent | null;
|
|
82
|
+
lastUpdated: string | null;
|
|
83
|
+
failureLog: VerificationFailure[];
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Task provenance tracking. */
|
|
87
|
+
export interface TaskProvenance {
|
|
88
|
+
createdBy: string | null;
|
|
89
|
+
modifiedBy: string | null;
|
|
90
|
+
sessionId: string | null;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** A single task relation entry. */
|
|
94
|
+
export interface TaskRelation {
|
|
95
|
+
taskId: string;
|
|
96
|
+
type: string;
|
|
97
|
+
reason?: string;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* A single CLEO task as stored in the database.
|
|
102
|
+
*
|
|
103
|
+
* Fields marked as required are enforced by CLEO's anti-hallucination validation
|
|
104
|
+
* at runtime. Making them required here ensures the type system catches violations
|
|
105
|
+
* at compile time rather than deferring to runtime checks.
|
|
106
|
+
*/
|
|
107
|
+
export interface Task {
|
|
108
|
+
/** Unique task identifier. Must match pattern `T\d{3,}` (e.g., T001, T5800). */
|
|
109
|
+
id: string;
|
|
110
|
+
|
|
111
|
+
/** Human-readable task title. Required, max 120 characters. */
|
|
112
|
+
title: string;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Task description. **Required** — CLEO's anti-hallucination rules reject tasks
|
|
116
|
+
* without a description, and require it to differ from the title.
|
|
117
|
+
*/
|
|
118
|
+
description: string;
|
|
119
|
+
|
|
120
|
+
/** Current task status. Must be a valid {@link TaskStatus} enum value. */
|
|
121
|
+
status: TaskStatus;
|
|
122
|
+
|
|
123
|
+
/** Task priority level. Defaults to `'medium'` on creation. */
|
|
124
|
+
priority: TaskPriority;
|
|
125
|
+
|
|
126
|
+
/** Task type in hierarchy. Inferred from parent context if not specified. */
|
|
127
|
+
type?: TaskType;
|
|
128
|
+
|
|
129
|
+
/** ID of the parent task. `null` for root-level tasks. */
|
|
130
|
+
parentId?: string | null;
|
|
131
|
+
|
|
132
|
+
/** Sort position within sibling scope. */
|
|
133
|
+
position?: number | null;
|
|
134
|
+
|
|
135
|
+
/** Optimistic concurrency version for position changes. */
|
|
136
|
+
positionVersion?: number;
|
|
137
|
+
|
|
138
|
+
/** Relative scope sizing (small/medium/large). NOT a time estimate. */
|
|
139
|
+
size?: TaskSize | null;
|
|
140
|
+
|
|
141
|
+
/** Phase slug this task belongs to. */
|
|
142
|
+
phase?: string;
|
|
143
|
+
|
|
144
|
+
/** File paths associated with this task. */
|
|
145
|
+
files?: string[];
|
|
146
|
+
|
|
147
|
+
/** Acceptance criteria for completion. */
|
|
148
|
+
acceptance?: string[];
|
|
149
|
+
|
|
150
|
+
/** IDs of tasks this task depends on. */
|
|
151
|
+
depends?: string[];
|
|
152
|
+
|
|
153
|
+
/** Related task entries (non-dependency relationships). */
|
|
154
|
+
relates?: TaskRelation[];
|
|
155
|
+
|
|
156
|
+
/** Epic lifecycle state. Only meaningful when `type = 'epic'`. */
|
|
157
|
+
epicLifecycle?: EpicLifecycle | null;
|
|
158
|
+
|
|
159
|
+
/** When true, epic will not auto-complete when all children are done. */
|
|
160
|
+
noAutoComplete?: boolean | null;
|
|
161
|
+
|
|
162
|
+
/** Reason the task is blocked (free-form text). */
|
|
163
|
+
blockedBy?: string;
|
|
164
|
+
|
|
165
|
+
/** Timestamped notes appended during task lifecycle. */
|
|
166
|
+
notes?: string[];
|
|
167
|
+
|
|
168
|
+
/** Classification labels for filtering and grouping. */
|
|
169
|
+
labels?: string[];
|
|
170
|
+
|
|
171
|
+
/** Task origin/provenance category. */
|
|
172
|
+
origin?: TaskOrigin | null;
|
|
173
|
+
|
|
174
|
+
/** ISO 8601 timestamp of task creation. Must not be in the future. */
|
|
175
|
+
createdAt: string;
|
|
176
|
+
|
|
177
|
+
/** ISO 8601 timestamp of last update. Set automatically on mutation. */
|
|
178
|
+
updatedAt?: string | null;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* ISO 8601 timestamp of task completion. Set when `status` transitions to `'done'`.
|
|
182
|
+
* See {@link CompletedTask} for the status-narrowed type where this is required.
|
|
183
|
+
*/
|
|
184
|
+
completedAt?: string;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* ISO 8601 timestamp of task cancellation. Set when `status` transitions to `'cancelled'`.
|
|
188
|
+
* See {@link CancelledTask} for the status-narrowed type where this is required.
|
|
189
|
+
*/
|
|
190
|
+
cancelledAt?: string;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Reason for cancellation. Required when `status = 'cancelled'`.
|
|
194
|
+
* See {@link CancelledTask} for the status-narrowed type where this is required.
|
|
195
|
+
*/
|
|
196
|
+
cancellationReason?: string;
|
|
197
|
+
|
|
198
|
+
/** Verification pipeline state. */
|
|
199
|
+
verification?: TaskVerification | null;
|
|
200
|
+
|
|
201
|
+
/** Provenance tracking (who created/modified, which session). */
|
|
202
|
+
provenance?: TaskProvenance | null;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
// ---------------------------------------------------------------------------
|
|
206
|
+
// Input types for task creation
|
|
207
|
+
// ---------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Input type for creating a new task via `addTask()`.
|
|
211
|
+
*
|
|
212
|
+
* Only the fields the caller MUST provide are required. All other fields
|
|
213
|
+
* have sensible defaults applied by the creation logic:
|
|
214
|
+
* - `status` defaults to `'pending'`
|
|
215
|
+
* - `priority` defaults to `'medium'`
|
|
216
|
+
* - `type` is inferred from parent context
|
|
217
|
+
* - `size` defaults to `'medium'`
|
|
218
|
+
*/
|
|
219
|
+
export interface TaskCreate {
|
|
220
|
+
/** Human-readable task title. Required, max 120 characters. */
|
|
221
|
+
title: string;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Task description. **Required** — CLEO's anti-hallucination rules reject tasks
|
|
225
|
+
* without a description, and require it to differ from the title.
|
|
226
|
+
*/
|
|
227
|
+
description: string;
|
|
228
|
+
|
|
229
|
+
/** Initial status. Defaults to `'pending'`. */
|
|
230
|
+
status?: TaskStatus;
|
|
231
|
+
|
|
232
|
+
/** Priority level. Defaults to `'medium'`. */
|
|
233
|
+
priority?: TaskPriority;
|
|
234
|
+
|
|
235
|
+
/** Task type. Inferred from parent context if not specified. */
|
|
236
|
+
type?: TaskType;
|
|
237
|
+
|
|
238
|
+
/** Parent task ID for hierarchy placement. */
|
|
239
|
+
parentId?: string | null;
|
|
240
|
+
|
|
241
|
+
/** Relative scope sizing. Defaults to `'medium'`. */
|
|
242
|
+
size?: TaskSize;
|
|
243
|
+
|
|
244
|
+
/** Phase slug to assign. Inherited from project.currentPhase if not specified. */
|
|
245
|
+
phase?: string;
|
|
246
|
+
|
|
247
|
+
/** Classification labels. */
|
|
248
|
+
labels?: string[];
|
|
249
|
+
|
|
250
|
+
/** File paths associated with this task. */
|
|
251
|
+
files?: string[];
|
|
252
|
+
|
|
253
|
+
/** Acceptance criteria. */
|
|
254
|
+
acceptance?: string[];
|
|
255
|
+
|
|
256
|
+
/** IDs of tasks this task depends on. */
|
|
257
|
+
depends?: string[];
|
|
258
|
+
|
|
259
|
+
/** Initial note to attach. */
|
|
260
|
+
notes?: string;
|
|
261
|
+
|
|
262
|
+
/** Sort position. Auto-calculated if not specified. */
|
|
263
|
+
position?: number;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// ---------------------------------------------------------------------------
|
|
267
|
+
// Status-narrowed types (discriminated unions)
|
|
268
|
+
// ---------------------------------------------------------------------------
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* A task with `status = 'done'`. Narrows {@link Task} to require `completedAt`.
|
|
272
|
+
*
|
|
273
|
+
* Use this type when you need to guarantee a completed task has its completion
|
|
274
|
+
* timestamp — for example, in cycle-time calculations or archive operations.
|
|
275
|
+
*/
|
|
276
|
+
export type CompletedTask = Task & {
|
|
277
|
+
/** Discriminant: status is always `'done'` for a completed task. */
|
|
278
|
+
status: 'done';
|
|
279
|
+
/** ISO 8601 timestamp of completion. Required for done tasks. */
|
|
280
|
+
completedAt: string;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* A task with `status = 'cancelled'`. Narrows {@link Task} to require
|
|
285
|
+
* `cancelledAt` and `cancellationReason`.
|
|
286
|
+
*
|
|
287
|
+
* Use this type when processing cancelled tasks where the cancellation
|
|
288
|
+
* metadata is guaranteed to be present.
|
|
289
|
+
*/
|
|
290
|
+
export type CancelledTask = Task & {
|
|
291
|
+
/** Discriminant: status is always `'cancelled'` for a cancelled task. */
|
|
292
|
+
status: 'cancelled';
|
|
293
|
+
/** ISO 8601 timestamp of cancellation. Required for cancelled tasks. */
|
|
294
|
+
cancelledAt: string;
|
|
295
|
+
/** Reason for cancellation. Required for cancelled tasks (min 5 chars). */
|
|
296
|
+
cancellationReason: string;
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
/** Phase status. */
|
|
300
|
+
export type PhaseStatus = 'pending' | 'active' | 'completed';
|
|
301
|
+
|
|
302
|
+
/** Phase definition. */
|
|
303
|
+
export interface Phase {
|
|
304
|
+
order: number;
|
|
305
|
+
name: string;
|
|
306
|
+
description?: string;
|
|
307
|
+
status: PhaseStatus;
|
|
308
|
+
startedAt?: string | null;
|
|
309
|
+
completedAt?: string | null;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/** Phase transition record. */
|
|
313
|
+
export interface PhaseTransition {
|
|
314
|
+
phase: string;
|
|
315
|
+
transitionType: 'started' | 'completed' | 'rollback';
|
|
316
|
+
timestamp: string;
|
|
317
|
+
taskCount: number;
|
|
318
|
+
fromPhase?: string | null;
|
|
319
|
+
reason?: string;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/** Release status. */
|
|
323
|
+
export type ReleaseStatus = 'planned' | 'active' | 'released';
|
|
324
|
+
|
|
325
|
+
/** Release definition. */
|
|
326
|
+
export interface Release {
|
|
327
|
+
version: string;
|
|
328
|
+
status: ReleaseStatus;
|
|
329
|
+
targetDate?: string | null;
|
|
330
|
+
releasedAt?: string | null;
|
|
331
|
+
tasks: string[];
|
|
332
|
+
notes?: string | null;
|
|
333
|
+
changelog?: string | null;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** Project metadata. */
|
|
337
|
+
export interface ProjectMeta {
|
|
338
|
+
name: string;
|
|
339
|
+
currentPhase?: string | null;
|
|
340
|
+
phases: Record<string, Phase>;
|
|
341
|
+
phaseHistory?: PhaseTransition[];
|
|
342
|
+
releases?: Release[];
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** File metadata (_meta block). */
|
|
346
|
+
export interface FileMeta {
|
|
347
|
+
schemaVersion: string;
|
|
348
|
+
specVersion?: string;
|
|
349
|
+
checksum: string;
|
|
350
|
+
configVersion: string;
|
|
351
|
+
lastSessionId?: string | null;
|
|
352
|
+
activeSession?: string | null;
|
|
353
|
+
activeSessionCount?: number;
|
|
354
|
+
sessionsFile?: string | null;
|
|
355
|
+
generation?: number;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/** Session note in taskWork block. */
|
|
359
|
+
export interface SessionNote {
|
|
360
|
+
note: string;
|
|
361
|
+
timestamp: string;
|
|
362
|
+
conversationId?: string | null;
|
|
363
|
+
agent?: string | null;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** Task work state. */
|
|
367
|
+
export interface TaskWorkState {
|
|
368
|
+
currentTask?: string | null;
|
|
369
|
+
currentPhase?: string | null;
|
|
370
|
+
blockedUntil?: string | null;
|
|
371
|
+
sessionNote?: string | null;
|
|
372
|
+
sessionNotes?: SessionNote[];
|
|
373
|
+
nextAction?: string | null;
|
|
374
|
+
primarySession?: string | null;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Root task data structure. */
|
|
378
|
+
export interface TaskFile {
|
|
379
|
+
version: string;
|
|
380
|
+
project: ProjectMeta;
|
|
381
|
+
lastUpdated: string;
|
|
382
|
+
_meta: FileMeta;
|
|
383
|
+
taskWork?: TaskWorkState;
|
|
384
|
+
focus?: TaskWorkState;
|
|
385
|
+
tasks: Task[];
|
|
386
|
+
labels?: Record<string, string[]>;
|
|
387
|
+
}
|
package/src/tessera.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tessera Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Tessera templates extend WarpChain with variable bindings,
|
|
5
|
+
* archetype classification, and instantiation inputs for
|
|
6
|
+
* parameterized pipeline creation.
|
|
7
|
+
*
|
|
8
|
+
* @task T5408
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import type { WarpChain } from './warp-chain.js';
|
|
12
|
+
|
|
13
|
+
/** A variable declaration within a Tessera template. */
|
|
14
|
+
export interface TesseraVariable {
|
|
15
|
+
name: string;
|
|
16
|
+
type: 'string' | 'number' | 'boolean' | 'taskId' | 'epicId';
|
|
17
|
+
description: string;
|
|
18
|
+
required: boolean;
|
|
19
|
+
default?: unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A parameterized WarpChain template with variable bindings. */
|
|
23
|
+
export interface TesseraTemplate extends WarpChain {
|
|
24
|
+
variables: Record<string, TesseraVariable>;
|
|
25
|
+
archetypes: string[];
|
|
26
|
+
defaultValues: Record<string, unknown>;
|
|
27
|
+
category: 'lifecycle' | 'hotfix' | 'research' | 'security-audit' | 'custom';
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Input for instantiating a Tessera template into a concrete chain. */
|
|
31
|
+
export interface TesseraInstantiationInput {
|
|
32
|
+
templateId: string;
|
|
33
|
+
epicId: string;
|
|
34
|
+
variables: Record<string, unknown>;
|
|
35
|
+
}
|
package/src/todowrite.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TodoWrite types for Claude TodoWrite state merge operations.
|
|
3
|
+
*
|
|
4
|
+
* @task T4551
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** TodoWrite item status as exported by Claude. */
|
|
8
|
+
export type TodoWriteItemStatus = 'pending' | 'in_progress' | 'completed';
|
|
9
|
+
|
|
10
|
+
/** TodoWrite item as exported by Claude. */
|
|
11
|
+
export interface TodoWriteItem {
|
|
12
|
+
content: string;
|
|
13
|
+
status: TodoWriteItemStatus;
|
|
14
|
+
activeForm?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** TodoWrite state file format. */
|
|
18
|
+
export interface TodoWriteState {
|
|
19
|
+
todos: TodoWriteItem[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Sync session state for TodoWrite integration. */
|
|
23
|
+
export interface TodoWriteSyncSessionState {
|
|
24
|
+
injected_tasks: string[];
|
|
25
|
+
injectedPhase?: string;
|
|
26
|
+
task_metadata?: Record<string, { phase?: string }>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Detected changes from TodoWrite state analysis. */
|
|
30
|
+
export interface TodoWriteChangeSet {
|
|
31
|
+
completed: string[];
|
|
32
|
+
progressed: string[];
|
|
33
|
+
newTasks: string[];
|
|
34
|
+
removed: string[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Action type for a TodoWrite merge change. */
|
|
38
|
+
export type TodoWriteChangeAction = 'complete' | 'create' | 'update';
|
|
39
|
+
|
|
40
|
+
/** A single change applied during TodoWrite merge. */
|
|
41
|
+
export interface TodoWriteChange {
|
|
42
|
+
taskId: string;
|
|
43
|
+
action: TodoWriteChangeAction;
|
|
44
|
+
details?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Result of a TodoWrite merge operation. */
|
|
48
|
+
export interface TodoWriteMergeResult {
|
|
49
|
+
dryRun: boolean;
|
|
50
|
+
changes: {
|
|
51
|
+
completed: number;
|
|
52
|
+
progressed: number;
|
|
53
|
+
new: number;
|
|
54
|
+
removed: number;
|
|
55
|
+
applied: number;
|
|
56
|
+
};
|
|
57
|
+
sessionCleared?: boolean;
|
|
58
|
+
}
|
package/src/transport.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport provider interface for CLEO provider adapters.
|
|
3
|
+
* Allows providers to supply custom inter-agent transport mechanisms.
|
|
4
|
+
* @task T5240
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface AdapterTransportProvider {
|
|
8
|
+
/** Create a transport instance for inter-agent communication */
|
|
9
|
+
createTransport(): unknown;
|
|
10
|
+
/** Name of this transport type for logging/debugging */
|
|
11
|
+
readonly transportName: string;
|
|
12
|
+
}
|