cliewen-openspec 0.1.0 → 0.2.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/CHANGELOG.md +88 -69
- package/README.md +106 -102
- package/dist/cli.js +3 -3
- package/dist/compatibility.d.ts +12 -0
- package/dist/compatibility.js +87 -0
- package/dist/core.d.ts +14 -2
- package/dist/core.js +60 -22
- package/dist/release.d.ts +9 -0
- package/dist/release.js +23 -0
- package/dist/schema-source.js +1 -1
- package/docs/configuration.md +317 -278
- package/docs/testing/evidence.md +88 -88
- package/package.json +2 -2
- package/schemas/base/instructions/closure.md +33 -0
- package/schemas/base/instructions/planning.md +31 -0
- package/schemas/base/instructions/product-context.md +31 -0
- package/schemas/base/instructions/prototyping.md +33 -0
- package/schemas/base/instructions/testing-approach.md +1 -0
- package/schemas/base/instructions/work-scoping.md +12 -0
- package/schemas/base/instructions/writing.md +2 -0
- package/schemas/delivery/instructions/apply.md +1 -0
- package/schemas/discovery/instructions/apply.md +1 -0
- package/schemas/discovery/instructions/investigation.md +1 -0
package/dist/core.js
CHANGED
|
@@ -12,7 +12,9 @@ import { template } from './schema-source.js';
|
|
|
12
12
|
import { validateRegistry } from './ac.js';
|
|
13
13
|
import { qualityDefaults, configureQuality, checkQuality } from './quality.js';
|
|
14
14
|
export { nextId, renamePrefix, capabilityForPrefix } from './ac.js';
|
|
15
|
-
|
|
15
|
+
import { version, supportedInstallations, supportsInstallation } from './release.js';
|
|
16
|
+
import { compatibility } from './compatibility.js';
|
|
17
|
+
export { version } from './release.js';
|
|
16
18
|
const state = '.cliewen-openspec';
|
|
17
19
|
const features = ['documentation', 'decisions', 'mermaid', 'planning', 'review', 'evidence'];
|
|
18
20
|
export function local(root, relative) {
|
|
@@ -214,7 +216,7 @@ export function recover(root) {
|
|
|
214
216
|
}
|
|
215
217
|
fs.unlinkSync(jp);
|
|
216
218
|
}
|
|
217
|
-
function bundledFiles() { return { ...deliveryFiles(), ...discoveryFiles(), ...allFiles(), [`${state}/templates/learning.md`]: template('base/templates/learning.md') }; }
|
|
219
|
+
function bundledFiles() { return { ...deliveryFiles(), ...discoveryFiles(), ...allFiles(), [`${state}/templates/learning.md`]: template('base/templates/learning.md'), [`${state}/planning.md`]: template('base/instructions/planning.md') + '\n## Work scoping\n\n' + template('base/instructions/work-scoping.md'), [`${state}/closure.md`]: template('base/instructions/closure.md'), [`${state}/prototyping.md`]: template('base/instructions/prototyping.md'), [`${state}/product-context.md`]: template('base/instructions/product-context.md') }; }
|
|
218
220
|
function manifestText(files) {
|
|
219
221
|
return JSON.stringify({ version, files: Object.fromEntries(Object.entries(files).map(([file, content]) => [file, hash(content)])) }, null, 2) + '\n';
|
|
220
222
|
}
|
|
@@ -226,13 +228,13 @@ function ownedManifest(root, operation) {
|
|
|
226
228
|
: 'No Cliewen installation manifest; no files removed. Uninstall requires recorded ownership.');
|
|
227
229
|
const previous = JSON.parse(read(mp));
|
|
228
230
|
keys(previous, ['version', 'files'], 'manifest');
|
|
229
|
-
if (previous.version
|
|
230
|
-
throw Error(`Unsupported installed version: ${previous.version}; ${operation} supports ${
|
|
231
|
+
if (!supportsInstallation(previous.version))
|
|
232
|
+
throw Error(`Unsupported installed version: ${previous.version}; ${operation} supports ${supportedInstallations.join(', ')} manifests only. Install a compatible package; no automatic migration or downgrade is available.`);
|
|
231
233
|
if (!previous.files || typeof previous.files !== 'object' || Array.isArray(previous.files) || !Object.keys(previous.files).length)
|
|
232
234
|
throw Error('Manifest files must be a nonempty ownership mapping');
|
|
233
235
|
for (const [file, digest] of Object.entries(previous.files)) {
|
|
234
236
|
local(root, file);
|
|
235
|
-
const owned = [`${state}/templates/decision.md`, `${state}/templates/learning.md`].includes(file) || /^openspec\/schemas\/cliewen-(delivery|discovery|all)\/(schema\.yaml|templates\/[a-z0-9][a-z0-9-]*\.md)$/.test(file);
|
|
237
|
+
const owned = [`${state}/templates/decision.md`, `${state}/templates/learning.md`, `${state}/planning.md`, `${state}/closure.md`, `${state}/prototyping.md`, `${state}/product-context.md`].includes(file) || /^openspec\/schemas\/cliewen-(delivery|discovery|all)\/(schema\.yaml|templates\/[a-z0-9][a-z0-9-]*\.md)$/.test(file);
|
|
236
238
|
if (!owned || typeof digest !== 'string' || !/^[a-f0-9]{64}$/.test(digest))
|
|
237
239
|
throw Error(`Invalid owned-file entry in manifest: ${file}`);
|
|
238
240
|
}
|
|
@@ -359,11 +361,9 @@ export function uninstall(root, dryRun = false, replacement) {
|
|
|
359
361
|
transaction(root, changes, dryRun);
|
|
360
362
|
return { writes: Object.keys(changes).filter(file => changes[file] !== null), deletes: Object.keys(changes).filter(file => changes[file] === null) };
|
|
361
363
|
}
|
|
362
|
-
|
|
364
|
+
function planUpdate(root) {
|
|
363
365
|
if (!fs.existsSync(local(root, 'openspec/specs')) || !fs.existsSync(local(root, 'openspec/changes')))
|
|
364
366
|
throw Error('Run openspec init first (specs and changes directories are required).');
|
|
365
|
-
if (!dryRun)
|
|
366
|
-
recover(root);
|
|
367
367
|
const manifestPath = `${state}/manifest.json`;
|
|
368
368
|
const mp = local(root, manifestPath);
|
|
369
369
|
const previous = ownedManifest(root, 'update');
|
|
@@ -401,18 +401,15 @@ export function update(root, dryRun = false) {
|
|
|
401
401
|
const manifest = manifestText(files);
|
|
402
402
|
if (read(mp) !== manifest)
|
|
403
403
|
changes[manifestPath] = manifest;
|
|
404
|
-
|
|
405
|
-
return { writes: Object.keys(changes).filter(file => changes[file] !== null), deletes: Object.keys(changes).filter(file => changes[file] === null) };
|
|
404
|
+
return changes;
|
|
406
405
|
}
|
|
407
|
-
|
|
406
|
+
function planInit(root, makeDefault) {
|
|
408
407
|
if (!fs.existsSync(local(root, 'openspec/specs')) || !fs.existsSync(local(root, 'openspec/changes')))
|
|
409
408
|
throw Error('Run openspec init first (specs and changes directories are required).');
|
|
410
|
-
if (!dryRun)
|
|
411
|
-
recover(root);
|
|
412
409
|
const mp = local(root, `${state}/manifest.json`);
|
|
413
|
-
const previous = fs.existsSync(mp) ?
|
|
410
|
+
const previous = fs.existsSync(mp) ? ownedManifest(root, 'update') : undefined;
|
|
414
411
|
if (previous && previous.version !== version)
|
|
415
|
-
throw Error(`Installed version differs;
|
|
412
|
+
throw Error(`Installed version differs: ${previous.version}; run update to install ${version} resources. Init does not upgrade an existing installation.`);
|
|
416
413
|
const files = bundledFiles();
|
|
417
414
|
const writes = {};
|
|
418
415
|
for (const [p, content] of Object.entries(files)) {
|
|
@@ -443,7 +440,15 @@ export function init(root, dryRun, makeDefault) {
|
|
|
443
440
|
const doc = parseDocument(original || '{}');
|
|
444
441
|
if (doc.errors.length)
|
|
445
442
|
throw Error(doc.errors[0].message);
|
|
443
|
+
if (doc.contents !== null && !isMap(doc.contents))
|
|
444
|
+
throw Error('OpenSpec config must be a YAML mapping');
|
|
445
|
+
const before = { ...doc.toJS() };
|
|
446
|
+
delete before.schema;
|
|
446
447
|
doc.set('schema', 'cliewen-delivery');
|
|
448
|
+
const after = { ...doc.toJS() };
|
|
449
|
+
delete after.schema;
|
|
450
|
+
if (!isDeepStrictEqual(before, after))
|
|
451
|
+
throw Error('Selecting the default would change other YAML values through shared anchors; resolve those aliases explicitly before init.');
|
|
447
452
|
const next = doc.toString();
|
|
448
453
|
if (next !== original)
|
|
449
454
|
writes[cfgPath] = next;
|
|
@@ -451,7 +456,36 @@ export function init(root, dryRun, makeDefault) {
|
|
|
451
456
|
const manifest = manifestText(files);
|
|
452
457
|
if (!fs.existsSync(mp) || read(mp) !== manifest)
|
|
453
458
|
writes[`${state}/manifest.json`] = manifest;
|
|
454
|
-
return
|
|
459
|
+
return writes;
|
|
460
|
+
}
|
|
461
|
+
export function lifecycle(root, operation, dryRun = false, makeDefault = false) {
|
|
462
|
+
const tools = compatibility(root);
|
|
463
|
+
const pending = fs.existsSync(local(root, `${state}/transaction.json`));
|
|
464
|
+
if (pending && dryRun)
|
|
465
|
+
throw Error('Interrupted transaction exists; run recover before preview. No preview files changed.');
|
|
466
|
+
if (pending)
|
|
467
|
+
recover(root);
|
|
468
|
+
try {
|
|
469
|
+
const mp = local(root, `${state}/manifest.json`);
|
|
470
|
+
const installedVersion = fs.existsSync(mp) ? ownedManifest(root, 'update').version : null;
|
|
471
|
+
const changes = operation === 'init' ? planInit(root, makeDefault) : planUpdate(root);
|
|
472
|
+
const writes = Object.keys(changes).filter(file => changes[file] !== null);
|
|
473
|
+
const result = { writes, deletes: Object.keys(changes).filter(file => changes[file] === null), creates: writes.filter(file => !fs.existsSync(local(root, file))), replaces: writes.filter(file => fs.existsSync(local(root, file))), installedVersion, targetVersion: version, compatibility: tools, recoveredTransaction: pending };
|
|
474
|
+
transaction(root, changes, dryRun);
|
|
475
|
+
return result;
|
|
476
|
+
}
|
|
477
|
+
catch (error) {
|
|
478
|
+
if (pending)
|
|
479
|
+
throw Error(`Recovered the preceding transaction; ${operation} did not complete: ${error instanceof Error ? error.message : String(error)}`);
|
|
480
|
+
throw error;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
export function init(root, dryRun, makeDefault) {
|
|
484
|
+
return lifecycle(root, 'init', dryRun, makeDefault).writes;
|
|
485
|
+
}
|
|
486
|
+
export function update(root, dryRun = false) {
|
|
487
|
+
const { writes, deletes } = lifecycle(root, 'update', dryRun);
|
|
488
|
+
return { writes, deletes };
|
|
455
489
|
}
|
|
456
490
|
export function markdowns(dir) {
|
|
457
491
|
if (!fs.existsSync(dir))
|
|
@@ -508,12 +542,16 @@ export function check(root, change, failPending = false) {
|
|
|
508
542
|
if (!fs.existsSync(mp))
|
|
509
543
|
add('not-installed', 'Run init');
|
|
510
544
|
else {
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
545
|
+
try {
|
|
546
|
+
const m = ownedManifest(root, 'update');
|
|
547
|
+
for (const [p, h] of Object.entries(m.files))
|
|
548
|
+
if (!fs.existsSync(local(root, p)) || hash(read(local(root, p))) !== h)
|
|
549
|
+
add('owned-file-modified', p);
|
|
550
|
+
}
|
|
551
|
+
catch (error) {
|
|
552
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
553
|
+
add(message.startsWith('Unsupported installed version') ? 'unsupported-installed-version' : 'invalid-installation-manifest', message);
|
|
554
|
+
}
|
|
517
555
|
}
|
|
518
556
|
try {
|
|
519
557
|
validateRegistry(root, c);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const version = "0.2.0";
|
|
2
|
+
export declare const requirements: {
|
|
3
|
+
readonly node: '20.19.0';
|
|
4
|
+
readonly openspec: '1.15.0';
|
|
5
|
+
};
|
|
6
|
+
export declare const supportedInstallations: string[];
|
|
7
|
+
export declare function stableVersion(value: string): number[] | undefined;
|
|
8
|
+
export declare function meetsMinimum(value: string, minimum: string): boolean;
|
|
9
|
+
export declare function supportsInstallation(value: unknown): value is string;
|
package/dist/release.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const version = '0.2.0';
|
|
2
|
+
export const requirements = { node: '20.19.0', openspec: '1.15.0' };
|
|
3
|
+
export const supportedInstallations = [...new Set(['0.1.0', version])];
|
|
4
|
+
export function stableVersion(value) {
|
|
5
|
+
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(value);
|
|
6
|
+
if (!match)
|
|
7
|
+
return;
|
|
8
|
+
const parts = match.slice(1, 4).map(Number);
|
|
9
|
+
if (parts.every(Number.isSafeInteger))
|
|
10
|
+
return parts;
|
|
11
|
+
}
|
|
12
|
+
export function meetsMinimum(value, minimum) {
|
|
13
|
+
const actual = stableVersion(value), floor = stableVersion(minimum);
|
|
14
|
+
if (!actual || !floor)
|
|
15
|
+
return false;
|
|
16
|
+
for (let i = 0; i < 3; i++)
|
|
17
|
+
if (actual[i] !== floor[i])
|
|
18
|
+
return actual[i] > floor[i];
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
export function supportsInstallation(value) {
|
|
22
|
+
return typeof value === 'string' && !!stableVersion(value) && supportedInstallations.includes(value) && meetsMinimum(version, value);
|
|
23
|
+
}
|
package/dist/schema-source.js
CHANGED
|
@@ -6,4 +6,4 @@ export function template(relative) {
|
|
|
6
6
|
export function instruction(relative) {
|
|
7
7
|
return template(relative).trim().split(/\n/).map(line => line.trim()).join(' ');
|
|
8
8
|
}
|
|
9
|
-
export const routing = ['routing', 'writing', 'humanizer', 'learnings', 'diagrams'].map(name => instruction(`base/instructions/${name}.md`)).join(' ');
|
|
9
|
+
export const routing = ['routing', 'writing', 'humanizer', 'learnings', 'diagrams', 'work-scoping'].map(name => instruction(`base/instructions/${name}.md`)).join(' ') + ' Read .cliewen-openspec/planning.md for optional planning guidance; features.planning controls its planning-specific requests.';
|