codex-workflow-v2 2.0.0-alpha.1
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/README.md +71 -0
- package/dist/src/artifacts.d.ts +4 -0
- package/dist/src/artifacts.js +106 -0
- package/dist/src/artifacts.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +356 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/contracts.d.ts +313 -0
- package/dist/src/contracts.js +3 -0
- package/dist/src/contracts.js.map +1 -0
- package/dist/src/diagnostics.d.ts +19 -0
- package/dist/src/diagnostics.js +25 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/domain/discovery.d.ts +8 -0
- package/dist/src/domain/discovery.js +25 -0
- package/dist/src/domain/discovery.js.map +1 -0
- package/dist/src/domain/validation.d.ts +3 -0
- package/dist/src/domain/validation.js +96 -0
- package/dist/src/domain/validation.js.map +1 -0
- package/dist/src/errors.d.ts +6 -0
- package/dist/src/errors.js +11 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fs-utils.d.ts +4 -0
- package/dist/src/fs-utils.js +52 -0
- package/dist/src/fs-utils.js.map +1 -0
- package/dist/src/git.d.ts +19 -0
- package/dist/src/git.js +115 -0
- package/dist/src/git.js.map +1 -0
- package/dist/src/graph.d.ts +28 -0
- package/dist/src/graph.js +263 -0
- package/dist/src/graph.js.map +1 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +13 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/memory.d.ts +9 -0
- package/dist/src/memory.js +242 -0
- package/dist/src/memory.js.map +1 -0
- package/dist/src/migration.d.ts +46 -0
- package/dist/src/migration.js +112 -0
- package/dist/src/migration.js.map +1 -0
- package/dist/src/repository.d.ts +12 -0
- package/dist/src/repository.js +69 -0
- package/dist/src/repository.js.map +1 -0
- package/dist/src/reviewer.d.ts +82 -0
- package/dist/src/reviewer.js +184 -0
- package/dist/src/reviewer.js.map +1 -0
- package/dist/src/state/lock.d.ts +13 -0
- package/dist/src/state/lock.js +100 -0
- package/dist/src/state/lock.js.map +1 -0
- package/dist/src/state/store.d.ts +45 -0
- package/dist/src/state/store.js +185 -0
- package/dist/src/state/store.js.map +1 -0
- package/dist/src/ulid.d.ts +2 -0
- package/dist/src/ulid.js +22 -0
- package/dist/src/ulid.js.map +1 -0
- package/dist/src/version.d.ts +2 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/dist/src/workflow.d.ts +93 -0
- package/dist/src/workflow.js +1276 -0
- package/dist/src/workflow.js.map +1 -0
- package/docs/decisions.md +38 -0
- package/docs/development-flow.md +69 -0
- package/docs/project-memory.md +38 -0
- package/docs/release.md +26 -0
- package/docs/validation-report.md +19 -0
- package/package.json +56 -0
- package/plugins/codex-workflow-gateway/.codex-plugin/plugin.json +25 -0
- package/plugins/codex-workflow-gateway/references/protocol.md +66 -0
- package/plugins/codex-workflow-gateway/scripts/install-or-update.sh +26 -0
- package/plugins/codex-workflow-gateway/skills/codex-workflow-gateway/SKILL.md +72 -0
- package/references/discovery.md +12 -0
- package/references/git-policy.md +7 -0
- package/references/state-machine.md +11 -0
- package/references/validation-and-review.md +13 -0
- package/roles/delivery-coordinator.md +10 -0
- package/roles/independent-reviewer.md +10 -0
- package/roles/scope-lead.md +11 -0
- package/roles/technical-planner.md +10 -0
- package/roles/worker.md +10 -0
- package/schemas/context-envelope.schema.json +58 -0
- package/schemas/discovery.schema.json +19 -0
- package/schemas/graph-binding.schema.json +30 -0
- package/schemas/milestone.schema.json +58 -0
- package/schemas/project-knowledge-map.schema.json +37 -0
- package/schemas/review-result.schema.json +30 -0
- package/schemas/task.schema.json +39 -0
- package/templates/brief.md +21 -0
- package/templates/plan.md +17 -0
- package/templates/result.md +13 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { lstatSync, readFileSync, readdirSync, realpathSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { STATE_SCHEMA_VERSION, } from './contracts.js';
|
|
5
|
+
import { WorkflowError } from './errors.js';
|
|
6
|
+
export const KNOWLEDGE_CATEGORIES = [
|
|
7
|
+
'agent-guidance',
|
|
8
|
+
'onboarding',
|
|
9
|
+
'architecture',
|
|
10
|
+
'decisions',
|
|
11
|
+
'commands',
|
|
12
|
+
'ownership',
|
|
13
|
+
'testing',
|
|
14
|
+
'operations',
|
|
15
|
+
'domain',
|
|
16
|
+
];
|
|
17
|
+
const ignoredDirectories = new Set([
|
|
18
|
+
'.git',
|
|
19
|
+
'.worktrees',
|
|
20
|
+
'.test-dist',
|
|
21
|
+
'node_modules',
|
|
22
|
+
'dist',
|
|
23
|
+
'build',
|
|
24
|
+
'coverage',
|
|
25
|
+
]);
|
|
26
|
+
export function scanProjectKnowledge(repositoryRoot, projectId, now = new Date()) {
|
|
27
|
+
const root = realpathSync(repositoryRoot);
|
|
28
|
+
const timestamp = now.toISOString();
|
|
29
|
+
const entries = [];
|
|
30
|
+
walk(root, root, (absolute, relative) => {
|
|
31
|
+
const category = classifyKnowledgePath(relative);
|
|
32
|
+
if (!category)
|
|
33
|
+
return;
|
|
34
|
+
const scope = normalizeScope(path.posix.dirname(relative));
|
|
35
|
+
entries.push({
|
|
36
|
+
id: sourceId(category, relative),
|
|
37
|
+
category,
|
|
38
|
+
path: relative,
|
|
39
|
+
scope,
|
|
40
|
+
authority: 'supporting',
|
|
41
|
+
contentHash: hashFile(absolute),
|
|
42
|
+
discoveredBy: 'repository-scan',
|
|
43
|
+
lastVerifiedAt: timestamp,
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
entries.sort(compareSources);
|
|
47
|
+
const gaps = knowledgeGaps(entries);
|
|
48
|
+
return {
|
|
49
|
+
schemaVersion: STATE_SCHEMA_VERSION,
|
|
50
|
+
revision: 0,
|
|
51
|
+
id: 'PROJECT-KNOWLEDGE-MAP',
|
|
52
|
+
projectId,
|
|
53
|
+
createdAt: timestamp,
|
|
54
|
+
updatedAt: timestamp,
|
|
55
|
+
kind: 'knowledge-map',
|
|
56
|
+
status: 'awaiting_approval',
|
|
57
|
+
entries,
|
|
58
|
+
gaps,
|
|
59
|
+
conflicts: [],
|
|
60
|
+
approval: null,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export function applyKnowledgeSelections(map, selections, actor, now = new Date()) {
|
|
64
|
+
const byId = new Map(map.entries.map((entry) => [entry.id, entry]));
|
|
65
|
+
const selectedIds = new Set();
|
|
66
|
+
for (const selection of selections) {
|
|
67
|
+
if (selectedIds.has(selection.sourceId)) {
|
|
68
|
+
throw new WorkflowError('INVALID_ARGUMENT', `Duplicate knowledge selection: ${selection.sourceId}`);
|
|
69
|
+
}
|
|
70
|
+
selectedIds.add(selection.sourceId);
|
|
71
|
+
if (!byId.has(selection.sourceId)) {
|
|
72
|
+
throw new WorkflowError('INVALID_ARGUMENT', `Unknown knowledge source: ${selection.sourceId}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const authority = new Map(selections.map((selection) => [selection.sourceId, selection.authority]));
|
|
76
|
+
const entries = map.entries
|
|
77
|
+
.map((entry) => ({ ...entry, authority: authority.get(entry.id) ?? entry.authority }))
|
|
78
|
+
.sort(compareSources);
|
|
79
|
+
const conflicts = knowledgeConflicts(entries);
|
|
80
|
+
const candidate = {
|
|
81
|
+
...map,
|
|
82
|
+
entries,
|
|
83
|
+
gaps: knowledgeGaps(entries),
|
|
84
|
+
conflicts,
|
|
85
|
+
approval: null,
|
|
86
|
+
status: conflicts.length > 0 ? 'conflicted' : 'awaiting_approval',
|
|
87
|
+
};
|
|
88
|
+
if (conflicts.length > 0)
|
|
89
|
+
return candidate;
|
|
90
|
+
const mapHash = hashKnowledgeMap(candidate);
|
|
91
|
+
return {
|
|
92
|
+
...candidate,
|
|
93
|
+
status: 'active',
|
|
94
|
+
approval: {
|
|
95
|
+
mapHash,
|
|
96
|
+
actor: actor.trim() || 'user',
|
|
97
|
+
approvedAt: now.toISOString(),
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
export function reconcileKnowledgeMap(current, scanned) {
|
|
102
|
+
const previous = new Map(current.entries.map((entry) => [`${entry.category}\0${entry.path}\0${entry.scope}`, entry]));
|
|
103
|
+
const entries = scanned.entries.map((entry) => {
|
|
104
|
+
const existing = previous.get(`${entry.category}\0${entry.path}\0${entry.scope}`);
|
|
105
|
+
return existing ? { ...entry, authority: existing.authority } : entry;
|
|
106
|
+
});
|
|
107
|
+
const conflicts = knowledgeConflicts(entries);
|
|
108
|
+
const candidate = {
|
|
109
|
+
...scanned,
|
|
110
|
+
createdAt: current.createdAt,
|
|
111
|
+
entries: entries.sort(compareSources),
|
|
112
|
+
gaps: knowledgeGaps(entries),
|
|
113
|
+
conflicts,
|
|
114
|
+
status: conflicts.length > 0 ? 'conflicted' : 'awaiting_approval',
|
|
115
|
+
};
|
|
116
|
+
if (current.status !== 'active' || !current.approval)
|
|
117
|
+
return candidate;
|
|
118
|
+
return hashKnowledgeMap(candidate) === current.approval.mapHash
|
|
119
|
+
? { ...candidate, status: 'active', approval: current.approval }
|
|
120
|
+
: { ...candidate, status: conflicts.length > 0 ? 'conflicted' : 'stale', approval: null };
|
|
121
|
+
}
|
|
122
|
+
export function inspectKnowledgeMap(current, scanned) {
|
|
123
|
+
const reconciled = reconcileKnowledgeMap(current, scanned);
|
|
124
|
+
return { ...reconciled, revision: current.revision, updatedAt: current.updatedAt };
|
|
125
|
+
}
|
|
126
|
+
export function hashKnowledgeMap(map) {
|
|
127
|
+
const stable = {
|
|
128
|
+
projectId: map.projectId,
|
|
129
|
+
entries: [...map.entries].sort(compareSources).map(({ lastVerifiedAt: _verified, ...entry }) => entry),
|
|
130
|
+
gaps: [...map.gaps].sort(compareGaps),
|
|
131
|
+
conflicts: [...map.conflicts].sort(compareConflicts),
|
|
132
|
+
};
|
|
133
|
+
return createHash('sha256').update(JSON.stringify(stable)).digest('hex');
|
|
134
|
+
}
|
|
135
|
+
export function selectKnowledgeSources(map, role, targetPaths = []) {
|
|
136
|
+
const targets = new Set(targetPaths.map(normalizeRelativePath));
|
|
137
|
+
const roleCategories = {
|
|
138
|
+
'scope-lead': new Set(KNOWLEDGE_CATEGORIES),
|
|
139
|
+
'technical-planner': new Set(['agent-guidance', 'onboarding', 'architecture', 'decisions', 'commands', 'ownership', 'testing', 'domain']),
|
|
140
|
+
'delivery-coordinator': new Set(['agent-guidance', 'commands', 'ownership', 'testing', 'operations']),
|
|
141
|
+
worker: new Set(['agent-guidance', 'commands', 'testing']),
|
|
142
|
+
'independent-reviewer': new Set(KNOWLEDGE_CATEGORIES),
|
|
143
|
+
};
|
|
144
|
+
return map.entries
|
|
145
|
+
.filter((entry) => entry.authority === 'canonical' || targets.has(entry.path))
|
|
146
|
+
.filter((entry) => roleCategories[role].has(entry.category) || targets.has(entry.path))
|
|
147
|
+
.map((entry) => entry.path)
|
|
148
|
+
.sort();
|
|
149
|
+
}
|
|
150
|
+
export function normalizeRelativePath(value) {
|
|
151
|
+
const normalized = value.replaceAll('\\', '/').replace(/^\.\//, '');
|
|
152
|
+
if (!normalized || normalized === '.' || path.posix.isAbsolute(normalized)) {
|
|
153
|
+
throw new WorkflowError('INVALID_ARGUMENT', `Knowledge path must be repository-relative: ${value}`);
|
|
154
|
+
}
|
|
155
|
+
const clean = path.posix.normalize(normalized);
|
|
156
|
+
if (clean === '..' || clean.startsWith('../')) {
|
|
157
|
+
throw new WorkflowError('INVALID_ARGUMENT', `Knowledge path escapes repository root: ${value}`);
|
|
158
|
+
}
|
|
159
|
+
return clean;
|
|
160
|
+
}
|
|
161
|
+
function walk(root, directory, visit) {
|
|
162
|
+
const entries = readdirSync(directory, { withFileTypes: true }).sort((left, right) => left.name.localeCompare(right.name));
|
|
163
|
+
for (const entry of entries) {
|
|
164
|
+
if (entry.isDirectory() && ignoredDirectories.has(entry.name))
|
|
165
|
+
continue;
|
|
166
|
+
const absolute = path.join(directory, entry.name);
|
|
167
|
+
if (entry.isSymbolicLink())
|
|
168
|
+
continue;
|
|
169
|
+
if (entry.isDirectory()) {
|
|
170
|
+
walk(root, absolute, visit);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (!entry.isFile() || !lstatSync(absolute).isFile())
|
|
174
|
+
continue;
|
|
175
|
+
const relative = path.relative(root, absolute).replaceAll(path.sep, '/');
|
|
176
|
+
visit(absolute, normalizeRelativePath(relative));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function classifyKnowledgePath(relative) {
|
|
180
|
+
const lower = relative.toLowerCase();
|
|
181
|
+
const base = path.posix.basename(lower);
|
|
182
|
+
if (base === 'agents.md')
|
|
183
|
+
return 'agent-guidance';
|
|
184
|
+
if (/^readme(?:\.[a-z0-9_-]+)?$/.test(base))
|
|
185
|
+
return 'onboarding';
|
|
186
|
+
if (base === 'codeowners' || base === 'owners')
|
|
187
|
+
return 'ownership';
|
|
188
|
+
if (base === 'package.json' || base === 'makefile' || base === 'justfile' || /^taskfile(?:\..+)?$/.test(base))
|
|
189
|
+
return 'commands';
|
|
190
|
+
if (/(^|\/)(adr|adrs|decisions)(\/|$)/.test(lower) || /^adr[-_].+\.md$/.test(base))
|
|
191
|
+
return 'decisions';
|
|
192
|
+
if (/(^|\/)(architecture|architectures)(\/|$)/.test(lower) || /architecture.*\.md$/.test(base))
|
|
193
|
+
return 'architecture';
|
|
194
|
+
if (/(^|\/)(domain|domains)(\/|$)/.test(lower))
|
|
195
|
+
return 'domain';
|
|
196
|
+
if (/(^|\/)(operations|runbooks?)(\/|$)/.test(lower) || /^dockerfile/.test(base) || /^compose.*\.ya?ml$/.test(base))
|
|
197
|
+
return 'operations';
|
|
198
|
+
if (/(^|\/)(\.github\/workflows|tests?|testing)(\/|$)/.test(lower) || /^(vitest|jest|playwright|cypress|pytest|test).*(json|js|ts|mjs|cjs|toml|ini)$/.test(base))
|
|
199
|
+
return 'testing';
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
function knowledgeGaps(entries) {
|
|
203
|
+
const present = new Set(entries.map((entry) => entry.category));
|
|
204
|
+
return KNOWLEDGE_CATEGORIES
|
|
205
|
+
.filter((category) => !present.has(category))
|
|
206
|
+
.map((category) => ({ category, scope: '.', reason: `No ${category} source was discovered.` }));
|
|
207
|
+
}
|
|
208
|
+
function knowledgeConflicts(entries) {
|
|
209
|
+
const groups = new Map();
|
|
210
|
+
for (const entry of entries.filter((candidate) => candidate.authority === 'canonical')) {
|
|
211
|
+
const key = `${entry.category}\0${entry.scope}`;
|
|
212
|
+
groups.set(key, [...(groups.get(key) ?? []), entry]);
|
|
213
|
+
}
|
|
214
|
+
return [...groups.values()]
|
|
215
|
+
.filter((group) => group.length > 1)
|
|
216
|
+
.map((group) => ({
|
|
217
|
+
category: group[0].category,
|
|
218
|
+
scope: group[0].scope,
|
|
219
|
+
sourceIds: group.map((entry) => entry.id).sort(),
|
|
220
|
+
reason: 'More than one canonical source exists for the same category and scope.',
|
|
221
|
+
}))
|
|
222
|
+
.sort(compareConflicts);
|
|
223
|
+
}
|
|
224
|
+
function sourceId(category, relative) {
|
|
225
|
+
return `KS-${createHash('sha256').update(`${category}\0${relative}`).digest('hex').slice(0, 16)}`;
|
|
226
|
+
}
|
|
227
|
+
function hashFile(file) {
|
|
228
|
+
return createHash('sha256').update(readFileSync(file)).digest('hex');
|
|
229
|
+
}
|
|
230
|
+
function normalizeScope(value) {
|
|
231
|
+
return value === '.' || value === '' ? '.' : normalizeRelativePath(value);
|
|
232
|
+
}
|
|
233
|
+
function compareSources(left, right) {
|
|
234
|
+
return `${left.category}\0${left.scope}\0${left.path}`.localeCompare(`${right.category}\0${right.scope}\0${right.path}`);
|
|
235
|
+
}
|
|
236
|
+
function compareGaps(left, right) {
|
|
237
|
+
return `${left.category}\0${left.scope}`.localeCompare(`${right.category}\0${right.scope}`);
|
|
238
|
+
}
|
|
239
|
+
function compareConflicts(left, right) {
|
|
240
|
+
return `${left.category}\0${left.scope}`.localeCompare(`${right.category}\0${right.scope}`);
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,oBAAoB,GAQrB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,CAAC,MAAM,oBAAoB,GAAiC;IAChE,gBAAgB;IAChB,YAAY;IACZ,cAAc;IACd,WAAW;IACX,UAAU;IACV,WAAW;IACX,SAAS;IACT,YAAY;IACZ,QAAQ;CACT,CAAC;AAEF,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC;IACjC,MAAM;IACN,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,MAAM;IACN,OAAO;IACP,UAAU;CACX,CAAC,CAAC;AAEH,MAAM,UAAU,oBAAoB,CAClC,cAAsB,EACtB,SAAiB,EACjB,MAAY,IAAI,IAAI,EAAE;IAEtB,MAAM,IAAI,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;IACpC,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE;QACtC,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,CAAC,QAAQ;YAAE,OAAO;QACtB,MAAM,KAAK,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,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,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;AAC3H,CAAC;AAED,SAAS,WAAW,CAAC,IAAkB,EAAE,KAAmB;IAC1D,OAAO,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;AAC9F,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAuB,EAAE,KAAwB;IACzE,OAAO,GAAG,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,KAAK,EAAE,CAAC,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,KAAK,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;AAC9F,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { FileStateStore } from './state/store.js';
|
|
2
|
+
interface SnapshotFile {
|
|
3
|
+
path: string;
|
|
4
|
+
mode: number;
|
|
5
|
+
size: number;
|
|
6
|
+
sha256: string;
|
|
7
|
+
contentBase64: string;
|
|
8
|
+
}
|
|
9
|
+
interface LegacySnapshot {
|
|
10
|
+
format: 'codex-workflow-v1-snapshot';
|
|
11
|
+
version: 1;
|
|
12
|
+
projectId: string;
|
|
13
|
+
repositoryRootFingerprint: string;
|
|
14
|
+
git: {
|
|
15
|
+
head: string;
|
|
16
|
+
branch: string | null;
|
|
17
|
+
statusPorcelainV1: string[];
|
|
18
|
+
refs: string[];
|
|
19
|
+
};
|
|
20
|
+
files: SnapshotFile[];
|
|
21
|
+
}
|
|
22
|
+
export interface MigrationReport {
|
|
23
|
+
dryRun: boolean;
|
|
24
|
+
snapshotRequested: boolean;
|
|
25
|
+
projectId: string;
|
|
26
|
+
stateSchemaVersion: number;
|
|
27
|
+
entities: {
|
|
28
|
+
discoveries: number;
|
|
29
|
+
tasks: number;
|
|
30
|
+
milestones: number;
|
|
31
|
+
};
|
|
32
|
+
actions: string[];
|
|
33
|
+
legacy: {
|
|
34
|
+
detected: boolean;
|
|
35
|
+
paths: string[];
|
|
36
|
+
automaticMappingSupported: false;
|
|
37
|
+
};
|
|
38
|
+
snapshot: null | {
|
|
39
|
+
format: LegacySnapshot['format'];
|
|
40
|
+
contentHash: string;
|
|
41
|
+
file: string;
|
|
42
|
+
fileCount: number;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export declare function migrateState(repository: string, store: FileStateStore, dryRun: boolean, snapshotRequested?: boolean): MigrationReport;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { existsSync, lstatSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { gzipSync } from 'node:zlib';
|
|
5
|
+
import { STATE_SCHEMA_VERSION } from './contracts.js';
|
|
6
|
+
import { WorkflowError } from './errors.js';
|
|
7
|
+
import { ensureDirectory } from './fs-utils.js';
|
|
8
|
+
import { resolveRepositoryIdentity, runGit } from './repository.js';
|
|
9
|
+
const LEGACY_CANDIDATES = ['.tasks', '.increments', '.codex-workflow.json', '.codex-workflow.lock.json'];
|
|
10
|
+
export function migrateState(repository, store, dryRun, snapshotRequested = !dryRun) {
|
|
11
|
+
if (dryRun && snapshotRequested) {
|
|
12
|
+
throw new WorkflowError('INVALID_ARGUMENT', 'Choose either migration dry-run or snapshot creation.');
|
|
13
|
+
}
|
|
14
|
+
const identity = resolveRepositoryIdentity(repository);
|
|
15
|
+
store.registerProject(identity);
|
|
16
|
+
const legacyPaths = LEGACY_CANDIDATES.filter((candidate) => existsSync(path.join(identity.repositoryRoot, candidate)));
|
|
17
|
+
const report = {
|
|
18
|
+
dryRun,
|
|
19
|
+
snapshotRequested,
|
|
20
|
+
projectId: identity.projectId,
|
|
21
|
+
stateSchemaVersion: STATE_SCHEMA_VERSION,
|
|
22
|
+
entities: {
|
|
23
|
+
discoveries: store.listDiscoveries(identity.projectId).length,
|
|
24
|
+
tasks: store.listTasks(identity.projectId).length,
|
|
25
|
+
milestones: store.listMilestones(identity.projectId).length,
|
|
26
|
+
},
|
|
27
|
+
actions: [],
|
|
28
|
+
legacy: {
|
|
29
|
+
detected: legacyPaths.length > 0,
|
|
30
|
+
paths: legacyPaths,
|
|
31
|
+
automaticMappingSupported: false,
|
|
32
|
+
},
|
|
33
|
+
snapshot: null,
|
|
34
|
+
};
|
|
35
|
+
if (!snapshotRequested)
|
|
36
|
+
return report;
|
|
37
|
+
if (legacyPaths.length === 0) {
|
|
38
|
+
throw new WorkflowError('NOT_FOUND', 'No legacy V1 workflow state was detected.');
|
|
39
|
+
}
|
|
40
|
+
const snapshot = buildSnapshot(identity.repositoryRoot, identity.projectId, legacyPaths);
|
|
41
|
+
const bytes = gzipSync(Buffer.from(`${JSON.stringify(snapshot)}\n`, 'utf8'), { level: 9 });
|
|
42
|
+
const contentHash = createHash('sha256').update(bytes).digest('hex');
|
|
43
|
+
const directory = store.snapshotRoot(identity.projectId);
|
|
44
|
+
const file = path.join(directory, `${contentHash}.snapshot.json.gz`);
|
|
45
|
+
ensureDirectory(directory);
|
|
46
|
+
if (!existsSync(file))
|
|
47
|
+
writeFileSync(file, bytes, { mode: 0o600, flag: 'wx' });
|
|
48
|
+
report.actions.push('Created immutable legacy snapshot; no V1 state was imported or modified.');
|
|
49
|
+
report.snapshot = {
|
|
50
|
+
format: snapshot.format,
|
|
51
|
+
contentHash,
|
|
52
|
+
file,
|
|
53
|
+
fileCount: snapshot.files.length,
|
|
54
|
+
};
|
|
55
|
+
return report;
|
|
56
|
+
}
|
|
57
|
+
function buildSnapshot(repositoryRoot, projectId, legacyPaths) {
|
|
58
|
+
const files = legacyPaths.flatMap((relative) => collectFiles(repositoryRoot, relative));
|
|
59
|
+
files.sort((left, right) => left.path.localeCompare(right.path));
|
|
60
|
+
const branch = safeGit(repositoryRoot, ['symbolic-ref', '--short', 'HEAD']) || null;
|
|
61
|
+
return {
|
|
62
|
+
format: 'codex-workflow-v1-snapshot',
|
|
63
|
+
version: 1,
|
|
64
|
+
projectId,
|
|
65
|
+
repositoryRootFingerprint: createHash('sha256').update(path.resolve(repositoryRoot)).digest('hex'),
|
|
66
|
+
git: {
|
|
67
|
+
head: runGit(repositoryRoot, ['rev-parse', 'HEAD']),
|
|
68
|
+
branch,
|
|
69
|
+
statusPorcelainV1: safeGit(repositoryRoot, ['status', '--porcelain=v1', '--untracked-files=all'])
|
|
70
|
+
.split('\n')
|
|
71
|
+
.filter(Boolean)
|
|
72
|
+
.sort(),
|
|
73
|
+
refs: safeGit(repositoryRoot, ['for-each-ref', '--format=%(refname) %(objectname)'])
|
|
74
|
+
.split('\n')
|
|
75
|
+
.filter(Boolean)
|
|
76
|
+
.sort(),
|
|
77
|
+
},
|
|
78
|
+
files,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function collectFiles(repositoryRoot, relative) {
|
|
82
|
+
const absolute = path.join(repositoryRoot, relative);
|
|
83
|
+
const stat = lstatSync(absolute);
|
|
84
|
+
if (stat.isSymbolicLink()) {
|
|
85
|
+
throw new WorkflowError('TRANSITION_BLOCKED', `Legacy snapshot rejects symbolic link: ${relative}`);
|
|
86
|
+
}
|
|
87
|
+
if (stat.isDirectory()) {
|
|
88
|
+
return readdirSync(absolute)
|
|
89
|
+
.sort()
|
|
90
|
+
.flatMap((name) => collectFiles(repositoryRoot, path.join(relative, name)));
|
|
91
|
+
}
|
|
92
|
+
if (!stat.isFile()) {
|
|
93
|
+
throw new WorkflowError('TRANSITION_BLOCKED', `Legacy snapshot supports regular files only: ${relative}`);
|
|
94
|
+
}
|
|
95
|
+
const content = readFileSync(absolute);
|
|
96
|
+
return [{
|
|
97
|
+
path: relative.split(path.sep).join('/'),
|
|
98
|
+
mode: stat.mode & 0o777,
|
|
99
|
+
size: content.length,
|
|
100
|
+
sha256: createHash('sha256').update(content).digest('hex'),
|
|
101
|
+
contentBase64: content.toString('base64'),
|
|
102
|
+
}];
|
|
103
|
+
}
|
|
104
|
+
function safeGit(repositoryRoot, args) {
|
|
105
|
+
try {
|
|
106
|
+
return runGit(repositoryRoot, args);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return '';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=migration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.js","sourceRoot":"","sources":["../../src/migration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGpE,MAAM,iBAAiB,GAAG,CAAC,QAAQ,EAAE,aAAa,EAAE,sBAAsB,EAAE,2BAA2B,CAAC,CAAC;AA4CzG,MAAM,UAAU,YAAY,CAC1B,UAAkB,EAClB,KAAqB,EACrB,MAAe,EACf,iBAAiB,GAAG,CAAC,MAAM;IAE3B,IAAI,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAChC,MAAM,IAAI,aAAa,CAAC,kBAAkB,EAAE,uDAAuD,CAAC,CAAC;IACvG,CAAC;IACD,MAAM,QAAQ,GAAG,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACvD,KAAK,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IAChC,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC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ACD,MAAM,OAAO,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,CAAC;YACN,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;YACxC,IAAI,EAAE,IAAI,CAAC,IAAI,GAAG,KAAK;YACvB,IAAI,EAAE,OAAO,CAAC,MAAM;YACpB,MAAM,EAAE,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;YAC1D,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;SAC1C,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,cAAsB,EAAE,IAAc;IACrD,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface RepositoryIdentity {
|
|
2
|
+
projectId: string;
|
|
3
|
+
repositoryRoot: string;
|
|
4
|
+
gitCommonDir: string;
|
|
5
|
+
}
|
|
6
|
+
export declare function runGit(repositoryRoot: string, args: string[], allowFailure?: boolean): string;
|
|
7
|
+
export declare function resolveRepositoryIdentity(repository: string): RepositoryIdentity;
|
|
8
|
+
export declare function currentBranch(repositoryRoot: string): string | null;
|
|
9
|
+
export declare function headCommit(repositoryRoot: string): string;
|
|
10
|
+
export declare function changedFiles(repositoryRoot: string): string[];
|
|
11
|
+
export declare function isClean(repositoryRoot: string): boolean;
|
|
12
|
+
export declare function gitIsAncestor(repositoryRoot: string, ancestor: string, descendant: string): boolean;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawnSync } from 'node:child_process';
|
|
5
|
+
import { WorkflowError } from './errors.js';
|
|
6
|
+
export function runGit(repositoryRoot, args, allowFailure = false) {
|
|
7
|
+
const result = spawnSync('git', ['-C', repositoryRoot, ...args], { encoding: 'utf8' });
|
|
8
|
+
if (result.status !== 0 && !allowFailure) {
|
|
9
|
+
throw new WorkflowError('COMMAND_FAILED', `git ${args.join(' ')} failed`, {
|
|
10
|
+
stdout: result.stdout.trim(),
|
|
11
|
+
stderr: result.stderr.trim(),
|
|
12
|
+
exitCode: result.status,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
return result.stdout.trim();
|
|
16
|
+
}
|
|
17
|
+
export function resolveRepositoryIdentity(repository) {
|
|
18
|
+
const repositoryRoot = realpathSync(runGit(repository, ['rev-parse', '--show-toplevel']));
|
|
19
|
+
const rawCommonDir = runGit(repositoryRoot, ['rev-parse', '--git-common-dir']);
|
|
20
|
+
const commonCandidate = path.isAbsolute(rawCommonDir)
|
|
21
|
+
? rawCommonDir
|
|
22
|
+
: path.resolve(repositoryRoot, rawCommonDir);
|
|
23
|
+
const gitCommonDir = realpathSync(commonCandidate);
|
|
24
|
+
const projectId = createHash('sha256').update(gitCommonDir).digest('hex').slice(0, 24);
|
|
25
|
+
return { projectId, repositoryRoot, gitCommonDir };
|
|
26
|
+
}
|
|
27
|
+
export function currentBranch(repositoryRoot) {
|
|
28
|
+
const branch = runGit(repositoryRoot, ['branch', '--show-current'], true);
|
|
29
|
+
return branch || null;
|
|
30
|
+
}
|
|
31
|
+
export function headCommit(repositoryRoot) {
|
|
32
|
+
return runGit(repositoryRoot, ['rev-parse', 'HEAD']);
|
|
33
|
+
}
|
|
34
|
+
export function changedFiles(repositoryRoot) {
|
|
35
|
+
const result = spawnSync('git', ['-C', repositoryRoot, 'status', '--porcelain=v1', '--untracked-files=all'], { encoding: 'utf8' });
|
|
36
|
+
if (result.status !== 0) {
|
|
37
|
+
throw new WorkflowError('COMMAND_FAILED', 'Unable to inspect Git working tree.', {
|
|
38
|
+
stdout: result.stdout.trim(),
|
|
39
|
+
stderr: result.stderr.trim(),
|
|
40
|
+
exitCode: result.status,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
const output = result.stdout.trimEnd();
|
|
44
|
+
if (!output)
|
|
45
|
+
return [];
|
|
46
|
+
return output.split('\n').map((line) => {
|
|
47
|
+
const entry = line.slice(3).trim();
|
|
48
|
+
const renameTarget = entry.includes(' -> ') ? entry.split(' -> ').at(-1) : entry;
|
|
49
|
+
return renameTarget?.replaceAll('\\', '/') ?? entry;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function isClean(repositoryRoot) {
|
|
53
|
+
return changedFiles(repositoryRoot).length === 0;
|
|
54
|
+
}
|
|
55
|
+
export function gitIsAncestor(repositoryRoot, ancestor, descendant) {
|
|
56
|
+
const result = spawnSync('git', ['-C', repositoryRoot, 'merge-base', '--is-ancestor', ancestor, descendant], { encoding: 'utf8' });
|
|
57
|
+
if (result.status === 0)
|
|
58
|
+
return true;
|
|
59
|
+
if (result.status === 1)
|
|
60
|
+
return false;
|
|
61
|
+
throw new WorkflowError('COMMAND_FAILED', 'Unable to verify Git ancestry.', {
|
|
62
|
+
ancestor,
|
|
63
|
+
descendant,
|
|
64
|
+
stdout: result.stdout.trim(),
|
|
65
|
+
stderr: result.stderr.trim(),
|
|
66
|
+
exitCode: result.status,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repository.js","sourceRoot":"","sources":["../../src/repository.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,aAAa,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,GAAG,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QACjF,OAAO,YAAY,EAAE,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAK,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,cAAsB;IAC5C,OAAO,YAAY,CAAC,cAAc,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,cAAsB,EAAE,QAAgB,EAAE,UAAkB;IACxF,MAAM,MAAM,GAAG,SAAS,CACtB,KAAK,EACL,CAAC,IAAI,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,CAAC,EAC3E,EAAE,QAAQ,EAAE,MAAM,EAAE,CACrB,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACrC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,MAAM,IAAI,aAAa,CAAC,gBAAgB,EAAE,gCAAgC,EAAE;QAC1E,QAAQ;QACR,UAAU;QACV,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;QAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM;KACxB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { ContextEnvelope, ReviewInput, TaskState } from './contracts.js';
|
|
2
|
+
export interface ReviewerProcessResult {
|
|
3
|
+
status: number | null;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}
|
|
7
|
+
export type ReviewerCommandRunner = (command: string, args: string[], options: {
|
|
8
|
+
cwd: string;
|
|
9
|
+
input: string;
|
|
10
|
+
}) => ReviewerProcessResult;
|
|
11
|
+
export interface StrictReviewOutput extends ReviewInput {
|
|
12
|
+
isolationProbe: 'denied' | 'written' | 'not-attempted';
|
|
13
|
+
}
|
|
14
|
+
export interface StrictReviewerLaunchResult {
|
|
15
|
+
review: ReviewInput;
|
|
16
|
+
verifiedIsolation: boolean;
|
|
17
|
+
command: string[];
|
|
18
|
+
processStatus: number | null;
|
|
19
|
+
stderr: string;
|
|
20
|
+
before: RepositorySeal;
|
|
21
|
+
after: RepositorySeal;
|
|
22
|
+
}
|
|
23
|
+
interface RepositorySeal {
|
|
24
|
+
headCommit: string;
|
|
25
|
+
changedFiles: string[];
|
|
26
|
+
contentHash: string;
|
|
27
|
+
}
|
|
28
|
+
declare const REVIEW_SCHEMA: {
|
|
29
|
+
readonly type: "object";
|
|
30
|
+
readonly additionalProperties: false;
|
|
31
|
+
readonly required: readonly ["status", "reviewer", "summary", "findings", "isolationProbe"];
|
|
32
|
+
readonly properties: {
|
|
33
|
+
readonly status: {
|
|
34
|
+
readonly enum: readonly ["passed", "failed", "unverified"];
|
|
35
|
+
};
|
|
36
|
+
readonly reviewer: {
|
|
37
|
+
readonly type: "string";
|
|
38
|
+
readonly minLength: 1;
|
|
39
|
+
};
|
|
40
|
+
readonly summary: {
|
|
41
|
+
readonly type: "string";
|
|
42
|
+
readonly minLength: 1;
|
|
43
|
+
};
|
|
44
|
+
readonly isolationProbe: {
|
|
45
|
+
readonly enum: readonly ["denied", "written", "not-attempted"];
|
|
46
|
+
};
|
|
47
|
+
readonly findings: {
|
|
48
|
+
readonly type: "array";
|
|
49
|
+
readonly items: {
|
|
50
|
+
readonly type: "object";
|
|
51
|
+
readonly additionalProperties: false;
|
|
52
|
+
readonly required: readonly ["id", "severity", "requirement", "summary", "evidence", "requiredAction"];
|
|
53
|
+
readonly properties: {
|
|
54
|
+
readonly id: {
|
|
55
|
+
readonly type: "string";
|
|
56
|
+
readonly minLength: 1;
|
|
57
|
+
};
|
|
58
|
+
readonly severity: {
|
|
59
|
+
readonly enum: readonly ["critical", "major", "minor"];
|
|
60
|
+
};
|
|
61
|
+
readonly requirement: {
|
|
62
|
+
readonly type: readonly ["string", "null"];
|
|
63
|
+
};
|
|
64
|
+
readonly summary: {
|
|
65
|
+
readonly type: "string";
|
|
66
|
+
readonly minLength: 1;
|
|
67
|
+
};
|
|
68
|
+
readonly evidence: {
|
|
69
|
+
readonly type: "string";
|
|
70
|
+
readonly minLength: 1;
|
|
71
|
+
};
|
|
72
|
+
readonly requiredAction: {
|
|
73
|
+
readonly type: "string";
|
|
74
|
+
readonly minLength: 1;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
export declare function launchStrictReviewer(repositoryRoot: string, task: TaskState, taskRoot: string, envelope: ContextEnvelope, runner?: ReviewerCommandRunner): StrictReviewerLaunchResult;
|
|
82
|
+
export { REVIEW_SCHEMA };
|