@besales/ops-framework 0.1.7 → 0.1.8
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/CHANGELOG.md +6 -0
- package/README.md +16 -0
- package/bin/initiative.mjs +294 -1
- package/bin/initiative.test.mjs +41 -0
- package/bin/lib/bootstrap-utils.mjs +2 -0
- package/bin/lib/bootstrap-utils.test.mjs +2 -0
- package/bin/ops-agent.mjs +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.8
|
|
4
|
+
|
|
5
|
+
- Added `initiative-intake` for source-doc indexing, source SHA tracking and deterministic requirement candidates.
|
|
6
|
+
- Added `initiative-requirements` to create `requirements-map.md` and `coverage.md` from intake candidates.
|
|
7
|
+
- Added generated project scripts for initiative intake and requirements mapping.
|
|
8
|
+
|
|
3
9
|
## 0.1.7
|
|
4
10
|
|
|
5
11
|
- Added the first Initiative Framework layer above tasks for MVPs, large feature trains and multi-phase work.
|
package/README.md
CHANGED
|
@@ -184,6 +184,8 @@ Do not commit that `file:` dependency to production projects. It is only for pac
|
|
|
184
184
|
- `initiative-add-work-package`
|
|
185
185
|
- `initiative-status`
|
|
186
186
|
- `initiative-next`
|
|
187
|
+
- `initiative-intake`
|
|
188
|
+
- `initiative-requirements`
|
|
187
189
|
- `test/self-test`
|
|
188
190
|
|
|
189
191
|
## Learning Loop
|
|
@@ -230,6 +232,8 @@ Initiatives are the program-level layer above tasks. Use them for MVPs, large fe
|
|
|
230
232
|
```bash
|
|
231
233
|
ops-agent initiative-create delivery-os-mvp --title "Delivery OS MVP" --mode fast_mvp
|
|
232
234
|
ops-agent initiative-add-work-package delivery-os-mvp WP-001-foundation --title "Foundation"
|
|
235
|
+
ops-agent initiative-intake delivery-os-mvp docs/delivery-os
|
|
236
|
+
ops-agent initiative-requirements delivery-os-mvp
|
|
233
237
|
ops-agent initiative-status delivery-os-mvp
|
|
234
238
|
ops-agent initiative-next delivery-os-mvp --materialize-task
|
|
235
239
|
```
|
|
@@ -244,6 +248,18 @@ Initiative
|
|
|
244
248
|
|
|
245
249
|
Work packages are materialized as normal tasks, so `brief/research/plan/check/execute/verify/retrospective/learning` still works at the audit boundary. Slices are not separate tasks; they use fast execution, micro-verify and slice evidence inside the work-package task. Create a separate task only when a slice triggers scope, risk, architecture or human-approval escalation.
|
|
246
250
|
|
|
251
|
+
For source docs, use intake before work-package planning:
|
|
252
|
+
|
|
253
|
+
```text
|
|
254
|
+
Raw docs
|
|
255
|
+
-> initiative intake/source-index
|
|
256
|
+
-> requirements-map.md
|
|
257
|
+
-> work packages
|
|
258
|
+
-> tasks
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`initiative-intake <initiative> <docs-dir>` indexes supported source documents, writes source SHA hashes and deterministic requirement candidates into `intake/`. `initiative-requirements <initiative>` turns those candidates into `REQ-*` rows in `requirements-map.md` and writes `coverage.md`. Human review is still required before treating candidates as approved or planned.
|
|
262
|
+
|
|
247
263
|
## Feedback Intake
|
|
248
264
|
|
|
249
265
|
Feedback is stage-agnostic. Any user question, correction, review note or learning observation during an active task should be captured before it is acted on:
|
package/bin/initiative.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
|
+
import crypto from 'node:crypto';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import {
|
|
5
6
|
getFlag,
|
|
@@ -14,6 +15,7 @@ import { resolveProjectContext } from './lib/project-config.mjs';
|
|
|
14
15
|
|
|
15
16
|
const INITIATIVE_ID_PATTERN = /^[a-z0-9][a-z0-9-]*$/;
|
|
16
17
|
const WORK_PACKAGE_ID_PATTERN = /^WP-\d{3}-[a-z0-9][a-z0-9-]*$/;
|
|
18
|
+
const SUPPORTED_SOURCE_EXTENSIONS = new Set(['.md', '.markdown', '.txt', '.json', '.yaml', '.yml']);
|
|
17
19
|
|
|
18
20
|
export function main() {
|
|
19
21
|
const command = process.argv[2];
|
|
@@ -63,7 +65,29 @@ export function main() {
|
|
|
63
65
|
printInitiativeNext(result);
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
if (command === 'initiative-intake') {
|
|
69
|
+
const result = initiativeIntake({
|
|
70
|
+
projectRoot: process.cwd(),
|
|
71
|
+
initiativeId: args.positional[0],
|
|
72
|
+
docsDir: args.positional[1],
|
|
73
|
+
force: args.flags.has('force'),
|
|
74
|
+
});
|
|
75
|
+
printChangeSummary(`Initiative intake written: ${result.initiativeId}`, result.changes);
|
|
76
|
+
console.log(`- sources: ${result.sources.length}`);
|
|
77
|
+
console.log(`- requirement candidates: ${result.candidates.length}`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
if (command === 'initiative-requirements') {
|
|
81
|
+
const result = initiativeRequirements({
|
|
82
|
+
projectRoot: process.cwd(),
|
|
83
|
+
initiativeId: args.positional[0],
|
|
84
|
+
force: args.flags.has('force'),
|
|
85
|
+
});
|
|
86
|
+
printChangeSummary(`Initiative requirements map written: ${result.initiativeId}`, result.changes);
|
|
87
|
+
console.log(`- requirements: ${result.requirements.length}`);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
fail('Usage: ops-agent initiative-create|initiative-add-work-package|initiative-status|initiative-next|initiative-intake|initiative-requirements ...');
|
|
67
91
|
} catch (error) {
|
|
68
92
|
fail(error.message);
|
|
69
93
|
}
|
|
@@ -193,6 +217,75 @@ export function initiativeNext({
|
|
|
193
217
|
};
|
|
194
218
|
}
|
|
195
219
|
|
|
220
|
+
export function initiativeIntake({
|
|
221
|
+
projectRoot = process.cwd(),
|
|
222
|
+
initiativeId,
|
|
223
|
+
docsDir,
|
|
224
|
+
force = false,
|
|
225
|
+
} = {}) {
|
|
226
|
+
const initiative = readInitiative({ projectRoot, initiativeId });
|
|
227
|
+
if (!docsDir) {
|
|
228
|
+
throw new Error('Usage: ops-agent initiative-intake <initiative> <docs-dir>');
|
|
229
|
+
}
|
|
230
|
+
const absoluteDocsDir = path.resolve(projectRoot, docsDir);
|
|
231
|
+
if (!fs.existsSync(absoluteDocsDir) || !fs.statSync(absoluteDocsDir).isDirectory()) {
|
|
232
|
+
throw new Error(`Docs directory not found: ${docsDir}`);
|
|
233
|
+
}
|
|
234
|
+
const intakeDir = path.join(initiative.initiativeDir, 'intake');
|
|
235
|
+
const changes = [];
|
|
236
|
+
ensureDirectory(intakeDir, changes);
|
|
237
|
+
const sources = collectSourceDocuments({ projectRoot, docsDir: absoluteDocsDir });
|
|
238
|
+
const candidates = collectRequirementCandidates({ projectRoot, sources });
|
|
239
|
+
writeFileIfAllowed(path.join(intakeDir, 'source-index.json'), JSON.stringify({
|
|
240
|
+
schemaVersion: 1,
|
|
241
|
+
generatedAt: new Date().toISOString(),
|
|
242
|
+
docsDir: path.relative(projectRoot, absoluteDocsDir),
|
|
243
|
+
sources,
|
|
244
|
+
}, null, 2), { force: true, changes });
|
|
245
|
+
writeFileIfAllowed(path.join(intakeDir, 'sources.md'), renderSourcesMarkdown({ docsDir: absoluteDocsDir, projectRoot, sources }), { force, changes });
|
|
246
|
+
writeFileIfAllowed(path.join(intakeDir, 'extracted-requirements.md'), renderRequirementCandidatesMarkdown(candidates), { force: true, changes });
|
|
247
|
+
writeFileIfAllowed(path.join(intakeDir, 'open-questions.md'), buildOpenQuestionsMarkdown(), { force, changes });
|
|
248
|
+
writeFileIfAllowed(path.join(intakeDir, 'assumptions.md'), buildAssumptionsMarkdown(), { force, changes });
|
|
249
|
+
return {
|
|
250
|
+
initiativeId,
|
|
251
|
+
intakeDir,
|
|
252
|
+
sources,
|
|
253
|
+
candidates,
|
|
254
|
+
changes,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export function initiativeRequirements({
|
|
259
|
+
projectRoot = process.cwd(),
|
|
260
|
+
initiativeId,
|
|
261
|
+
force = false,
|
|
262
|
+
} = {}) {
|
|
263
|
+
const initiative = readInitiative({ projectRoot, initiativeId });
|
|
264
|
+
const candidatesPath = path.join(initiative.initiativeDir, 'intake', 'extracted-requirements.md');
|
|
265
|
+
if (!fs.existsSync(candidatesPath)) {
|
|
266
|
+
throw new Error('Missing intake/extracted-requirements.md. Run initiative-intake first.');
|
|
267
|
+
}
|
|
268
|
+
const candidates = parseRequirementCandidates(fs.readFileSync(candidatesPath, 'utf8'));
|
|
269
|
+
const requirements = candidates.map((candidate, index) => ({
|
|
270
|
+
id: `REQ-${String(index + 1).padStart(3, '0')}`,
|
|
271
|
+
status: 'candidate',
|
|
272
|
+
title: summarizeRequirementTitle(candidate.text),
|
|
273
|
+
source: candidate.source,
|
|
274
|
+
sourceHash: candidate.sourceHash,
|
|
275
|
+
text: candidate.text,
|
|
276
|
+
workPackage: '',
|
|
277
|
+
acceptance: '',
|
|
278
|
+
}));
|
|
279
|
+
const changes = [];
|
|
280
|
+
writeFileIfAllowed(path.join(initiative.initiativeDir, 'requirements-map.md'), renderRequirementsMap(requirements), { force: true, changes });
|
|
281
|
+
writeFileIfAllowed(path.join(initiative.initiativeDir, 'coverage.md'), renderCoverage({ requirements }), { force, changes });
|
|
282
|
+
return {
|
|
283
|
+
initiativeId,
|
|
284
|
+
requirements,
|
|
285
|
+
changes,
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
|
|
196
289
|
function materializeWorkPackageTask({ projectRoot, initiativeId, workPackage, taskId, force }) {
|
|
197
290
|
const task = createTask({
|
|
198
291
|
projectRoot,
|
|
@@ -217,6 +310,188 @@ function materializeWorkPackageTask({ projectRoot, initiativeId, workPackage, ta
|
|
|
217
310
|
return task;
|
|
218
311
|
}
|
|
219
312
|
|
|
313
|
+
function collectSourceDocuments({ projectRoot, docsDir }) {
|
|
314
|
+
const files = [];
|
|
315
|
+
walkDocs(docsDir, files);
|
|
316
|
+
return files
|
|
317
|
+
.sort()
|
|
318
|
+
.map((filePath) => {
|
|
319
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
320
|
+
return {
|
|
321
|
+
path: path.relative(projectRoot, filePath),
|
|
322
|
+
bytes: Buffer.byteLength(content),
|
|
323
|
+
sha256: sha256(content),
|
|
324
|
+
title: inferSourceTitle(content, filePath),
|
|
325
|
+
};
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
function walkDocs(directory, files) {
|
|
330
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
331
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') {
|
|
332
|
+
continue;
|
|
333
|
+
}
|
|
334
|
+
const entryPath = path.join(directory, entry.name);
|
|
335
|
+
if (entry.isDirectory()) {
|
|
336
|
+
walkDocs(entryPath, files);
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
if (entry.isFile() && SUPPORTED_SOURCE_EXTENSIONS.has(path.extname(entry.name).toLowerCase())) {
|
|
340
|
+
files.push(entryPath);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function collectRequirementCandidates({ projectRoot, sources }) {
|
|
346
|
+
const candidates = [];
|
|
347
|
+
const seen = new Set();
|
|
348
|
+
for (const source of sources) {
|
|
349
|
+
const sourcePath = path.join(projectRoot, source.path);
|
|
350
|
+
const lines = fs.readFileSync(sourcePath, 'utf8').split(/\r?\n/);
|
|
351
|
+
lines.forEach((line, index) => {
|
|
352
|
+
const normalized = normalizeRequirementCandidate(line);
|
|
353
|
+
if (!isRequirementCandidate(normalized)) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const key = sha256(`${source.path}:${normalized}`).slice(0, 16);
|
|
357
|
+
if (seen.has(key)) {
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
seen.add(key);
|
|
361
|
+
candidates.push({
|
|
362
|
+
id: `RC-${String(candidates.length + 1).padStart(3, '0')}`,
|
|
363
|
+
source: `${source.path}:${index + 1}`,
|
|
364
|
+
sourceHash: source.sha256,
|
|
365
|
+
text: normalized,
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
return candidates;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
function normalizeRequirementCandidate(line) {
|
|
373
|
+
return line
|
|
374
|
+
.replace(/^#{1,6}\s+/, '')
|
|
375
|
+
.replace(/^[-*]\s+/, '')
|
|
376
|
+
.replace(/^\d+[.)]\s+/, '')
|
|
377
|
+
.replace(/\s+/g, ' ')
|
|
378
|
+
.trim();
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
function isRequirementCandidate(text) {
|
|
382
|
+
if (text.length < 20 || text.length > 500) {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
return /(must|should|required|requirement|user can|user must|system must|needs to|нужно|должен|должна|должны|требован|пользователь может|пользователь должен|система должна|необходимо|важно)/i.test(text);
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function renderSourcesMarkdown({ docsDir, projectRoot, sources }) {
|
|
389
|
+
return [
|
|
390
|
+
'# Initiative Sources',
|
|
391
|
+
'',
|
|
392
|
+
`Docs directory: \`${path.relative(projectRoot, docsDir)}\``,
|
|
393
|
+
'',
|
|
394
|
+
'| Source | Title | SHA-256 | Bytes |',
|
|
395
|
+
'| --- | --- | --- | --- |',
|
|
396
|
+
...sources.map((source) => `| \`${source.path}\` | ${escapeTable(source.title)} | \`${source.sha256}\` | ${source.bytes} |`),
|
|
397
|
+
'',
|
|
398
|
+
].join('\n');
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
function renderRequirementCandidatesMarkdown(candidates) {
|
|
402
|
+
return [
|
|
403
|
+
'# Extracted Requirement Candidates',
|
|
404
|
+
'',
|
|
405
|
+
'These are deterministic candidates from source docs. Human review is required before planning work packages.',
|
|
406
|
+
'',
|
|
407
|
+
...candidates.map((candidate) => [
|
|
408
|
+
`## ${candidate.id}`,
|
|
409
|
+
'',
|
|
410
|
+
`- Source: \`${candidate.source}\``,
|
|
411
|
+
`- Source hash: \`${candidate.sourceHash}\``,
|
|
412
|
+
`- Candidate: ${candidate.text}`,
|
|
413
|
+
'',
|
|
414
|
+
].join('\n')),
|
|
415
|
+
].join('\n');
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
function parseRequirementCandidates(content) {
|
|
419
|
+
return content.split(/^##\s+/m).slice(1).map((section) => {
|
|
420
|
+
const [rawId, ...bodyLines] = section.split('\n');
|
|
421
|
+
const body = bodyLines.join('\n');
|
|
422
|
+
return {
|
|
423
|
+
id: rawId.trim(),
|
|
424
|
+
source: readMarkdownListField(body, 'Source'),
|
|
425
|
+
sourceHash: readMarkdownListField(body, 'Source hash'),
|
|
426
|
+
text: readMarkdownListField(body, 'Candidate'),
|
|
427
|
+
};
|
|
428
|
+
}).filter((candidate) => candidate.id && candidate.source && candidate.text);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function renderRequirementsMap(requirements) {
|
|
432
|
+
return [
|
|
433
|
+
'# Requirements Map',
|
|
434
|
+
'',
|
|
435
|
+
'Statuses: `candidate | approved | planned | implemented | rejected`.',
|
|
436
|
+
'',
|
|
437
|
+
'| ID | Status | Requirement | Source | Work package | Acceptance |',
|
|
438
|
+
'| --- | --- | --- | --- | --- | --- |',
|
|
439
|
+
...requirements.map((req) => `| ${req.id} | ${req.status} | ${escapeTable(req.title)} | \`${req.source}\` | ${req.workPackage || ''} | ${req.acceptance || ''} |`),
|
|
440
|
+
'',
|
|
441
|
+
'## Requirement Details',
|
|
442
|
+
'',
|
|
443
|
+
...requirements.map((req) => [
|
|
444
|
+
`### ${req.id}`,
|
|
445
|
+
'',
|
|
446
|
+
`- Status: \`${req.status}\``,
|
|
447
|
+
`- Source: \`${req.source}\``,
|
|
448
|
+
`- Source hash: \`${req.sourceHash}\``,
|
|
449
|
+
`- Work package: ${req.workPackage || '(unassigned)'}`,
|
|
450
|
+
`- Acceptance: ${req.acceptance || '(fill before implementation)'}`,
|
|
451
|
+
`- Requirement: ${req.text}`,
|
|
452
|
+
'',
|
|
453
|
+
].join('\n')),
|
|
454
|
+
].join('\n');
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
function renderCoverage({ requirements }) {
|
|
458
|
+
const counts = countBy(requirements, (req) => req.status || 'candidate');
|
|
459
|
+
return [
|
|
460
|
+
'# Initiative Coverage',
|
|
461
|
+
'',
|
|
462
|
+
`- Total requirements: ${requirements.length}`,
|
|
463
|
+
`- Candidate: ${counts.candidate || 0}`,
|
|
464
|
+
`- Approved: ${counts.approved || 0}`,
|
|
465
|
+
`- Planned: ${counts.planned || 0}`,
|
|
466
|
+
`- Implemented: ${counts.implemented || 0}`,
|
|
467
|
+
`- Rejected: ${counts.rejected || 0}`,
|
|
468
|
+
'',
|
|
469
|
+
'## Unassigned Requirements',
|
|
470
|
+
'',
|
|
471
|
+
...requirements.filter((req) => !req.workPackage).map((req) => `- ${req.id}: ${req.title}`),
|
|
472
|
+
...(requirements.some((req) => !req.workPackage) ? [] : ['- None.']),
|
|
473
|
+
'',
|
|
474
|
+
].join('\n');
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
function buildOpenQuestionsMarkdown() {
|
|
478
|
+
return [
|
|
479
|
+
'# Open Questions',
|
|
480
|
+
'',
|
|
481
|
+
'- Add human decisions discovered during initiative intake.',
|
|
482
|
+
'',
|
|
483
|
+
].join('\n');
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
function buildAssumptionsMarkdown() {
|
|
487
|
+
return [
|
|
488
|
+
'# Assumptions',
|
|
489
|
+
'',
|
|
490
|
+
'- Add assumptions that were required to interpret source docs.',
|
|
491
|
+
'',
|
|
492
|
+
].join('\n');
|
|
493
|
+
}
|
|
494
|
+
|
|
220
495
|
function readInitiative({ projectRoot, initiativeId }) {
|
|
221
496
|
assertInitiativeId(initiativeId);
|
|
222
497
|
const context = resolveProjectContext({ cwd: projectRoot });
|
|
@@ -407,6 +682,11 @@ function readInlineField(content, field) {
|
|
|
407
682
|
return match ? match[1].trim() : '';
|
|
408
683
|
}
|
|
409
684
|
|
|
685
|
+
function readMarkdownListField(content, field) {
|
|
686
|
+
const match = new RegExp(`^- ${escapeRegExp(field)}:\\s*(.*)$`, 'm').exec(content);
|
|
687
|
+
return match ? match[1].replace(/^`|`$/g, '').trim() : '';
|
|
688
|
+
}
|
|
689
|
+
|
|
410
690
|
function readSection(content, heading) {
|
|
411
691
|
const match = new RegExp(`^##\\s+${escapeRegExp(heading)}\\s*\\n([\\s\\S]*?)(?=^##\\s+|\\s*$)`, 'm').exec(content);
|
|
412
692
|
return match ? match[1].trim() : '';
|
|
@@ -516,6 +796,19 @@ function escapeTable(value) {
|
|
|
516
796
|
return String(value).replace(/\|/g, '\\|');
|
|
517
797
|
}
|
|
518
798
|
|
|
799
|
+
function inferSourceTitle(content, filePath) {
|
|
800
|
+
const heading = /^#\s+(.+)$/m.exec(content);
|
|
801
|
+
return heading ? heading[1].trim() : path.basename(filePath);
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
function summarizeRequirementTitle(text) {
|
|
805
|
+
return text.length > 120 ? `${text.slice(0, 117)}...` : text;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
function sha256(value) {
|
|
809
|
+
return crypto.createHash('sha256').update(value).digest('hex');
|
|
810
|
+
}
|
|
811
|
+
|
|
519
812
|
function escapeRegExp(value) {
|
|
520
813
|
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
521
814
|
}
|
package/bin/initiative.test.mjs
CHANGED
|
@@ -5,7 +5,9 @@ import { describe, expect, it } from 'vitest';
|
|
|
5
5
|
import {
|
|
6
6
|
addWorkPackage,
|
|
7
7
|
createInitiative,
|
|
8
|
+
initiativeIntake,
|
|
8
9
|
initiativeNext,
|
|
10
|
+
initiativeRequirements,
|
|
9
11
|
initiativeStatus,
|
|
10
12
|
} from './initiative.mjs';
|
|
11
13
|
|
|
@@ -72,6 +74,45 @@ describe('initiative framework', () => {
|
|
|
72
74
|
expect(workPackage).toContain('Status: in_progress');
|
|
73
75
|
expect(workPackage).toContain('Task: TASK-001-foundation');
|
|
74
76
|
});
|
|
77
|
+
|
|
78
|
+
it('indexes source docs and builds a requirements map', () => {
|
|
79
|
+
const root = makeProject();
|
|
80
|
+
const docsDir = path.join(root, 'docs', 'delivery-os');
|
|
81
|
+
fs.mkdirSync(docsDir, { recursive: true });
|
|
82
|
+
fs.writeFileSync(path.join(docsDir, 'mvp.md'), [
|
|
83
|
+
'# Delivery OS MVP',
|
|
84
|
+
'',
|
|
85
|
+
'- User must create delivery orders from the admin UI.',
|
|
86
|
+
'- Система должна показывать статус доставки оператору.',
|
|
87
|
+
'- Nice prose for background context only.',
|
|
88
|
+
].join('\n'));
|
|
89
|
+
createInitiative({
|
|
90
|
+
projectRoot: root,
|
|
91
|
+
initiativeId: 'delivery-os-mvp',
|
|
92
|
+
title: 'Delivery OS MVP',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const intake = initiativeIntake({
|
|
96
|
+
projectRoot: root,
|
|
97
|
+
initiativeId: 'delivery-os-mvp',
|
|
98
|
+
docsDir: 'docs/delivery-os',
|
|
99
|
+
});
|
|
100
|
+
const requirements = initiativeRequirements({
|
|
101
|
+
projectRoot: root,
|
|
102
|
+
initiativeId: 'delivery-os-mvp',
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
expect(intake.sources).toHaveLength(1);
|
|
106
|
+
expect(intake.candidates).toHaveLength(2);
|
|
107
|
+
expect(requirements.requirements).toHaveLength(2);
|
|
108
|
+
const initiativeDir = path.join(root, 'ops', 'agent-pipeline', 'initiatives', 'delivery-os-mvp');
|
|
109
|
+
const sourceIndex = JSON.parse(fs.readFileSync(path.join(initiativeDir, 'intake', 'source-index.json'), 'utf8'));
|
|
110
|
+
const requirementsMap = fs.readFileSync(path.join(initiativeDir, 'requirements-map.md'), 'utf8');
|
|
111
|
+
expect(sourceIndex.sources[0].path).toBe('docs/delivery-os/mvp.md');
|
|
112
|
+
expect(requirementsMap).toContain('REQ-001');
|
|
113
|
+
expect(requirementsMap).toContain('User must create delivery orders');
|
|
114
|
+
expect(requirementsMap).toContain('REQ-002');
|
|
115
|
+
});
|
|
75
116
|
});
|
|
76
117
|
|
|
77
118
|
function makeProject() {
|
|
@@ -125,6 +125,8 @@ export function buildOpsScripts(packageSpec) {
|
|
|
125
125
|
'agent:initiative-add-work-package': run('initiative-add-work-package'),
|
|
126
126
|
'agent:initiative-status': run('initiative-status'),
|
|
127
127
|
'agent:initiative-next': run('initiative-next'),
|
|
128
|
+
'agent:initiative-intake': run('initiative-intake'),
|
|
129
|
+
'agent:initiative-requirements': run('initiative-requirements'),
|
|
128
130
|
'agent:test': run('test/self-test'),
|
|
129
131
|
};
|
|
130
132
|
}
|
|
@@ -142,6 +142,8 @@ describe('buildOpsScripts', () => {
|
|
|
142
142
|
expect(scripts['agent:closeout']).toBe('ops-agent closeout');
|
|
143
143
|
expect(scripts['agent:initiative-create']).toBe('ops-agent initiative-create');
|
|
144
144
|
expect(scripts['agent:initiative-next']).toBe('ops-agent initiative-next');
|
|
145
|
+
expect(scripts['agent:initiative-intake']).toBe('ops-agent initiative-intake');
|
|
146
|
+
expect(scripts['agent:initiative-requirements']).toBe('ops-agent initiative-requirements');
|
|
145
147
|
expect(scripts['agent:test']).toBe('ops-agent test/self-test');
|
|
146
148
|
});
|
|
147
149
|
});
|
package/bin/ops-agent.mjs
CHANGED
|
@@ -38,6 +38,8 @@ const COMMANDS = new Map([
|
|
|
38
38
|
['initiative-add-work-package', 'initiative.mjs'],
|
|
39
39
|
['initiative-status', 'initiative.mjs'],
|
|
40
40
|
['initiative-next', 'initiative.mjs'],
|
|
41
|
+
['initiative-intake', 'initiative.mjs'],
|
|
42
|
+
['initiative-requirements', 'initiative.mjs'],
|
|
41
43
|
['test/self-test', null],
|
|
42
44
|
]);
|
|
43
45
|
|