@ifc-lite/cli 0.17.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/layer-diff.d.ts +3 -0
- package/dist/commands/layer-diff.d.ts.map +1 -0
- package/dist/commands/layer-diff.js +46 -0
- package/dist/commands/layer-diff.js.map +1 -0
- package/dist/commands/layer-history.d.ts +61 -0
- package/dist/commands/layer-history.d.ts.map +1 -0
- package/dist/commands/layer-history.js +276 -0
- package/dist/commands/layer-history.js.map +1 -0
- package/dist/commands/layer-merge.d.ts +22 -0
- package/dist/commands/layer-merge.d.ts.map +1 -0
- package/dist/commands/layer-merge.js +138 -0
- package/dist/commands/layer-merge.js.map +1 -0
- package/dist/commands/layer-publish.d.ts +67 -0
- package/dist/commands/layer-publish.d.ts.map +1 -0
- package/dist/commands/layer-publish.js +299 -0
- package/dist/commands/layer-publish.js.map +1 -0
- package/dist/commands/layer-store.d.ts +59 -0
- package/dist/commands/layer-store.d.ts.map +1 -0
- package/dist/commands/layer-store.js +225 -0
- package/dist/commands/layer-store.js.map +1 -0
- package/dist/commands/layer-test-helpers.d.ts +10 -0
- package/dist/commands/layer-test-helpers.d.ts.map +1 -0
- package/dist/commands/layer-test-helpers.js +49 -0
- package/dist/commands/layer-test-helpers.js.map +1 -0
- package/dist/commands/layer.d.ts +2 -0
- package/dist/commands/layer.d.ts.map +1 -0
- package/dist/commands/layer.js +100 -0
- package/dist/commands/layer.js.map +1 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +4 -1
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/ref.d.ts +17 -0
- package/dist/commands/ref.d.ts.map +1 -0
- package/dist/commands/ref.js +173 -0
- package/dist/commands/ref.js.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/package.json +13 -11
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { AuthorKind, IfcxFile, ProvenanceCheck } from '@ifc-lite/ifcx';
|
|
2
|
+
import { type LayerStore } from './layer-store.js';
|
|
3
|
+
/** A derived op descriptor with the entity path kept for diagnostics. */
|
|
4
|
+
export interface DerivedScopeOp {
|
|
5
|
+
path: string;
|
|
6
|
+
capability: string;
|
|
7
|
+
ifcType?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Derive op descriptors from a delta's nodes against the base state:
|
|
11
|
+
* tombstones → `model.delete`, new entities → `model.create`, everything
|
|
12
|
+
* else `model.mutate:<target>` per attribute (target = Pset/Qto name when
|
|
13
|
+
* present in the key, else the last `::` segment).
|
|
14
|
+
*/
|
|
15
|
+
export declare function deriveScopeOps(delta: IfcxFile, baseLayers: readonly IfcxFile[]): DerivedScopeOp[];
|
|
16
|
+
export interface ScopeVerification {
|
|
17
|
+
verified: boolean;
|
|
18
|
+
violations: DerivedScopeOp[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Verify derived ops against declared claims. An empty claim list skips
|
|
22
|
+
* verification (claims are optional); parse errors throw.
|
|
23
|
+
*/
|
|
24
|
+
export declare function verifyScopeClaims(claims: readonly string[], ops: readonly DerivedScopeOp[]): ScopeVerification;
|
|
25
|
+
export interface PublishInit {
|
|
26
|
+
delta: IfcxFile;
|
|
27
|
+
/** Base ref name; null when published against nothing ('-'). */
|
|
28
|
+
baseRef: string | null;
|
|
29
|
+
intent: string;
|
|
30
|
+
scope?: string[];
|
|
31
|
+
principal?: string;
|
|
32
|
+
kind?: AuthorKind;
|
|
33
|
+
created?: string;
|
|
34
|
+
/** Abort (throw ScopeViolationError) instead of storing a flagged layer. */
|
|
35
|
+
strictScope?: boolean;
|
|
36
|
+
/** Verified check evidence to stamp into the manifest (see parseCheckEvidence). */
|
|
37
|
+
checks?: ProvenanceCheck[];
|
|
38
|
+
}
|
|
39
|
+
/** Thrown under `strictScope` before any side effect; CLI maps it to exit 4. */
|
|
40
|
+
export declare class ScopeViolationError extends Error {
|
|
41
|
+
readonly violations: DerivedScopeOp[];
|
|
42
|
+
constructor(violations: DerivedScopeOp[]);
|
|
43
|
+
}
|
|
44
|
+
export interface PublishResult {
|
|
45
|
+
layerId: string;
|
|
46
|
+
file: IfcxFile;
|
|
47
|
+
opCount: number;
|
|
48
|
+
scopeVerified: boolean;
|
|
49
|
+
violations: DerivedScopeOp[];
|
|
50
|
+
}
|
|
51
|
+
/** Build provenance, content-address, scope-verify and store a delta. */
|
|
52
|
+
export declare function publishLayer(store: LayerStore, init: PublishInit): PublishResult;
|
|
53
|
+
/**
|
|
54
|
+
* Parse `--check <spec.ids>=<report.json>` flags into manifest evidence.
|
|
55
|
+
*
|
|
56
|
+
* The report must be the JSON written by `ifc-lite ids <model> <rules.ids>
|
|
57
|
+
* --json`; pass/fail is derived from its summary — never asserted by the
|
|
58
|
+
* caller — and both files are content-addressed so a registry (or a merge
|
|
59
|
+
* reviewer) can verify the evidence byte-for-byte. In-process IDS
|
|
60
|
+
* execution over the composed IFCX state is L3 roadmap work; until then
|
|
61
|
+
* this is the one honest producer of `manifest.checks`.
|
|
62
|
+
*/
|
|
63
|
+
export declare function parseCheckEvidence(flags: readonly string[]): ProvenanceCheck[];
|
|
64
|
+
export declare function layerPublishCommand(args: string[]): Promise<void>;
|
|
65
|
+
export declare function layerCreateCommand(args: string[]): Promise<void>;
|
|
66
|
+
export declare function layerStatusCommand(args: string[]): Promise<void>;
|
|
67
|
+
//# sourceMappingURL=layer-publish.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-publish.d.ts","sourceRoot":"","sources":["../../src/commands/layer-publish.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAkB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAa5F,OAAO,EAWL,KAAK,UAAU,EAChB,MAAM,kBAAkB,CAAC;AAK1B,yEAAyE;AACzE,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,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WAAW,GAAG,aAAa,CA6BhF;AAMD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,eAAe,EAAE,CAkB9E;AAgCD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8DvE;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAiBtE;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBtE"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* `ifc-lite layer publish|create|status` — publish a delta document as a
|
|
6
|
+
* content-addressed layer, with publish-time scope verification
|
|
7
|
+
* (07-security.md §7.2), plus the draft descriptor workflow.
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync } from 'node:fs';
|
|
10
|
+
import { basename } from 'node:path';
|
|
11
|
+
import { ATTR, IFCLITE_ATTR, blake3Digest, computeLayerId, computeStackHash, createProvenanceManifest, setProvenance, } from '@ifc-lite/ifcx';
|
|
12
|
+
import { extractStackState } from '@ifc-lite/merge';
|
|
13
|
+
import { findCoveringClaim, parseScopeClaims } from '@ifc-lite/extensions';
|
|
14
|
+
import { getAllFlags, getFlag, hasFlag, printJson } from '../output.js';
|
|
15
|
+
import { deleteDraft, defaultPrincipal, loadRefLayers, readDraft, readIfcxFile, refStackHash, requireRef, storeFromArgs, storeLayer, writeDraft, } from './layer-store.js';
|
|
16
|
+
const PSET_QTO_RE = /(?:^|::)((?:Pset|Qto)_[A-Za-z0-9_]+)(?:::|$)/;
|
|
17
|
+
const AUTHOR_KINDS = ['human', 'agent', 'hybrid'];
|
|
18
|
+
function classCodeOf(value) {
|
|
19
|
+
if (typeof value === 'object' && value !== null) {
|
|
20
|
+
const code = value.code;
|
|
21
|
+
if (typeof code === 'string')
|
|
22
|
+
return code;
|
|
23
|
+
}
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
function ifcTypeFor(node, baseEntity) {
|
|
27
|
+
const baseClass = baseEntity?.components.get('attr:class');
|
|
28
|
+
return classCodeOf(baseClass?.[ATTR.CLASS]) ?? classCodeOf(node.attributes?.[ATTR.CLASS]);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Derive op descriptors from a delta's nodes against the base state:
|
|
32
|
+
* tombstones → `model.delete`, new entities → `model.create`, everything
|
|
33
|
+
* else `model.mutate:<target>` per attribute (target = Pset/Qto name when
|
|
34
|
+
* present in the key, else the last `::` segment).
|
|
35
|
+
*/
|
|
36
|
+
export function deriveScopeOps(delta, baseLayers) {
|
|
37
|
+
const baseState = extractStackState(baseLayers);
|
|
38
|
+
const ops = [];
|
|
39
|
+
for (const node of delta.data) {
|
|
40
|
+
const baseEntity = baseState.get(node.path);
|
|
41
|
+
const ifcType = ifcTypeFor(node, baseEntity);
|
|
42
|
+
const push = (capability) => {
|
|
43
|
+
const op = { path: node.path, capability };
|
|
44
|
+
if (ifcType !== undefined)
|
|
45
|
+
op.ifcType = ifcType;
|
|
46
|
+
ops.push(op);
|
|
47
|
+
};
|
|
48
|
+
if (node.attributes?.[IFCLITE_ATTR.DELETED] === true) {
|
|
49
|
+
push('model.delete');
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (baseEntity === undefined || baseEntity.deleted) {
|
|
53
|
+
push('model.create');
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
for (const key of Object.keys(node.attributes ?? {})) {
|
|
57
|
+
if (key === IFCLITE_ATTR.DELETED || key.startsWith(IFCLITE_ATTR.DERIVED))
|
|
58
|
+
continue;
|
|
59
|
+
const setMatch = PSET_QTO_RE.exec(key);
|
|
60
|
+
const target = setMatch ? setMatch[1] : key.split('::').pop() ?? key;
|
|
61
|
+
push(`model.mutate:${target}`);
|
|
62
|
+
}
|
|
63
|
+
// Structural edits are write capabilities too: a delta that only
|
|
64
|
+
// touches children/inherits must not bypass scope verification.
|
|
65
|
+
if (hierarchyChanged(node.children, baseEntity.children)) {
|
|
66
|
+
push('model.mutate:children');
|
|
67
|
+
}
|
|
68
|
+
if (hierarchyChanged(node.inherits, baseEntity.inherits)) {
|
|
69
|
+
push('model.mutate:inherits');
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return ops;
|
|
73
|
+
}
|
|
74
|
+
/** True when a children/inherits delta differs from the base slots. */
|
|
75
|
+
function hierarchyChanged(delta, base) {
|
|
76
|
+
if (!delta)
|
|
77
|
+
return false;
|
|
78
|
+
for (const [role, target] of Object.entries(delta)) {
|
|
79
|
+
if (target === null) {
|
|
80
|
+
if (base.has(role))
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
else if (base.get(role) !== target) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Verify derived ops against declared claims. An empty claim list skips
|
|
91
|
+
* verification (claims are optional); parse errors throw.
|
|
92
|
+
*/
|
|
93
|
+
export function verifyScopeClaims(claims, ops) {
|
|
94
|
+
if (claims.length === 0)
|
|
95
|
+
return { verified: true, violations: [] };
|
|
96
|
+
const parsed = parseScopeClaims(claims);
|
|
97
|
+
if (!parsed.ok) {
|
|
98
|
+
const detail = parsed.errors.map((e) => e.message).join('; ');
|
|
99
|
+
throw new Error(`Invalid scope claim(s): ${detail}`);
|
|
100
|
+
}
|
|
101
|
+
const violations = ops.filter((op) => findCoveringClaim(parsed.value, op) === undefined);
|
|
102
|
+
return { verified: violations.length === 0, violations };
|
|
103
|
+
}
|
|
104
|
+
/** Thrown under `strictScope` before any side effect; CLI maps it to exit 4. */
|
|
105
|
+
export class ScopeViolationError extends Error {
|
|
106
|
+
violations;
|
|
107
|
+
constructor(violations) {
|
|
108
|
+
super(`scope claim mismatch: ${violations.length} op(s) outside the declared claims`);
|
|
109
|
+
this.name = 'ScopeViolationError';
|
|
110
|
+
this.violations = violations;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Build provenance, content-address, scope-verify and store a delta. */
|
|
114
|
+
export function publishLayer(store, init) {
|
|
115
|
+
const baseLayers = init.baseRef === null ? [] : loadRefLayers(store, init.baseRef);
|
|
116
|
+
const base = init.baseRef === null
|
|
117
|
+
? null
|
|
118
|
+
: { kind: 'stack', id: computeStackHash(requireRef(store, init.baseRef).layers) };
|
|
119
|
+
const scope = init.scope ?? [];
|
|
120
|
+
const manifest = createProvenanceManifest({
|
|
121
|
+
author: { kind: init.kind ?? 'human', principal: init.principal ?? defaultPrincipal() },
|
|
122
|
+
intent: init.intent,
|
|
123
|
+
base,
|
|
124
|
+
created: init.created,
|
|
125
|
+
scope_claim: scope,
|
|
126
|
+
checks: init.checks ?? [],
|
|
127
|
+
});
|
|
128
|
+
// Verify before any side effect: a strict-scope failure must leave the
|
|
129
|
+
// store (and the draft) untouched and never print success output.
|
|
130
|
+
const ops = deriveScopeOps(init.delta, baseLayers);
|
|
131
|
+
const { verified, violations } = verifyScopeClaims(scope, ops);
|
|
132
|
+
if (!verified && init.strictScope) {
|
|
133
|
+
throw new ScopeViolationError(violations);
|
|
134
|
+
}
|
|
135
|
+
const withManifest = setProvenance(init.delta, manifest);
|
|
136
|
+
const layerId = computeLayerId(withManifest);
|
|
137
|
+
const file = { ...withManifest, header: { ...withManifest.header, id: layerId } };
|
|
138
|
+
storeLayer(store, file);
|
|
139
|
+
return { layerId, file, opCount: ops.length, scopeVerified: verified, violations };
|
|
140
|
+
}
|
|
141
|
+
// ---------------------------------------------------------------------------
|
|
142
|
+
// check evidence
|
|
143
|
+
// ---------------------------------------------------------------------------
|
|
144
|
+
/**
|
|
145
|
+
* Parse `--check <spec.ids>=<report.json>` flags into manifest evidence.
|
|
146
|
+
*
|
|
147
|
+
* The report must be the JSON written by `ifc-lite ids <model> <rules.ids>
|
|
148
|
+
* --json`; pass/fail is derived from its summary — never asserted by the
|
|
149
|
+
* caller — and both files are content-addressed so a registry (or a merge
|
|
150
|
+
* reviewer) can verify the evidence byte-for-byte. In-process IDS
|
|
151
|
+
* execution over the composed IFCX state is L3 roadmap work; until then
|
|
152
|
+
* this is the one honest producer of `manifest.checks`.
|
|
153
|
+
*/
|
|
154
|
+
export function parseCheckEvidence(flags) {
|
|
155
|
+
return flags.map((raw) => {
|
|
156
|
+
const eq = raw.indexOf('=');
|
|
157
|
+
if (eq <= 0 || eq === raw.length - 1) {
|
|
158
|
+
throw new Error(`--check expects <spec.ids>=<report.json>, got "${raw}"`);
|
|
159
|
+
}
|
|
160
|
+
const specPath = raw.slice(0, eq);
|
|
161
|
+
const reportPath = raw.slice(eq + 1);
|
|
162
|
+
const specContent = readFileSync(specPath, 'utf-8');
|
|
163
|
+
const reportContent = readFileSync(reportPath, 'utf-8');
|
|
164
|
+
return {
|
|
165
|
+
tool: '@ifc-lite/ids',
|
|
166
|
+
spec: basename(specPath),
|
|
167
|
+
specDigest: blake3Digest(specContent),
|
|
168
|
+
result: checkResultOf(reportContent, reportPath),
|
|
169
|
+
report: blake3Digest(reportContent),
|
|
170
|
+
};
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/** Derive pass/fail from an `ifc-lite ids --json` report's summary. */
|
|
174
|
+
function checkResultOf(reportContent, label) {
|
|
175
|
+
let parsed;
|
|
176
|
+
try {
|
|
177
|
+
parsed = JSON.parse(reportContent);
|
|
178
|
+
}
|
|
179
|
+
catch (err) {
|
|
180
|
+
throw new Error(`Check report ${label} is not valid JSON: ${err instanceof Error ? err.message : String(err)}`);
|
|
181
|
+
}
|
|
182
|
+
const summary = parsed.summary;
|
|
183
|
+
const failed = summary?.failedSpecifications;
|
|
184
|
+
if (typeof failed !== 'number') {
|
|
185
|
+
throw new Error(`Check report ${label} has no summary.failedSpecifications — expected the JSON written by \`ifc-lite ids <model> <rules.ids> --json\``);
|
|
186
|
+
}
|
|
187
|
+
return failed === 0 ? 'pass' : 'fail';
|
|
188
|
+
}
|
|
189
|
+
// ---------------------------------------------------------------------------
|
|
190
|
+
// commands
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
function parseKind(raw) {
|
|
193
|
+
if (raw === undefined)
|
|
194
|
+
return 'human';
|
|
195
|
+
if (AUTHOR_KINDS.includes(raw))
|
|
196
|
+
return raw;
|
|
197
|
+
throw new Error(`--kind must be one of ${AUTHOR_KINDS.join(' | ')}, got "${raw}"`);
|
|
198
|
+
}
|
|
199
|
+
export async function layerPublishCommand(args) {
|
|
200
|
+
const store = storeFromArgs(args);
|
|
201
|
+
const deltaPath = args[0];
|
|
202
|
+
if (!deltaPath || deltaPath.startsWith('-')) {
|
|
203
|
+
throw new Error('Usage: ifc-lite layer publish <delta.ifcx> --base <ref|-> --intent "<text>" [--scope <claim>]... [--check <spec.ids>=<report.json>]... [--principal <id>] [--kind human|agent|hybrid] [--strict-scope] [--json]');
|
|
204
|
+
}
|
|
205
|
+
const draft = readDraft(store);
|
|
206
|
+
const baseFlag = getFlag(args, '--base') ?? draft?.base;
|
|
207
|
+
if (baseFlag === undefined) {
|
|
208
|
+
throw new Error('Missing --base <ref|-> (no draft.json to default from)');
|
|
209
|
+
}
|
|
210
|
+
const intent = getFlag(args, '--intent') ?? draft?.intent;
|
|
211
|
+
if (intent === undefined) {
|
|
212
|
+
throw new Error('Missing --intent (no draft.json to default from)');
|
|
213
|
+
}
|
|
214
|
+
const scopeFlags = getAllFlags(args, '--scope');
|
|
215
|
+
const scope = scopeFlags.length > 0 ? scopeFlags : draft?.scope ?? [];
|
|
216
|
+
let result;
|
|
217
|
+
try {
|
|
218
|
+
result = publishLayer(store, {
|
|
219
|
+
delta: readIfcxFile(deltaPath),
|
|
220
|
+
baseRef: baseFlag === '-' ? null : baseFlag,
|
|
221
|
+
intent,
|
|
222
|
+
scope,
|
|
223
|
+
principal: getFlag(args, '--principal'),
|
|
224
|
+
kind: parseKind(getFlag(args, '--kind')),
|
|
225
|
+
strictScope: hasFlag(args, '--strict-scope'),
|
|
226
|
+
checks: parseCheckEvidence(getAllFlags(args, '--check')),
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch (error) {
|
|
230
|
+
if (error instanceof ScopeViolationError) {
|
|
231
|
+
// Nothing was stored and the draft is kept for retry.
|
|
232
|
+
process.stderr.write('Scope claim mismatch — ops outside the declared claims:\n');
|
|
233
|
+
for (const op of error.violations) {
|
|
234
|
+
const type = op.ifcType ? ` (${op.ifcType})` : '';
|
|
235
|
+
process.stderr.write(` ${op.path}: ${op.capability}${type}\n`);
|
|
236
|
+
}
|
|
237
|
+
process.exit(4);
|
|
238
|
+
}
|
|
239
|
+
throw error;
|
|
240
|
+
}
|
|
241
|
+
if (!result.scopeVerified) {
|
|
242
|
+
process.stderr.write('Warning: scope claim mismatch — ops outside the declared claims:\n');
|
|
243
|
+
for (const op of result.violations) {
|
|
244
|
+
const type = op.ifcType ? ` (${op.ifcType})` : '';
|
|
245
|
+
process.stderr.write(` ${op.path}: ${op.capability}${type}\n`);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (draft)
|
|
249
|
+
deleteDraft(store);
|
|
250
|
+
if (hasFlag(args, '--json')) {
|
|
251
|
+
printJson({ id: result.layerId, opCount: result.opCount, scope_verified: result.scopeVerified });
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
process.stdout.write(`${result.layerId}\n`);
|
|
255
|
+
process.stderr.write(`Published ${result.opCount} op(s) to ${store.dir}\n`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
export async function layerCreateCommand(args) {
|
|
259
|
+
const store = storeFromArgs(args);
|
|
260
|
+
const baseRef = getFlag(args, '--base');
|
|
261
|
+
const intent = getFlag(args, '--intent');
|
|
262
|
+
if (!baseRef || !intent) {
|
|
263
|
+
throw new Error('Usage: ifc-lite layer create --base <ref> --intent "<text>" [--scope <claim>]...');
|
|
264
|
+
}
|
|
265
|
+
const draft = {
|
|
266
|
+
base: baseRef,
|
|
267
|
+
baseStackHash: baseRef === '-' ? computeStackHash([]) : refStackHash(store, baseRef),
|
|
268
|
+
intent,
|
|
269
|
+
scope: getAllFlags(args, '--scope'),
|
|
270
|
+
created: new Date().toISOString(),
|
|
271
|
+
};
|
|
272
|
+
writeDraft(store, draft);
|
|
273
|
+
if (hasFlag(args, '--json'))
|
|
274
|
+
printJson(draft);
|
|
275
|
+
else
|
|
276
|
+
process.stderr.write(`Draft recorded at ${store.dir}/draft.json (base ${baseRef})\n`);
|
|
277
|
+
}
|
|
278
|
+
export async function layerStatusCommand(args) {
|
|
279
|
+
const store = storeFromArgs(args);
|
|
280
|
+
const draft = readDraft(store);
|
|
281
|
+
if (!draft) {
|
|
282
|
+
process.stderr.write(`No draft in ${store.dir} — run 'ifc-lite layer create' first.\n`);
|
|
283
|
+
process.exit(1);
|
|
284
|
+
}
|
|
285
|
+
const currentHash = draft.base === '-' ? computeStackHash([]) : refStackHash(store, draft.base);
|
|
286
|
+
const baseMoved = currentHash !== draft.baseStackHash;
|
|
287
|
+
if (hasFlag(args, '--json')) {
|
|
288
|
+
printJson({ ...draft, baseMoved, currentBaseStackHash: currentHash });
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
process.stdout.write(`base: ${draft.base}\n`);
|
|
292
|
+
process.stdout.write(`intent: ${draft.intent}\n`);
|
|
293
|
+
process.stdout.write(`scope: ${draft.scope.length > 0 ? draft.scope.join(', ') : '(none)'}\n`);
|
|
294
|
+
process.stdout.write(`created: ${draft.created}\n`);
|
|
295
|
+
process.stdout.write(baseMoved
|
|
296
|
+
? `base ref has MOVED since the draft was created (${draft.baseStackHash} → ${currentHash})\n`
|
|
297
|
+
: 'base ref has not moved\n');
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=layer-publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-publish.js","sourceRoot":"","sources":["../../src/commands/layer-publish.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;GAIG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EACL,IAAI,EACJ,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAoB,MAAM,iBAAiB,CAAC;AACtE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,UAAU,EACV,UAAU,GAEX,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,GAAG,8CAA8C,CAAC;AACnE,MAAM,YAAY,GAA0B,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AASzE,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;QAChD,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;IAC5C,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,UAAU,CAAC,IAA8B,EAAE,UAAmC;IACrF,MAAM,SAAS,GAAG,UAAU,EAAE,UAAU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CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { IfcxFile } from '@ifc-lite/ifcx';
|
|
2
|
+
import type { RefEntry } from '@ifc-lite/merge';
|
|
3
|
+
export type { RefEntry, RefPolicy } from '@ifc-lite/merge';
|
|
4
|
+
export interface RefsFile {
|
|
5
|
+
refs: Record<string, RefEntry>;
|
|
6
|
+
}
|
|
7
|
+
/** Draft descriptor recorded by `ifc-lite layer create`. */
|
|
8
|
+
export interface DraftDescriptor {
|
|
9
|
+
/** Base ref name ('-' for none). */
|
|
10
|
+
base: string;
|
|
11
|
+
/** Stack hash of the base ref at draft-creation time. */
|
|
12
|
+
baseStackHash: string;
|
|
13
|
+
intent: string;
|
|
14
|
+
scope: string[];
|
|
15
|
+
created: string;
|
|
16
|
+
}
|
|
17
|
+
export interface LayerStore {
|
|
18
|
+
dir: string;
|
|
19
|
+
}
|
|
20
|
+
/** Open (without creating) a store rooted at `dir` or `<cwd>/.ifc-lite`. */
|
|
21
|
+
export declare function openStore(dir?: string): LayerStore;
|
|
22
|
+
/** Store from CLI args: honours the `--store <dir>` override. */
|
|
23
|
+
export declare function storeFromArgs(args: string[]): LayerStore;
|
|
24
|
+
export declare function readRefs(store: LayerStore): RefsFile;
|
|
25
|
+
export declare function writeRefs(store: LayerStore, refs: RefsFile): void;
|
|
26
|
+
export declare function getRef(store: LayerStore, name: string): RefEntry | undefined;
|
|
27
|
+
export declare function requireRef(store: LayerStore, name: string): RefEntry;
|
|
28
|
+
export declare function setRef(store: LayerStore, name: string, entry: RefEntry): void;
|
|
29
|
+
/** Stack hash of a ref's current layer list. */
|
|
30
|
+
export declare function refStackHash(store: LayerStore, name: string): string;
|
|
31
|
+
/** Persist a published layer; `file.header.id` must be its blake3 id. */
|
|
32
|
+
export declare function storeLayer(store: LayerStore, file: IfcxFile): string;
|
|
33
|
+
export declare function hasLayer(store: LayerStore, layerId: string): boolean;
|
|
34
|
+
/** Resolve a full id, bare hex, or unique hex prefix to a full layer id. */
|
|
35
|
+
export declare function resolveLayerId(store: LayerStore, idOrPrefix: string): string;
|
|
36
|
+
export declare function loadLayer(store: LayerStore, layerId: string): IfcxFile;
|
|
37
|
+
/** Load a ref's layer documents, ordered weakest first. */
|
|
38
|
+
export declare function loadRefLayers(store: LayerStore, name: string): IfcxFile[];
|
|
39
|
+
export declare function readDraft(store: LayerStore): DraftDescriptor | undefined;
|
|
40
|
+
export declare function writeDraft(store: LayerStore, draft: DraftDescriptor): void;
|
|
41
|
+
export declare function deleteDraft(store: LayerStore): void;
|
|
42
|
+
export declare function parseIfcxJson(text: string, label: string): IfcxFile;
|
|
43
|
+
export declare function readIfcxFile(path: string): IfcxFile;
|
|
44
|
+
export interface ResolvedSide {
|
|
45
|
+
kind: 'ref' | 'layer' | 'file';
|
|
46
|
+
/** Ordered layer documents (a ref's stack, or a single document). */
|
|
47
|
+
layers: IfcxFile[];
|
|
48
|
+
label: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Resolve a `<layer-id|ref|file.ifcx>` argument to an ordered layer list:
|
|
52
|
+
* refs win over layer ids, layer ids over file paths.
|
|
53
|
+
*/
|
|
54
|
+
export declare function resolveSide(store: LayerStore, spec: string): ResolvedSide;
|
|
55
|
+
/** Short display form of a `blake3:<hex>` id. */
|
|
56
|
+
export declare function shortId(layerId: string): string;
|
|
57
|
+
/** Default principal for provenance authorship. */
|
|
58
|
+
export declare function defaultPrincipal(): string;
|
|
59
|
+
//# sourceMappingURL=layer-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layer-store.d.ts","sourceRoot":"","sources":["../../src/commands/layer-store.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAiBhD,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,C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