@cleocode/contracts 2026.5.96 → 2026.5.98
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/__tests__/enums.test.d.ts +14 -0
- package/dist/__tests__/enums.test.d.ts.map +1 -0
- package/dist/__tests__/enums.test.js +75 -0
- package/dist/__tests__/enums.test.js.map +1 -0
- package/dist/__tests__/jobs.test.d.ts +11 -0
- package/dist/__tests__/jobs.test.d.ts.map +1 -0
- package/dist/__tests__/jobs.test.js +48 -0
- package/dist/__tests__/jobs.test.js.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts +19 -0
- package/dist/__tests__/memory-wire-shapes.test.d.ts.map +1 -0
- package/dist/__tests__/memory-wire-shapes.test.js +119 -0
- package/dist/__tests__/memory-wire-shapes.test.js.map +1 -0
- package/dist/__tests__/operation-def.test.d.ts +20 -0
- package/dist/__tests__/operation-def.test.d.ts.map +1 -0
- package/dist/__tests__/operation-def.test.js +111 -0
- package/dist/__tests__/operation-def.test.js.map +1 -0
- package/dist/__tests__/provenance.test.d.ts +18 -0
- package/dist/__tests__/provenance.test.d.ts.map +1 -0
- package/dist/__tests__/provenance.test.js +142 -0
- package/dist/__tests__/provenance.test.js.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts +19 -0
- package/dist/__tests__/scaffold-diagnostics.test.d.ts.map +1 -0
- package/dist/__tests__/scaffold-diagnostics.test.js +70 -0
- package/dist/__tests__/scaffold-diagnostics.test.js.map +1 -0
- package/dist/dispatch/identity.d.ts +72 -0
- package/dist/dispatch/identity.d.ts.map +1 -0
- package/dist/dispatch/identity.js +72 -0
- package/dist/dispatch/identity.js.map +1 -0
- package/dist/dispatch/operation-def.d.ts +92 -0
- package/dist/dispatch/operation-def.d.ts.map +1 -0
- package/dist/dispatch/operation-def.js +31 -0
- package/dist/dispatch/operation-def.js.map +1 -0
- package/dist/doctor.d.ts +43 -0
- package/dist/doctor.d.ts.map +1 -1
- package/dist/enums.d.ts +123 -0
- package/dist/enums.d.ts.map +1 -0
- package/dist/enums.js +139 -0
- package/dist/enums.js.map +1 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/jobs.d.ts +39 -0
- package/dist/jobs.d.ts.map +1 -0
- package/dist/jobs.js +19 -0
- package/dist/jobs.js.map +1 -0
- package/dist/memory/budgeted.d.ts +67 -0
- package/dist/memory/budgeted.d.ts.map +1 -0
- package/dist/memory/budgeted.js +17 -0
- package/dist/memory/budgeted.js.map +1 -0
- package/dist/memory/fetch.d.ts +58 -0
- package/dist/memory/fetch.d.ts.map +1 -0
- package/dist/memory/fetch.js +19 -0
- package/dist/memory/fetch.js.map +1 -0
- package/dist/memory/observe.d.ts +158 -0
- package/dist/memory/observe.d.ts.map +1 -0
- package/dist/memory/observe.js +46 -0
- package/dist/memory/observe.js.map +1 -0
- package/dist/memory/search.d.ts +137 -0
- package/dist/memory/search.d.ts.map +1 -0
- package/dist/memory/search.js +22 -0
- package/dist/memory/search.js.map +1 -0
- package/dist/memory/timeline.d.ts +89 -0
- package/dist/memory/timeline.d.ts.map +1 -0
- package/dist/memory/timeline.js +22 -0
- package/dist/memory/timeline.js.map +1 -0
- package/dist/operations/focus.d.ts +199 -0
- package/dist/operations/focus.d.ts.map +1 -0
- package/dist/operations/focus.js +15 -0
- package/dist/operations/focus.js.map +1 -0
- package/dist/operations/index.d.ts +1 -0
- package/dist/operations/index.d.ts.map +1 -1
- package/dist/operations/index.js +1 -0
- package/dist/operations/index.js.map +1 -1
- package/dist/operations/session.d.ts +65 -0
- package/dist/operations/session.d.ts.map +1 -1
- package/dist/operations/tasks.d.ts +38 -0
- package/dist/operations/tasks.d.ts.map +1 -1
- package/dist/provenance.d.ts +257 -0
- package/dist/provenance.d.ts.map +1 -0
- package/dist/provenance.js +42 -0
- package/dist/provenance.js.map +1 -0
- package/dist/release/plan.d.ts +7 -7
- package/dist/scaffold-diagnostics.d.ts +110 -0
- package/dist/scaffold-diagnostics.d.ts.map +1 -0
- package/dist/scaffold-diagnostics.js +28 -0
- package/dist/scaffold-diagnostics.js.map +1 -0
- package/dist/session.d.ts +37 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js.map +1 -1
- package/dist/tasks/archive.d.ts +3 -3
- package/package.json +42 -2
- package/src/__tests__/enums.test.ts +114 -0
- package/src/__tests__/jobs.test.ts +76 -0
- package/src/__tests__/memory-wire-shapes.test.ts +371 -0
- package/src/__tests__/operation-def.test.ts +185 -0
- package/src/__tests__/provenance.test.ts +259 -0
- package/src/__tests__/scaffold-diagnostics.test.ts +137 -0
- package/src/dispatch/identity.ts +109 -0
- package/src/dispatch/operation-def.ts +102 -0
- package/src/doctor.ts +44 -0
- package/src/enums.ts +144 -0
- package/src/index.ts +79 -1
- package/src/jobs.ts +45 -0
- package/src/memory/budgeted.ts +75 -0
- package/src/memory/fetch.ts +66 -0
- package/src/memory/observe.ts +176 -0
- package/src/memory/search.ts +145 -0
- package/src/memory/timeline.ts +100 -0
- package/src/operations/focus.ts +226 -0
- package/src/operations/index.ts +1 -0
- package/src/operations/session.ts +67 -0
- package/src/operations/tasks.ts +40 -0
- package/src/provenance.ts +335 -0
- package/src/scaffold-diagnostics.ts +119 -0
- package/src/session.ts +37 -0
|
@@ -65,6 +65,11 @@ export interface SessionListParams {
|
|
|
65
65
|
status?: string;
|
|
66
66
|
limit?: number;
|
|
67
67
|
offset?: number;
|
|
68
|
+
/**
|
|
69
|
+
* When true, surface all columns including per-agent fields added in T9975
|
|
70
|
+
* (agentHandle, scopeKind, scopeId, lastActivity).
|
|
71
|
+
*/
|
|
72
|
+
all?: boolean;
|
|
68
73
|
}
|
|
69
74
|
/** Result of `session.list`. */
|
|
70
75
|
export interface SessionListResult {
|
|
@@ -295,6 +300,38 @@ export interface SessionBriefingShowParams {
|
|
|
295
300
|
scope?: string;
|
|
296
301
|
/** When true, exit non-zero if any contract violation is detected (T1905). */
|
|
297
302
|
strict?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Explicit session ID to scope the briefing to (T9975).
|
|
305
|
+
*
|
|
306
|
+
* When provided, the briefing resolution uses this session ID instead of
|
|
307
|
+
* inferring from env vars or most-recent active session. Internal use only.
|
|
308
|
+
*/
|
|
309
|
+
activeSessionId?: string;
|
|
310
|
+
/**
|
|
311
|
+
* When true, include `peerPatterns` in the warm bundle and other verbose
|
|
312
|
+
* debug fields that are suppressed by default to reduce token count.
|
|
313
|
+
*
|
|
314
|
+
* @task T9974
|
|
315
|
+
*/
|
|
316
|
+
debug?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* When true, include `cold.userProfile` traits in the bundle.
|
|
319
|
+
* Suppressed by default (large trait dump rarely needed at session start).
|
|
320
|
+
*
|
|
321
|
+
* @task T9974
|
|
322
|
+
*/
|
|
323
|
+
withProfile?: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* When true, restore full text fields on peerLearnings and decisions
|
|
326
|
+
* (the `insight` and `decision` body fields respectively). By default
|
|
327
|
+
* these are stripped and only `{id, title, createdAt, _next}` is emitted
|
|
328
|
+
* to reduce token consumption (T9964 Part 1 follow-up).
|
|
329
|
+
*
|
|
330
|
+
* Alias: `--memory-detail` on the CLI.
|
|
331
|
+
*
|
|
332
|
+
* @task T9964
|
|
333
|
+
*/
|
|
334
|
+
memoryDetail?: boolean;
|
|
298
335
|
}
|
|
299
336
|
|
|
300
337
|
/** Compact task entry in a session briefing's next-tasks list. */
|
|
@@ -504,6 +541,34 @@ export interface SessionStartParams {
|
|
|
504
541
|
* and validated on every `CLEO_OWNER_OVERRIDE` call.
|
|
505
542
|
*/
|
|
506
543
|
ownerAuthToken?: string;
|
|
544
|
+
/**
|
|
545
|
+
* Human-readable agent handle for multi-agent isolation (T9975).
|
|
546
|
+
*
|
|
547
|
+
* When provided, the conflict check is scoped per-agent-handle: multiple
|
|
548
|
+
* sessions with different handles may be active simultaneously, enabling
|
|
549
|
+
* N-agent parallel execution without briefing surface collisions.
|
|
550
|
+
*
|
|
551
|
+
* Stored in `sessions.agent_handle`. Surfaced in `cleo session list --all`.
|
|
552
|
+
*
|
|
553
|
+
* @example "agent-A", "worker-T9975", "ct-task-executor"
|
|
554
|
+
*/
|
|
555
|
+
agentHandle?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
// session.adopt
|
|
559
|
+
/** Parameters for `session.adopt`. */
|
|
560
|
+
export interface SessionAdoptParams {
|
|
561
|
+
/** Session ID to rebind the current env to. */
|
|
562
|
+
sessionId: string;
|
|
563
|
+
}
|
|
564
|
+
/** Result of `session.adopt`. */
|
|
565
|
+
export interface SessionAdoptResult {
|
|
566
|
+
/** The session being adopted. */
|
|
567
|
+
sessionId: string;
|
|
568
|
+
/** Shell export command to rebind env — print and eval in the calling shell. */
|
|
569
|
+
exportCommand: string;
|
|
570
|
+
/** Name of the env variable set. */
|
|
571
|
+
envVar: 'CLEO_SESSION_ID';
|
|
507
572
|
}
|
|
508
573
|
// session.end
|
|
509
574
|
/** Parameters for `session.end`. */
|
|
@@ -690,4 +755,6 @@ export type SessionOps = {
|
|
|
690
755
|
SessionRecordAssumptionResult,
|
|
691
756
|
];
|
|
692
757
|
readonly lint: readonly [SessionLintParams, SessionLintResult];
|
|
758
|
+
/** Rebind env to a specific session (T9975). */
|
|
759
|
+
readonly adopt: readonly [SessionAdoptParams, SessionAdoptResult];
|
|
693
760
|
};
|
package/src/operations/tasks.ts
CHANGED
|
@@ -35,6 +35,7 @@ import type {
|
|
|
35
35
|
TaskTreeNode,
|
|
36
36
|
TaskView,
|
|
37
37
|
} from '../tasks.js';
|
|
38
|
+
import type { DocsType } from './docs.js';
|
|
38
39
|
|
|
39
40
|
export type { TaskPriority, TaskStatus };
|
|
40
41
|
|
|
@@ -146,17 +147,56 @@ export interface TasksShowParams {
|
|
|
146
147
|
/** When true, include IVTR phase history. */
|
|
147
148
|
ivtrHistory?: boolean;
|
|
148
149
|
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Minimal attachment entry surfaced in the `tasks.show` envelope.
|
|
153
|
+
*
|
|
154
|
+
* A lightweight projection of a docs attachment — enough to identify and
|
|
155
|
+
* navigate to the full attachment via `cleo docs fetch <slug|id>`, without
|
|
156
|
+
* the full byte payload.
|
|
157
|
+
*
|
|
158
|
+
* Fields are a subset of {@link import('./docs.js').DocsAttachmentRow}:
|
|
159
|
+
* - `attachmentId` — store ID (att_* or UUID)
|
|
160
|
+
* - `slug` — human-friendly name (present when set on `cleo docs add`)
|
|
161
|
+
* - `type` — taxonomy classification (e.g. 'adr', 'research')
|
|
162
|
+
* - `kind` — storage kind ('local-file', 'url', 'blob', etc.)
|
|
163
|
+
*
|
|
164
|
+
* @task T9966
|
|
165
|
+
* @epic T9964
|
|
166
|
+
*/
|
|
167
|
+
export interface TaskShowAttachmentEntry {
|
|
168
|
+
/** Attachment identifier (att_* or UUID). */
|
|
169
|
+
attachmentId: string;
|
|
170
|
+
/** Human-friendly slug, unique per project. Present when assigned at add time. */
|
|
171
|
+
slug?: string;
|
|
172
|
+
/** Taxonomy classification. Present when assigned at add time. */
|
|
173
|
+
type?: DocsType;
|
|
174
|
+
/** Storage kind — discriminant for the full attachment variant. */
|
|
175
|
+
kind: string;
|
|
176
|
+
}
|
|
177
|
+
|
|
149
178
|
/**
|
|
150
179
|
* Result of `tasks.show` — the full task record plus its canonical view
|
|
151
180
|
* projection. `view` is null when the task has no lifecycle pipeline.
|
|
152
181
|
*
|
|
153
182
|
* @task T1703
|
|
183
|
+
* @task T9966 — attachments[] always present (empty array when none)
|
|
154
184
|
*/
|
|
155
185
|
export interface TasksShowResult {
|
|
156
186
|
/** Full task record (string-widened for dispatch layer serialization). */
|
|
157
187
|
task: TaskRecord;
|
|
158
188
|
/** Canonical task view projection produced by `computeTaskView`. Null when unavailable. */
|
|
159
189
|
view: TaskView | null;
|
|
190
|
+
/**
|
|
191
|
+
* Attachments linked to this task via the docs store.
|
|
192
|
+
*
|
|
193
|
+
* Always an array — empty (`[]`) when no attachments exist. Never `null`.
|
|
194
|
+
* Each entry carries enough context to navigate to the full attachment
|
|
195
|
+
* via `cleo docs fetch <slug|attachmentId>`.
|
|
196
|
+
*
|
|
197
|
+
* @task T9966
|
|
198
|
+
*/
|
|
199
|
+
attachments: TaskShowAttachmentEntry[];
|
|
160
200
|
}
|
|
161
201
|
|
|
162
202
|
// tasks.tree dispatch params (with optional withBlockers flag — dispatch alias)
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provenance graph union types.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the 16 string-literal union types that describe edges
|
|
5
|
+
* and FSM states in the CLEO provenance graph (commits, pull requests,
|
|
6
|
+
* releases, release artifacts, and BRAIN↔release links). Promoted from
|
|
7
|
+
* `packages/core/src/store/tasks-schema.ts` in Phase 0c of the
|
|
8
|
+
* SG-ARCH-SOLID Saga so that downstream packages can import these unions
|
|
9
|
+
* without pulling in the Drizzle schema runtime.
|
|
10
|
+
*
|
|
11
|
+
* The const arrays that back each union (`PR_STATES`, `COMMIT_LINK_KINDS`,
|
|
12
|
+
* `RELEASE_STATUSES`, …) remain in `tasks-schema.ts` because Drizzle's
|
|
13
|
+
* `text({ enum: ... })` column declaration narrows the runtime row type
|
|
14
|
+
* directly from those `as const` literals. `tasks-schema.ts` re-exports
|
|
15
|
+
* each union from this module to preserve the existing public surface for
|
|
16
|
+
* every `import * as schema from '../store/tasks-schema.js'` consumer.
|
|
17
|
+
*
|
|
18
|
+
* @see SPEC-T9345 §3 — provenance graph table definitions
|
|
19
|
+
* @see ADR-073 — task hierarchy charter (release provenance scope)
|
|
20
|
+
*
|
|
21
|
+
* Consolidated unions:
|
|
22
|
+
* - {@link PrState} — pull-request lifecycle state
|
|
23
|
+
* - {@link PrLinkSource} — how a PR↔task link was discovered
|
|
24
|
+
* - {@link PrLinkKind} — semantic PR↔task relationship
|
|
25
|
+
* - {@link CommitConventionalType} — Conventional Commits prefix
|
|
26
|
+
* - {@link CommitLinkKind} — semantic commit↔task relationship
|
|
27
|
+
* - {@link CommitLinkSource} — how a commit↔task link was discovered
|
|
28
|
+
* - {@link CommitFileChangeType} — git status letter (A/M/D/R/C)
|
|
29
|
+
* - {@link ReleaseScheme} — versioning scheme
|
|
30
|
+
* - {@link ReleaseChannel} — npm dist-tag channel
|
|
31
|
+
* - {@link ReleaseKind} — release packaging type
|
|
32
|
+
* - {@link ReleaseStatus} — unified release FSM state
|
|
33
|
+
* - {@link ReleaseChangeType} — 12-value change taxonomy
|
|
34
|
+
* - {@link ReleaseImpact} — semver impact level
|
|
35
|
+
* - {@link ReleaseClassifiedBy} — change-classification provenance
|
|
36
|
+
* - {@link ReleaseArtifactType} — artifact archetype
|
|
37
|
+
* - {@link BrainReleaseLinkType} — BRAIN↔release link semantics
|
|
38
|
+
*
|
|
39
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 · T9955 (Phase 0c)
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
// ── Pull-request unions (T9507) ─────────────────────────────────────────
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* State of a pull request.
|
|
46
|
+
*
|
|
47
|
+
* Mirrors the GitHub PR state machine:
|
|
48
|
+
* - `open` — PR is open and not yet merged
|
|
49
|
+
* - `closed` — PR was closed without merging
|
|
50
|
+
* - `merged` — PR was merged into the target branch
|
|
51
|
+
*
|
|
52
|
+
* @task T9507
|
|
53
|
+
*/
|
|
54
|
+
export type PrState = 'open' | 'closed' | 'merged';
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* How a PR↔task link was discovered.
|
|
58
|
+
*
|
|
59
|
+
* - `pr-title` — task ID matched in the PR title
|
|
60
|
+
* - `pr-body` — task ID matched in the PR body markdown
|
|
61
|
+
* - `branch-name` — parsed from the branch name (e.g. `feat/T9507-...`)
|
|
62
|
+
* - `commit-trailer` — extracted from a git trailer in a PR commit
|
|
63
|
+
* - `manual` — explicitly linked via `cleo provenance link`
|
|
64
|
+
*
|
|
65
|
+
* @task T9507
|
|
66
|
+
*/
|
|
67
|
+
export type PrLinkSource = 'pr-title' | 'pr-body' | 'branch-name' | 'commit-trailer' | 'manual';
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Semantic classification of a PR↔task relationship.
|
|
71
|
+
*
|
|
72
|
+
* Extends {@link CommitLinkKind} with `'tracks'` for PRs that observe a
|
|
73
|
+
* task without directly implementing, fixing, or documenting it.
|
|
74
|
+
*
|
|
75
|
+
* - `implements` — the PR directly implements the task's acceptance criteria
|
|
76
|
+
* - `fixes` — the PR fixes a bug or regression in the task's work
|
|
77
|
+
* - `refactors` — the PR restructures code introduced by the task
|
|
78
|
+
* - `tests` — the PR adds or updates tests for the task
|
|
79
|
+
* - `docs` — the PR updates documentation for the task
|
|
80
|
+
* - `reverts` — the PR reverts work introduced by the task
|
|
81
|
+
* - `tracks` — the PR is related to but does not directly implement the task
|
|
82
|
+
*
|
|
83
|
+
* @task T9507
|
|
84
|
+
*/
|
|
85
|
+
export type PrLinkKind =
|
|
86
|
+
| 'implements'
|
|
87
|
+
| 'fixes'
|
|
88
|
+
| 'refactors'
|
|
89
|
+
| 'tests'
|
|
90
|
+
| 'docs'
|
|
91
|
+
| 'reverts'
|
|
92
|
+
| 'tracks';
|
|
93
|
+
|
|
94
|
+
// ── Commit unions (T9506) ───────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Conventional Commits prefix parsed from a commit subject.
|
|
98
|
+
*
|
|
99
|
+
* Adds `'breaking'` to the canonical CC set to flag BREAKING CHANGE
|
|
100
|
+
* footers. The DB column is nullable — a commit that does not follow
|
|
101
|
+
* Conventional Commits format stores NULL rather than one of these values.
|
|
102
|
+
*
|
|
103
|
+
* @task T9506
|
|
104
|
+
*/
|
|
105
|
+
export type CommitConventionalType =
|
|
106
|
+
| 'feat'
|
|
107
|
+
| 'fix'
|
|
108
|
+
| 'chore'
|
|
109
|
+
| 'docs'
|
|
110
|
+
| 'refactor'
|
|
111
|
+
| 'test'
|
|
112
|
+
| 'build'
|
|
113
|
+
| 'ci'
|
|
114
|
+
| 'perf'
|
|
115
|
+
| 'revert'
|
|
116
|
+
| 'breaking';
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Semantic classification of a commit↔task relationship.
|
|
120
|
+
*
|
|
121
|
+
* - `implements` — the commit directly implements the task's acceptance criteria
|
|
122
|
+
* - `fixes` — the commit fixes a bug or regression in the task's work
|
|
123
|
+
* - `refactors` — the commit restructures code introduced by the task
|
|
124
|
+
* - `tests` — the commit adds or updates tests for the task
|
|
125
|
+
* - `docs` — the commit updates documentation for the task
|
|
126
|
+
* - `reverts` — the commit reverts work introduced by the task
|
|
127
|
+
*
|
|
128
|
+
* @task T9506
|
|
129
|
+
*/
|
|
130
|
+
export type CommitLinkKind = 'implements' | 'fixes' | 'refactors' | 'tests' | 'docs' | 'reverts';
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* How a commit↔task link was discovered.
|
|
134
|
+
*
|
|
135
|
+
* - `commit-trailer` — extracted from a `T####:` or `Task-Id:` git trailer
|
|
136
|
+
* - `commit-subject` — matched `T####` regex in the commit subject line
|
|
137
|
+
* - `pr-title` — matched task ID in the PR title
|
|
138
|
+
* - `pr-body` — matched task ID in the PR body markdown
|
|
139
|
+
* - `branch-name` — parsed from the branch name (e.g., `feat/T9506-...`)
|
|
140
|
+
* - `manual` — explicitly linked via `cleo provenance link`
|
|
141
|
+
*
|
|
142
|
+
* @task T9506
|
|
143
|
+
*/
|
|
144
|
+
export type CommitLinkSource =
|
|
145
|
+
| 'commit-trailer'
|
|
146
|
+
| 'commit-subject'
|
|
147
|
+
| 'pr-title'
|
|
148
|
+
| 'pr-body'
|
|
149
|
+
| 'branch-name'
|
|
150
|
+
| 'manual';
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Per-file change type from a git diff (status letter codes).
|
|
154
|
+
*
|
|
155
|
+
* - `A` — added
|
|
156
|
+
* - `M` — modified
|
|
157
|
+
* - `D` — deleted
|
|
158
|
+
* - `R` — renamed
|
|
159
|
+
* - `C` — copied
|
|
160
|
+
*
|
|
161
|
+
* @task T9506
|
|
162
|
+
*/
|
|
163
|
+
export type CommitFileChangeType = 'A' | 'M' | 'D' | 'R' | 'C';
|
|
164
|
+
|
|
165
|
+
// ── Release unions (T9508) ──────────────────────────────────────────────
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* Versioning scheme for a release.
|
|
169
|
+
*
|
|
170
|
+
* - `calver` — YYYY.MM.patch (e.g. 2026.5.74) — CLEO default
|
|
171
|
+
* - `semver` — MAJOR.MINOR.PATCH (e.g. 1.2.3)
|
|
172
|
+
* - `calver-suffix` — YYYY.MM.patch.N suffix hotfix (e.g. 2026.5.74.2)
|
|
173
|
+
*
|
|
174
|
+
* @task T9508
|
|
175
|
+
* @remarks
|
|
176
|
+
* The values here MUST stay aligned with `RELEASE_SCHEMES` in
|
|
177
|
+
* `tasks-schema.ts`; that const array drives the Drizzle row type. A
|
|
178
|
+
* compile-time structural assertion in
|
|
179
|
+
* `packages/contracts/src/__tests__/provenance.test.ts` pins both sides.
|
|
180
|
+
*/
|
|
181
|
+
export type ReleaseScheme = 'calver' | 'semver' | 'calver-suffix';
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Release channel — controls which npm dist-tag (or equivalent) the
|
|
185
|
+
* artifact is published under.
|
|
186
|
+
*
|
|
187
|
+
* - `latest` — current stable
|
|
188
|
+
* - `beta` — pre-release tested in production-adjacent environments
|
|
189
|
+
* - `dev` — internal development snapshots
|
|
190
|
+
* - `hotfix` — emergency patch outside the regular cadence
|
|
191
|
+
*
|
|
192
|
+
* @task T9508
|
|
193
|
+
* @remarks
|
|
194
|
+
* Distinct from the `ReleaseChannel` exported by
|
|
195
|
+
* `@cleocode/contracts/release/channel` (which carries the npm-level
|
|
196
|
+
* `latest|beta|alpha` set) and from the `ReleaseChannel` in
|
|
197
|
+
* `@cleocode/contracts/release/plan` (which carries the release-plan
|
|
198
|
+
* `latest|beta|alpha|rc` set). Top-level `@cleocode/contracts` re-exports
|
|
199
|
+
* this union under a disambiguating alias.
|
|
200
|
+
*/
|
|
201
|
+
export type ReleaseChannel = 'latest' | 'beta' | 'dev' | 'hotfix';
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Release packaging kind, orthogonal to individual change types within
|
|
205
|
+
* the release.
|
|
206
|
+
*
|
|
207
|
+
* - `regular` — standard scheduled release
|
|
208
|
+
* - `hotfix` — emergency patch outside regular cadence
|
|
209
|
+
* - `prerelease` — alpha/beta/rc release for early adopters
|
|
210
|
+
*
|
|
211
|
+
* @task T9508
|
|
212
|
+
*/
|
|
213
|
+
export type ReleaseKind = 'regular' | 'hotfix' | 'prerelease';
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Unified release FSM state (admits values from BOTH the new T9492
|
|
217
|
+
* pipeline and the legacy T5580 pipeline; the status value itself
|
|
218
|
+
* discriminates which pipeline owns the row).
|
|
219
|
+
*
|
|
220
|
+
* **New T9492 pipeline** — SPEC-T9345 §10.1 FSM:
|
|
221
|
+
* `planned → pr-opened → pr-merged → published → reconciled`
|
|
222
|
+
*
|
|
223
|
+
* **Legacy T5580 pipeline** — pre-T9492 12-step flow:
|
|
224
|
+
* `prepared → committed → tagged → pushed`
|
|
225
|
+
*
|
|
226
|
+
* **Shared terminal states**:
|
|
227
|
+
* `rolled_back | failed | cancelled`
|
|
228
|
+
*
|
|
229
|
+
* State transitions per R-302 MUST be monotonic within each lifecycle;
|
|
230
|
+
* illegal transitions return `E_INVALID_STATE` and MUST NOT mutate any row.
|
|
231
|
+
*
|
|
232
|
+
* @task T9508
|
|
233
|
+
* @task T9686 (unification — legacy + new statuses on one column)
|
|
234
|
+
* @see SPEC-T9345 §10.1
|
|
235
|
+
*/
|
|
236
|
+
export type ReleaseStatus =
|
|
237
|
+
| 'planned'
|
|
238
|
+
| 'pr-opened'
|
|
239
|
+
| 'pr-merged'
|
|
240
|
+
| 'published'
|
|
241
|
+
| 'reconciled'
|
|
242
|
+
| 'prepared'
|
|
243
|
+
| 'committed'
|
|
244
|
+
| 'tagged'
|
|
245
|
+
| 'pushed'
|
|
246
|
+
| 'rolled_back'
|
|
247
|
+
| 'failed'
|
|
248
|
+
| 'cancelled';
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* 12-value CLEO release change taxonomy (Option B from
|
|
252
|
+
* provenance-graph-design.md §2.2).
|
|
253
|
+
*
|
|
254
|
+
* Lives at the release-changes level (not on `tasks.kind`) so that:
|
|
255
|
+
* - A single task can produce multiple change rows across releases.
|
|
256
|
+
* - Hotfix classification is a release-packaging decision, not a task property.
|
|
257
|
+
* - Auto-classification is agent-writable without touching OWNER-WRITE-ONLY fields.
|
|
258
|
+
*
|
|
259
|
+
* @task T9508
|
|
260
|
+
* @see SPEC-T9345 §2.2
|
|
261
|
+
*/
|
|
262
|
+
export type ReleaseChangeType =
|
|
263
|
+
| 'feature'
|
|
264
|
+
| 'enhancement'
|
|
265
|
+
| 'bug'
|
|
266
|
+
| 'hotfix'
|
|
267
|
+
| 'security'
|
|
268
|
+
| 'breaking'
|
|
269
|
+
| 'refactor'
|
|
270
|
+
| 'docs'
|
|
271
|
+
| 'chore'
|
|
272
|
+
| 'revert'
|
|
273
|
+
| 'deprecation'
|
|
274
|
+
| 'infrastructure';
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Impact level for a release change, mapped to semver bump assessment.
|
|
278
|
+
*
|
|
279
|
+
* - `major` — breaking change (MAJOR bump)
|
|
280
|
+
* - `minor` — new feature (MINOR bump)
|
|
281
|
+
* - `patch` — bug fix / chore (PATCH bump)
|
|
282
|
+
* - `none` — cosmetic / docs / trivial (no version bump warranted alone)
|
|
283
|
+
*
|
|
284
|
+
* @task T9508
|
|
285
|
+
*/
|
|
286
|
+
export type ReleaseImpact = 'major' | 'minor' | 'patch' | 'none';
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Provenance of a release-change classification.
|
|
290
|
+
*
|
|
291
|
+
* - `auto` — derived by the classification engine from CC prefix + heuristics
|
|
292
|
+
* - `manual` — owner overrode the auto classification via `cleo release classify`
|
|
293
|
+
* - `approved` — owner approved an agent-proposed classification
|
|
294
|
+
*
|
|
295
|
+
* @task T9508
|
|
296
|
+
*/
|
|
297
|
+
export type ReleaseClassifiedBy = 'auto' | 'manual' | 'approved';
|
|
298
|
+
|
|
299
|
+
// ── Release artifact + BRAIN-link unions (T9509) ─────────────────────────
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* Release artifact archetype.
|
|
303
|
+
*
|
|
304
|
+
* - `npm` — npm package published to a registry
|
|
305
|
+
* - `cargo` — Rust crate published to crates.io
|
|
306
|
+
* - `docker` — Container image pushed to an OCI registry
|
|
307
|
+
* - `pypi` — Python package published to pypi.org
|
|
308
|
+
* - `github-release` — GitHub Releases asset attached to a git tag
|
|
309
|
+
* - `binary` — Generic compiled binary distributed via direct URL
|
|
310
|
+
* - `github-tag` — Lightweight git tag (no attached assets)
|
|
311
|
+
*
|
|
312
|
+
* @task T9509
|
|
313
|
+
* @see SPEC-T9345 §3.9
|
|
314
|
+
*/
|
|
315
|
+
export type ReleaseArtifactType =
|
|
316
|
+
| 'npm'
|
|
317
|
+
| 'cargo'
|
|
318
|
+
| 'docker'
|
|
319
|
+
| 'pypi'
|
|
320
|
+
| 'github-release'
|
|
321
|
+
| 'binary'
|
|
322
|
+
| 'github-tag';
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Semantic relationship between a BRAIN entry and a release.
|
|
326
|
+
*
|
|
327
|
+
* - `approved-by` — A BRAIN decision approved a change that shipped in this release.
|
|
328
|
+
* - `documented-in` — This release is where the BRAIN entry was first formally documented.
|
|
329
|
+
* - `derived-from` — The release's failure or outcome produced this BRAIN learning/pattern.
|
|
330
|
+
* - `observed-in` — A BRAIN observation was made about this release (e.g. performance note).
|
|
331
|
+
*
|
|
332
|
+
* @task T9509
|
|
333
|
+
* @see SPEC-T9345 §8.1
|
|
334
|
+
*/
|
|
335
|
+
export type BrainReleaseLinkType = 'approved-by' | 'documented-in' | 'derived-from' | 'observed-in';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scaffold + diagnostic result contracts.
|
|
3
|
+
*
|
|
4
|
+
* Canonical home for the result shapes produced by CLEO's directory/file
|
|
5
|
+
* scaffolding utilities (`ensure*`) and read-only health-check utilities
|
|
6
|
+
* (`check*`). Promoted to `@cleocode/contracts` in Phase 0a of the
|
|
7
|
+
* SG-ARCH-SOLID Saga to eliminate duplicate definitions that previously
|
|
8
|
+
* lived in `packages/core/src/scaffold.ts`, `injection.ts`, `hooks.ts`,
|
|
9
|
+
* `schema-management.ts`, and `validation/doctor/checks.ts`.
|
|
10
|
+
*
|
|
11
|
+
* Consolidated types:
|
|
12
|
+
* - {@link ScaffoldResult} — was defined 3× in core (scaffold/injection/hooks)
|
|
13
|
+
* - {@link CheckStatus} — was defined 2× in core (scaffold/doctor checks)
|
|
14
|
+
* - {@link CheckResult} — was defined 2× in core (scaffold/doctor checks)
|
|
15
|
+
* - {@link HookCheckResult} — single canonical definition (no prior duplication;
|
|
16
|
+
* promoted here to keep all scaffold-diagnostic shapes co-located)
|
|
17
|
+
*
|
|
18
|
+
* NOT consolidated (intentional — different domain shape):
|
|
19
|
+
* - `CheckResult` in `packages/core/src/schema-management.ts` is a
|
|
20
|
+
* `{ ok, installed, bundled, missing, stale }` schema-install report,
|
|
21
|
+
* unrelated to diagnostic checks. It retains its local definition and
|
|
22
|
+
* will be renamed in a follow-up slice if/when its naming collision
|
|
23
|
+
* warrants a separate cleanup task.
|
|
24
|
+
*
|
|
25
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
// ── ScaffoldResult ────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Result of an `ensure*` scaffolding operation.
|
|
32
|
+
*
|
|
33
|
+
* All ensure functions in `@cleocode/core` are idempotent — they may
|
|
34
|
+
* create, repair, or skip the requested resource and report which
|
|
35
|
+
* action they took.
|
|
36
|
+
*
|
|
37
|
+
* Originally defined in:
|
|
38
|
+
* - `packages/core/src/scaffold.ts`
|
|
39
|
+
* - `packages/core/src/injection.ts`
|
|
40
|
+
* - `packages/core/src/hooks.ts`
|
|
41
|
+
*
|
|
42
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
43
|
+
*/
|
|
44
|
+
export interface ScaffoldResult {
|
|
45
|
+
/** What action was taken: created, repaired, or skipped. */
|
|
46
|
+
action: 'created' | 'repaired' | 'skipped';
|
|
47
|
+
/** Filesystem path that was operated on. */
|
|
48
|
+
path: string;
|
|
49
|
+
/** Human-readable explanation of the result. */
|
|
50
|
+
details?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// ── CheckStatus + CheckResult ─────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Status of a `check*` diagnostic.
|
|
57
|
+
*
|
|
58
|
+
* Originally defined in:
|
|
59
|
+
* - `packages/core/src/scaffold.ts`
|
|
60
|
+
* - `packages/core/src/validation/doctor/checks.ts`
|
|
61
|
+
*
|
|
62
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
63
|
+
*/
|
|
64
|
+
export type CheckStatus = 'passed' | 'failed' | 'warning' | 'info';
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Result of a `check*` diagnostic (used by `cleo doctor` and scaffold
|
|
68
|
+
* health checks).
|
|
69
|
+
*
|
|
70
|
+
* Originally defined in:
|
|
71
|
+
* - `packages/core/src/scaffold.ts`
|
|
72
|
+
* - `packages/core/src/validation/doctor/checks.ts`
|
|
73
|
+
*
|
|
74
|
+
* The scaffold.ts and doctor/checks.ts definitions were structurally
|
|
75
|
+
* identical; this is the consolidated shape with TSDoc preserved.
|
|
76
|
+
*
|
|
77
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
78
|
+
*/
|
|
79
|
+
export interface CheckResult {
|
|
80
|
+
/** Unique check identifier (e.g. "cleo_structure", "sqlite_db"). */
|
|
81
|
+
id: string;
|
|
82
|
+
/** Category grouping (e.g. "scaffold", "global"). */
|
|
83
|
+
category: string;
|
|
84
|
+
/** Diagnostic outcome: passed, failed, warning, or info. */
|
|
85
|
+
status: CheckStatus;
|
|
86
|
+
/** Human-readable description of the check result. */
|
|
87
|
+
message: string;
|
|
88
|
+
/** Structured metadata about the check (paths, sizes, missing items). */
|
|
89
|
+
details: Record<string, unknown>;
|
|
90
|
+
/** Suggested CLI command to fix the issue, or null if passed. */
|
|
91
|
+
fix: string | null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ── HookCheckResult ───────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Result of a git-hook installation check.
|
|
98
|
+
*
|
|
99
|
+
* Reports whether a managed hook (commit-msg, pre-commit, pre-push) is
|
|
100
|
+
* installed in `.git/hooks/` and whether the installed copy matches the
|
|
101
|
+
* source template under `packages/core/templates/git-hooks/`.
|
|
102
|
+
*
|
|
103
|
+
* Originally defined in `packages/core/src/hooks.ts`. Promoted here to
|
|
104
|
+
* co-locate all scaffold-diagnostic shapes.
|
|
105
|
+
*
|
|
106
|
+
* @since SG-ARCH-SOLID Saga T9831 · E-CONTRACTS-FOUNDATION T9832 (Phase 0a)
|
|
107
|
+
*/
|
|
108
|
+
export interface HookCheckResult {
|
|
109
|
+
/** Hook name (commit-msg, pre-commit, pre-push). */
|
|
110
|
+
hook: string;
|
|
111
|
+
/** Whether the hook is installed at `.git/hooks/<hook>`. */
|
|
112
|
+
installed: boolean;
|
|
113
|
+
/** Whether the installed hook bytes match the source template. */
|
|
114
|
+
current: boolean;
|
|
115
|
+
/** Absolute path of the source template that should be installed. */
|
|
116
|
+
sourcePath: string;
|
|
117
|
+
/** Absolute path where the hook is (or would be) installed. */
|
|
118
|
+
installedPath: string;
|
|
119
|
+
}
|
package/src/session.ts
CHANGED
|
@@ -137,6 +137,43 @@ export interface Session {
|
|
|
137
137
|
gradeMode?: boolean;
|
|
138
138
|
/** ID of the provider adapter used for this session. @defaultValue undefined */
|
|
139
139
|
providerId?: string | null;
|
|
140
|
+
/**
|
|
141
|
+
* Human-readable agent handle for multi-agent isolation (T9975).
|
|
142
|
+
*
|
|
143
|
+
* Set via `cleo session start --agent <handle>`. Allows concurrent agent
|
|
144
|
+
* sessions to be distinguished in `cleo session list --all` and enables
|
|
145
|
+
* `cleo briefing` env-precedence detection when `CLEO_SESSION_ID` is set.
|
|
146
|
+
*
|
|
147
|
+
* @defaultValue undefined
|
|
148
|
+
*/
|
|
149
|
+
agentHandle?: string | null;
|
|
150
|
+
/**
|
|
151
|
+
* Denormalised scope type ("global" | "epic") for fast index queries (T9975).
|
|
152
|
+
*
|
|
153
|
+
* Derived from `scope.type` at session creation; cached in the DB column
|
|
154
|
+
* `scope_kind` to avoid JSON parsing in hot paths.
|
|
155
|
+
*
|
|
156
|
+
* @defaultValue undefined
|
|
157
|
+
*/
|
|
158
|
+
scopeKind?: string | null;
|
|
159
|
+
/**
|
|
160
|
+
* Denormalised scope target ID (e.g. "T9964") for epic sessions (T9975).
|
|
161
|
+
*
|
|
162
|
+
* Derived from `scope.epicId` / `scope.rootTaskId` at session creation.
|
|
163
|
+
* NULL for global sessions.
|
|
164
|
+
*
|
|
165
|
+
* @defaultValue undefined
|
|
166
|
+
*/
|
|
167
|
+
scopeId?: string | null;
|
|
168
|
+
/**
|
|
169
|
+
* ISO 8601 timestamp of the last mutation on this session (T9975).
|
|
170
|
+
*
|
|
171
|
+
* Updated on session start, task focus change, and task completion.
|
|
172
|
+
* Used by the idle auto-end lifecycle hook and `cleo session list --all`.
|
|
173
|
+
*
|
|
174
|
+
* @defaultValue undefined
|
|
175
|
+
*/
|
|
176
|
+
lastActivity?: string | null;
|
|
140
177
|
}
|
|
141
178
|
|
|
142
179
|
/**
|