arkaik 0.11.0 → 0.12.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/assets/skill/scripts/validate-bundle.js +4 -4
- package/dist/index.js +788 -101
- package/dist/io.js +576 -8
- package/package.json +1 -1
- package/src/io.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -3055,13 +3055,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
3055
3055
|
}
|
|
3056
3056
|
return propValues;
|
|
3057
3057
|
});
|
|
3058
|
-
const
|
|
3058
|
+
const isObject4 = isObject;
|
|
3059
3059
|
const catchall = def.catchall;
|
|
3060
3060
|
let value;
|
|
3061
3061
|
inst._zod.parse = (payload, ctx) => {
|
|
3062
3062
|
value ?? (value = _normalized.value);
|
|
3063
3063
|
const input = payload.value;
|
|
3064
|
-
if (!
|
|
3064
|
+
if (!isObject4(input)) {
|
|
3065
3065
|
payload.issues.push({
|
|
3066
3066
|
expected: "object",
|
|
3067
3067
|
code: "invalid_type",
|
|
@@ -3188,7 +3188,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3188
3188
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
3189
3189
|
};
|
|
3190
3190
|
let fastpass;
|
|
3191
|
-
const
|
|
3191
|
+
const isObject4 = isObject;
|
|
3192
3192
|
const jit = !globalConfig.jitless;
|
|
3193
3193
|
const allowsEval2 = allowsEval;
|
|
3194
3194
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -3197,7 +3197,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
|
|
|
3197
3197
|
inst._zod.parse = (payload, ctx) => {
|
|
3198
3198
|
value ?? (value = _normalized.value);
|
|
3199
3199
|
const input = payload.value;
|
|
3200
|
-
if (!
|
|
3200
|
+
if (!isObject4(input)) {
|
|
3201
3201
|
payload.issues.push({
|
|
3202
3202
|
expected: "object",
|
|
3203
3203
|
code: "invalid_type",
|
|
@@ -14621,6 +14621,38 @@ var VALUE_IDS = [
|
|
|
14621
14621
|
// social-impact (1)
|
|
14622
14622
|
"self-transcendence"
|
|
14623
14623
|
];
|
|
14624
|
+
var VALUE_TIERS = {
|
|
14625
|
+
"saves-time": "functional",
|
|
14626
|
+
simplifies: "functional",
|
|
14627
|
+
"makes-money": "functional",
|
|
14628
|
+
"reduces-risk": "functional",
|
|
14629
|
+
organizes: "functional",
|
|
14630
|
+
integrates: "functional",
|
|
14631
|
+
connects: "functional",
|
|
14632
|
+
"reduces-effort": "functional",
|
|
14633
|
+
"avoids-hassles": "functional",
|
|
14634
|
+
"reduces-cost": "functional",
|
|
14635
|
+
quality: "functional",
|
|
14636
|
+
variety: "functional",
|
|
14637
|
+
"sensory-appeal": "functional",
|
|
14638
|
+
informs: "functional",
|
|
14639
|
+
"reduces-anxiety": "emotional",
|
|
14640
|
+
"rewards-me": "emotional",
|
|
14641
|
+
nostalgia: "emotional",
|
|
14642
|
+
"design-aesthetics": "emotional",
|
|
14643
|
+
"badge-value": "emotional",
|
|
14644
|
+
wellness: "emotional",
|
|
14645
|
+
"therapeutic-value": "emotional",
|
|
14646
|
+
"fun-entertainment": "emotional",
|
|
14647
|
+
attractiveness: "emotional",
|
|
14648
|
+
"provides-access": "emotional",
|
|
14649
|
+
"provides-hope": "life-changing",
|
|
14650
|
+
"self-actualization": "life-changing",
|
|
14651
|
+
motivation: "life-changing",
|
|
14652
|
+
heirloom: "life-changing",
|
|
14653
|
+
"affiliation-belonging": "life-changing",
|
|
14654
|
+
"self-transcendence": "social-impact"
|
|
14655
|
+
};
|
|
14624
14656
|
|
|
14625
14657
|
// ../schema/src/legacy-status.ts
|
|
14626
14658
|
var LEGACY_STATUS_IDS = ["prioritized", "blocked"];
|
|
@@ -15207,6 +15239,82 @@ function missingProvenanceNodeIds(snapshotNodeIds, events) {
|
|
|
15207
15239
|
return missing;
|
|
15208
15240
|
}
|
|
15209
15241
|
|
|
15242
|
+
// ../schema/src/weighing-schemas.ts
|
|
15243
|
+
var documented = (schema) => external_exports.union([schema, external_exports.unknown()]);
|
|
15244
|
+
var leaf = (description) => external_exports.unknown().optional().meta({ description });
|
|
15245
|
+
var WeighingConfidenceSchema = external_exports.unknown().meta({ description: "0 guess \xB7 1 inferred \xB7 2 evidenced \xB7 3 verified." });
|
|
15246
|
+
var WeighingScorerSchema = external_exports.object({
|
|
15247
|
+
kind: leaf("Who judged: human, agent or rule. A human's level beats an agent's, which beats a rule's. Any value parses; the validator warns on another kind."),
|
|
15248
|
+
id: leaf("A person's handle, an agent's name, or a seeding rule's id."),
|
|
15249
|
+
model: leaf("The model behind an agent, when it says."),
|
|
15250
|
+
on_behalf_of: leaf("Whom the scorer acts for: a user id, a handle or a display name, never an email. Stamped by the writer where identity is known.")
|
|
15251
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingScorer", description: "Provenance of one assessment." });
|
|
15252
|
+
var WeighingScaleSchema = external_exports.object({
|
|
15253
|
+
min: leaf("The lowest level, e.g. -3."),
|
|
15254
|
+
max: leaf("The highest level, e.g. 3."),
|
|
15255
|
+
anchors: leaf("Every level described in words, keyed by the level as a string.")
|
|
15256
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingScale", description: "A criteria set's scale: its bounds and every level's anchor." });
|
|
15257
|
+
var WeighingGroupSchema = external_exports.object({ id: leaf("The group's id."), title: leaf("The group's title.") }).catchall(external_exports.unknown()).meta({ id: "WeighingGroup", description: "A grouping of criteria \u2014 the tiers, for the value set." });
|
|
15258
|
+
var WeighingCriterionSchema = external_exports.object({
|
|
15259
|
+
id: leaf("Stable identifier. Never redefined \u2014 retired via superseded_by."),
|
|
15260
|
+
group: leaf("A group id \u2014 for the value set, the tier."),
|
|
15261
|
+
name: leaf("A short name."),
|
|
15262
|
+
question: leaf("The question a scorer answers."),
|
|
15263
|
+
definition: leaf("What the criterion means."),
|
|
15264
|
+
anchors: leaf("This criterion's own wording of each level \u2014 on a positioning, in the product's words."),
|
|
15265
|
+
weight: leaf("On a positioning: how much the product stands on it, a number above 0. Absent means 1."),
|
|
15266
|
+
superseded_by: leaf("The id of the criterion that replaces this one.")
|
|
15267
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingCriterion", description: "One question on a scale where every level is described." });
|
|
15268
|
+
var WeighingCriteriaSetSchema = external_exports.object({
|
|
15269
|
+
id: leaf("The set's id."),
|
|
15270
|
+
version: leaf("Semver. Levels are comparable only within a major."),
|
|
15271
|
+
title: leaf("A human title."),
|
|
15272
|
+
subject: leaf("What the set judges: acceptance today."),
|
|
15273
|
+
scale: documented(WeighingScaleSchema).optional().meta({ description: "The scale. A positioning may leave it out and use its ruler's." }),
|
|
15274
|
+
groups: documented(external_exports.array(documented(WeighingGroupSchema))).optional(),
|
|
15275
|
+
criteria: documented(external_exports.array(documented(WeighingCriterionSchema))).optional(),
|
|
15276
|
+
role: leaf("positioning marks the set a project writes about itself."),
|
|
15277
|
+
status: leaf("Absent or active is active; anything else is a draft, which feeds no roll-up."),
|
|
15278
|
+
extends: leaf("A positioning's ruler, e.g. value-contribution@1.")
|
|
15279
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingCriteriaSet", description: "A versioned list of criteria for one kind of subject. The 30 elements of value are one; a positioning is another." });
|
|
15280
|
+
var WeighingMatrixSchema = external_exports.object({
|
|
15281
|
+
id: leaf("The matrix's id."),
|
|
15282
|
+
title: leaf("A human title."),
|
|
15283
|
+
set: leaf("The set's id and major, e.g. value-contribution@1."),
|
|
15284
|
+
subjects: documented(
|
|
15285
|
+
external_exports.object({ kind: leaf("query or list."), species: leaf("For a query: the species judged."), items: leaf("For a list: the subjects.") }).catchall(external_exports.unknown())
|
|
15286
|
+
).optional().meta({ description: "What the matrix judges: { kind: query, species } or { kind: list, items }." }),
|
|
15287
|
+
positioning: leaf("The id of the positioning set that re-weights this matrix."),
|
|
15288
|
+
context: leaf("The node the matrix is about, as { node_id }."),
|
|
15289
|
+
status: leaf("Absent or active is active; anything else is a draft.")
|
|
15290
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingMatrix", description: "A criteria set applied to a list of subjects." });
|
|
15291
|
+
var WeighingAssessmentBasisSchema = external_exports.object({
|
|
15292
|
+
fingerprint: leaf("A hash of the subject's judged fields."),
|
|
15293
|
+
commit: leaf("The commit the scorer was looking at."),
|
|
15294
|
+
set_version: leaf("The full version of the set the level was read against.")
|
|
15295
|
+
}).catchall(external_exports.unknown());
|
|
15296
|
+
var WeighingAssessmentSchema = external_exports.object({
|
|
15297
|
+
matrix: leaf("The matrix's id. A row without it cannot be addressed: readers skip it and the validator warns."),
|
|
15298
|
+
subject: leaf("A node id for the value matrix."),
|
|
15299
|
+
criterion: leaf("A criterion id."),
|
|
15300
|
+
level: leaf("A whole number on the set's scale. 0 means unrelated. No half points \u2014 but any value parses; the validator warns on one off the scale."),
|
|
15301
|
+
scorer: documented(WeighingScorerSchema).optional().meta({ description: "Who judged. Required in practice: without it a human, an agent and a rule are indistinguishable, so the validator warns." }),
|
|
15302
|
+
confidence: leaf("0 guess \xB7 1 inferred \xB7 2 evidenced \xB7 3 verified."),
|
|
15303
|
+
evidence: leaf("Markdown."),
|
|
15304
|
+
refs: leaf("Ids cited: nodes, journal events, findings."),
|
|
15305
|
+
basis: documented(WeighingAssessmentBasisSchema).optional().meta({ description: "What the scorer was looking at, so a re-read can tell the score went stale." }),
|
|
15306
|
+
run: leaf("The audit or plan the score belongs to."),
|
|
15307
|
+
ts: leaf("ISO 8601.")
|
|
15308
|
+
}).catchall(external_exports.unknown()).meta({ id: "WeighingAssessment", description: "One (matrix \xD7 subject \xD7 criterion) judgement \u2014 latest per scorer kind wins; history lives in the journal." });
|
|
15309
|
+
var WeighingSectionSchema = external_exports.object({
|
|
15310
|
+
sets: external_exports.array(documented(WeighingCriteriaSetSchema)).optional(),
|
|
15311
|
+
matrices: external_exports.array(documented(WeighingMatrixSchema)).optional(),
|
|
15312
|
+
assessments: external_exports.array(documented(WeighingAssessmentSchema)).optional()
|
|
15313
|
+
}).catchall(external_exports.unknown()).meta({
|
|
15314
|
+
id: "WeighingSection",
|
|
15315
|
+
description: "The project's weighing state (docs/rfcs/weighing.md) \u2014 its own criteria sets (a positioning), matrices and assessments. The built-in value set is library content, not stored; served, cost and kept share are derived, never stored. Each list may be absent; a reader treats it as empty."
|
|
15316
|
+
});
|
|
15317
|
+
|
|
15210
15318
|
// ../schema/src/journal-events.ts
|
|
15211
15319
|
var envelope = {
|
|
15212
15320
|
id: external_exports.string().meta({ description: "ULID \u2014 sortable, collision-free without coordination." }),
|
|
@@ -15397,6 +15505,21 @@ var QualitySignalTrippedEventSchema = external_exports.object({
|
|
|
15397
15505
|
commit: external_exports.string().optional(),
|
|
15398
15506
|
detail: external_exports.string().optional()
|
|
15399
15507
|
}).catchall(external_exports.unknown());
|
|
15508
|
+
var WeighingAssessmentRecordedEventSchema = external_exports.object({
|
|
15509
|
+
...envelope,
|
|
15510
|
+
type: external_exports.literal("weighing.assessment.recorded"),
|
|
15511
|
+
matrix: external_exports.string(),
|
|
15512
|
+
subject: external_exports.string(),
|
|
15513
|
+
criterion: external_exports.string(),
|
|
15514
|
+
level: external_exports.number().int(),
|
|
15515
|
+
scorer: WeighingScorerSchema,
|
|
15516
|
+
confidence: WeighingConfidenceSchema,
|
|
15517
|
+
evidence: external_exports.string().optional(),
|
|
15518
|
+
refs: external_exports.array(external_exports.string()).optional(),
|
|
15519
|
+
basis: WeighingAssessmentBasisSchema.optional(),
|
|
15520
|
+
run: external_exports.string().optional()
|
|
15521
|
+
}).catchall(external_exports.unknown());
|
|
15522
|
+
var WeighingSetSavedEventSchema = external_exports.object({ ...envelope, type: external_exports.literal("weighing.set.saved"), set: WeighingCriteriaSetSchema }).catchall(external_exports.unknown());
|
|
15400
15523
|
var JOURNAL_EVENT_SCHEMAS = {
|
|
15401
15524
|
"node.created": NodeCreatedEventSchema,
|
|
15402
15525
|
"node.updated": NodeUpdatedEventSchema,
|
|
@@ -15420,7 +15543,9 @@ var JOURNAL_EVENT_SCHEMAS = {
|
|
|
15420
15543
|
"quality.finding.opened": QualityFindingOpenedEventSchema,
|
|
15421
15544
|
"quality.finding.resolved": QualityFindingResolvedEventSchema,
|
|
15422
15545
|
"quality.finding.accepted": QualityFindingAcceptedEventSchema,
|
|
15423
|
-
"quality.signal.tripped": QualitySignalTrippedEventSchema
|
|
15546
|
+
"quality.signal.tripped": QualitySignalTrippedEventSchema,
|
|
15547
|
+
"weighing.assessment.recorded": WeighingAssessmentRecordedEventSchema,
|
|
15548
|
+
"weighing.set.saved": WeighingSetSavedEventSchema
|
|
15424
15549
|
};
|
|
15425
15550
|
var KnownJournalEventSchema = external_exports.union([
|
|
15426
15551
|
NodeCreatedEventSchema,
|
|
@@ -15445,7 +15570,9 @@ var KnownJournalEventSchema = external_exports.union([
|
|
|
15445
15570
|
QualityFindingOpenedEventSchema,
|
|
15446
15571
|
QualityFindingResolvedEventSchema,
|
|
15447
15572
|
QualityFindingAcceptedEventSchema,
|
|
15448
|
-
QualitySignalTrippedEventSchema
|
|
15573
|
+
QualitySignalTrippedEventSchema,
|
|
15574
|
+
WeighingAssessmentRecordedEventSchema,
|
|
15575
|
+
WeighingSetSavedEventSchema
|
|
15449
15576
|
]);
|
|
15450
15577
|
|
|
15451
15578
|
// ../schema/src/quality.ts
|
|
@@ -16669,6 +16796,9 @@ var ProjectBundleSchema = external_exports.object({
|
|
|
16669
16796
|
}),
|
|
16670
16797
|
quality: QualitySectionSchema.optional().meta({
|
|
16671
16798
|
description: "Optional Kritik quality state (docs/rfcs/kritik.md \xA7 4.1) \u2014 the pinned pack version, the project's surface profile, its assessments and findings. Additive: a bundle without it is not an error, and the comparative matrix is derived from it (deriveQualityMatrix), never stored."
|
|
16799
|
+
}),
|
|
16800
|
+
weighing: WeighingSectionSchema.optional().meta({
|
|
16801
|
+
description: "Optional weighing state (docs/rfcs/weighing.md) \u2014 the project's own criteria sets (a positioning), matrices and assessments, each assessment carrying its scorer, confidence and basis. Additive: a bundle without it is not an error, and every weight, served and cost figure is derived from it, never stored."
|
|
16672
16802
|
})
|
|
16673
16803
|
}).catchall(external_exports.unknown()).meta({
|
|
16674
16804
|
id: "ProjectBundle",
|
|
@@ -16702,6 +16832,375 @@ function isBuiltInMapId(id) {
|
|
|
16702
16832
|
return BUILT_IN_MAP_IDS.includes(id);
|
|
16703
16833
|
}
|
|
16704
16834
|
|
|
16835
|
+
// ../schema/src/weighing.ts
|
|
16836
|
+
var SCORER_KINDS = ["human", "agent", "rule"];
|
|
16837
|
+
var STORED_SCORER_KINDS = ["human", "agent"];
|
|
16838
|
+
function scorerRank(kind) {
|
|
16839
|
+
const index = SCORER_KINDS.indexOf(kind);
|
|
16840
|
+
return index === -1 ? 0 : SCORER_KINDS.length - index;
|
|
16841
|
+
}
|
|
16842
|
+
var WEIGHING_ASSESSMENT_RECORDED = "weighing.assessment.recorded";
|
|
16843
|
+
var WEIGHING_SET_SAVED = "weighing.set.saved";
|
|
16844
|
+
function cellKey(matrix, subject, criterion) {
|
|
16845
|
+
return `${matrix}\0${subject}\0${criterion}`;
|
|
16846
|
+
}
|
|
16847
|
+
function assessmentKey(a) {
|
|
16848
|
+
const kind = typeof a?.scorer?.kind === "string" ? a.scorer.kind : "";
|
|
16849
|
+
return `${cellKey(String(a?.matrix), String(a?.subject), String(a?.criterion))}\0${kind}`;
|
|
16850
|
+
}
|
|
16851
|
+
var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16852
|
+
function isWeighingAssessmentShape(row) {
|
|
16853
|
+
return isRecord3(row) && typeof row.matrix === "string" && typeof row.subject === "string" && typeof row.criterion === "string";
|
|
16854
|
+
}
|
|
16855
|
+
function splitSetRef(ref) {
|
|
16856
|
+
const at2 = ref.lastIndexOf("@");
|
|
16857
|
+
if (at2 === -1) return { id: ref, major: void 0 };
|
|
16858
|
+
return { id: ref.slice(0, at2), major: ref.slice(at2 + 1) };
|
|
16859
|
+
}
|
|
16860
|
+
function majorOf(version2) {
|
|
16861
|
+
const match = /^(\d+)(?:\.|$)/.exec(version2);
|
|
16862
|
+
return match ? match[1] : void 0;
|
|
16863
|
+
}
|
|
16864
|
+
function sortWeighingAssessments(assessments) {
|
|
16865
|
+
return [...assessments].sort((a, b) => {
|
|
16866
|
+
const text = (x) => typeof x === "string" ? x : "\uFFFF";
|
|
16867
|
+
const by = (x, y) => text(x) < text(y) ? -1 : text(x) > text(y) ? 1 : 0;
|
|
16868
|
+
return by(a?.matrix, b?.matrix) || by(a?.subject, b?.subject) || by(a?.criterion, b?.criterion) || scorerRank(b?.scorer?.kind) - scorerRank(a?.scorer?.kind);
|
|
16869
|
+
});
|
|
16870
|
+
}
|
|
16871
|
+
|
|
16872
|
+
// ../schema/src/weighing-library.ts
|
|
16873
|
+
function deepFreeze(value) {
|
|
16874
|
+
if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
|
|
16875
|
+
Object.freeze(value);
|
|
16876
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
16877
|
+
}
|
|
16878
|
+
return value;
|
|
16879
|
+
}
|
|
16880
|
+
var VALUE_SET_ID = "value-contribution";
|
|
16881
|
+
var VALUE_SET_VERSION = "1.0.0";
|
|
16882
|
+
var VALUE_MATRIX_ID = "value";
|
|
16883
|
+
var POSITIONING_SET_ID = "positioning";
|
|
16884
|
+
var VALUE_SCALE_ANCHORS = {
|
|
16885
|
+
"3": "Core. The promise exists for this; take it away and the value goes.",
|
|
16886
|
+
"2": "Supports clearly. The user would notice it missing.",
|
|
16887
|
+
"1": "Touches. A side effect of the promise, not its purpose.",
|
|
16888
|
+
"0": "Unrelated: weighed and found to have nothing to do with it. (No row means nobody has weighed it yet.)",
|
|
16889
|
+
"-1": "Small friction. It costs this value a little.",
|
|
16890
|
+
"-2": "Works against it. The user notices the cost.",
|
|
16891
|
+
"-3": "Costs it at its core. The user feels the opposite."
|
|
16892
|
+
};
|
|
16893
|
+
var TIER_TITLES = {
|
|
16894
|
+
functional: "Functional",
|
|
16895
|
+
emotional: "Emotional",
|
|
16896
|
+
"life-changing": "Life-changing",
|
|
16897
|
+
"social-impact": "Social impact"
|
|
16898
|
+
};
|
|
16899
|
+
var VALUE_TEXT = {
|
|
16900
|
+
"saves-time": { name: "Saves time", definition: "Completes the user's task in less time." },
|
|
16901
|
+
simplifies: { name: "Simplifies", definition: "Reduces steps, choices, or cognitive load." },
|
|
16902
|
+
"makes-money": { name: "Makes money", definition: "Helps the user earn." },
|
|
16903
|
+
"reduces-risk": { name: "Reduces risk", definition: "Protects against loss, error, or uncertainty." },
|
|
16904
|
+
organizes: { name: "Organizes", definition: "Brings order to the user's things or life." },
|
|
16905
|
+
integrates: { name: "Integrates", definition: "Ties different tools or parts of life together." },
|
|
16906
|
+
connects: { name: "Connects", definition: "Brings the user together with other people." },
|
|
16907
|
+
"reduces-effort": { name: "Reduces effort", definition: "Same outcome, less work." },
|
|
16908
|
+
"avoids-hassles": { name: "Avoids hassles", definition: "Prevents friction and annoyance before it happens." },
|
|
16909
|
+
"reduces-cost": { name: "Reduces cost", definition: "Saves the user money." },
|
|
16910
|
+
quality: { name: "Quality", definition: "Superior craft or performance the user can feel." },
|
|
16911
|
+
variety: { name: "Variety", definition: "Meaningful choice and breadth." },
|
|
16912
|
+
"sensory-appeal": { name: "Sensory appeal", definition: "Looks, sounds, or feels good in the moment." },
|
|
16913
|
+
informs: { name: "Informs", definition: "Tells the user something they want to know." },
|
|
16914
|
+
"reduces-anxiety": { name: "Reduces anxiety", definition: "Calms; makes the user feel safe." },
|
|
16915
|
+
"rewards-me": { name: "Rewards me", definition: "Tangible perks for engagement." },
|
|
16916
|
+
nostalgia: { name: "Nostalgia", definition: "Positive memory of the past." },
|
|
16917
|
+
"design-aesthetics": { name: "Design / aesthetics", definition: "Beauty as an experienced value, beyond function." },
|
|
16918
|
+
"badge-value": { name: "Badge value", definition: "Signals identity or status to others." },
|
|
16919
|
+
wellness: { name: "Wellness", definition: "Improves physical or mental well-being." },
|
|
16920
|
+
"therapeutic-value": { name: "Therapeutic value", definition: "Actively supports emotional processing or healing." },
|
|
16921
|
+
"fun-entertainment": { name: "Fun / entertainment", definition: "Enjoyable, playful, delightful." },
|
|
16922
|
+
attractiveness: { name: "Attractiveness", definition: "Makes the user feel attractive." },
|
|
16923
|
+
"provides-access": { name: "Provides access", definition: "Grants entry to something otherwise out of reach." },
|
|
16924
|
+
"provides-hope": { name: "Provides hope", definition: "Reason to believe things can improve." },
|
|
16925
|
+
"self-actualization": { name: "Self-actualization", definition: "Helps the user become who they want to be." },
|
|
16926
|
+
motivation: { name: "Motivation", definition: "Energizes the user toward their goals." },
|
|
16927
|
+
heirloom: { name: "Heirloom", definition: "Something worth passing on across time." },
|
|
16928
|
+
"affiliation-belonging": { name: "Affiliation & belonging", definition: "Makes the user part of a group that matters." },
|
|
16929
|
+
"self-transcendence": { name: "Self-transcendence", definition: "Helps beyond the user themselves." }
|
|
16930
|
+
};
|
|
16931
|
+
var VALUE_SCALE = { min: -3, max: 3, anchors: { ...VALUE_SCALE_ANCHORS } };
|
|
16932
|
+
var VALUE_CONTRIBUTION_SET = deepFreeze({
|
|
16933
|
+
id: VALUE_SET_ID,
|
|
16934
|
+
version: VALUE_SET_VERSION,
|
|
16935
|
+
title: "Elements of value",
|
|
16936
|
+
subject: "acceptance",
|
|
16937
|
+
scale: VALUE_SCALE,
|
|
16938
|
+
groups: Object.keys(TIER_TITLES).map((id) => ({ id, title: TIER_TITLES[id] })),
|
|
16939
|
+
criteria: VALUE_IDS.map((id) => ({
|
|
16940
|
+
id,
|
|
16941
|
+
group: VALUE_TIERS[id],
|
|
16942
|
+
name: VALUE_TEXT[id].name,
|
|
16943
|
+
question: `Does this promise serve, or cost, "${VALUE_TEXT[id].name}"?`,
|
|
16944
|
+
definition: VALUE_TEXT[id].definition
|
|
16945
|
+
}))
|
|
16946
|
+
});
|
|
16947
|
+
var VALUE_MATRIX = deepFreeze({
|
|
16948
|
+
id: VALUE_MATRIX_ID,
|
|
16949
|
+
title: "Value",
|
|
16950
|
+
set: `${VALUE_SET_ID}@1`,
|
|
16951
|
+
subjects: { kind: "query", species: "acceptance" },
|
|
16952
|
+
positioning: POSITIONING_SET_ID,
|
|
16953
|
+
status: "active"
|
|
16954
|
+
});
|
|
16955
|
+
var BUILT_IN_SETS = [VALUE_CONTRIBUTION_SET];
|
|
16956
|
+
var BUILT_IN_MATRICES = [VALUE_MATRIX];
|
|
16957
|
+
var isObject2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16958
|
+
function cleaned(set2) {
|
|
16959
|
+
const usable = set2.criteria.filter((criterion) => isObject2(criterion) && typeof criterion.id === "string");
|
|
16960
|
+
return usable.length === set2.criteria.length ? set2 : { ...set2, criteria: usable };
|
|
16961
|
+
}
|
|
16962
|
+
function isWeighingSetShape(set2) {
|
|
16963
|
+
return isObject2(set2) && typeof set2.id === "string" && typeof set2.version === "string" && Array.isArray(set2.criteria) && (isObject2(set2.scale) || set2.role === "positioning");
|
|
16964
|
+
}
|
|
16965
|
+
function isWeighingMatrixShape(matrix) {
|
|
16966
|
+
if (!isObject2(matrix) || typeof matrix.id !== "string" || typeof matrix.set !== "string" || !isObject2(matrix.subjects)) return false;
|
|
16967
|
+
const { kind, species, items } = matrix.subjects;
|
|
16968
|
+
return kind === "query" && typeof species === "string" || kind === "list" && Array.isArray(items);
|
|
16969
|
+
}
|
|
16970
|
+
function isUsableScale(scale) {
|
|
16971
|
+
return isObject2(scale) && typeof scale.min === "number" && typeof scale.max === "number" && isObject2(scale.anchors);
|
|
16972
|
+
}
|
|
16973
|
+
function weighingScaleOf(set2, resolved) {
|
|
16974
|
+
if (isUsableScale(set2.scale)) return set2.scale;
|
|
16975
|
+
const ruler = typeof set2.extends === "string" && resolved !== void 0 ? setOfRef(resolved, set2.extends) : void 0;
|
|
16976
|
+
return ruler !== void 0 && isUsableScale(ruler.scale) ? ruler.scale : VALUE_SCALE;
|
|
16977
|
+
}
|
|
16978
|
+
function resolveWeighing(section) {
|
|
16979
|
+
const sets = [...BUILT_IN_SETS];
|
|
16980
|
+
const matrices = [...BUILT_IN_MATRICES];
|
|
16981
|
+
const skipped = [];
|
|
16982
|
+
const idOf2 = (entry) => isObject2(entry) ? { ...typeof entry.id === "string" ? { id: entry.id } : {}, ...typeof entry.role === "string" ? { role: entry.role } : {} } : {};
|
|
16983
|
+
(Array.isArray(section?.sets) ? section.sets : []).forEach((set2, index) => {
|
|
16984
|
+
if (isWeighingSetShape(set2) && !sets.some((s) => s.id === set2.id)) sets.push(cleaned(set2));
|
|
16985
|
+
else skipped.push({ kind: "set", ...idOf2(set2), index });
|
|
16986
|
+
});
|
|
16987
|
+
(Array.isArray(section?.matrices) ? section.matrices : []).forEach((matrix, index) => {
|
|
16988
|
+
if (isWeighingMatrixShape(matrix) && !matrices.some((m) => m.id === matrix.id)) matrices.push(matrix);
|
|
16989
|
+
else skipped.push({ kind: "matrix", ...idOf2(matrix), index });
|
|
16990
|
+
});
|
|
16991
|
+
return { sets, matrices, skipped };
|
|
16992
|
+
}
|
|
16993
|
+
function setOfRef(resolved, ref) {
|
|
16994
|
+
const { id, major } = splitSetRef(ref);
|
|
16995
|
+
const set2 = resolved.sets.find((candidate) => candidate.id === id);
|
|
16996
|
+
if (set2 === void 0) return void 0;
|
|
16997
|
+
return major === void 0 || majorOf(set2.version) === major ? set2 : void 0;
|
|
16998
|
+
}
|
|
16999
|
+
|
|
17000
|
+
// ../schema/src/weighing-validate.ts
|
|
17001
|
+
var isObject3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17002
|
+
function validateWeighingSection(section, nodeSpecies, journal) {
|
|
17003
|
+
const out = [];
|
|
17004
|
+
const warn = (path6, rule, message) => out.push({ path: path6, rule, message });
|
|
17005
|
+
if (section !== void 0 && section !== null && !isObject3(section)) {
|
|
17006
|
+
warn("weighing", "weighing-section-shape", "The weighing section is not an object \u2014 it is ignored");
|
|
17007
|
+
}
|
|
17008
|
+
if (isObject3(section)) {
|
|
17009
|
+
for (const list of ["sets", "matrices", "assessments"]) {
|
|
17010
|
+
if (section[list] !== void 0 && !Array.isArray(section[list])) {
|
|
17011
|
+
warn(`weighing.${list}`, "weighing-section-shape", `weighing.${list} is not an array \u2014 it is ignored`);
|
|
17012
|
+
}
|
|
17013
|
+
}
|
|
17014
|
+
const sets = Array.isArray(section.sets) ? section.sets : [];
|
|
17015
|
+
const matrices = Array.isArray(section.matrices) ? section.matrices : [];
|
|
17016
|
+
const assessments = Array.isArray(section.assessments) ? section.assessments : [];
|
|
17017
|
+
const resolved = resolveWeighing(section);
|
|
17018
|
+
const resolveRef2 = (ref, path6, who, unknownRule) => {
|
|
17019
|
+
const set2 = setOfRef(resolved, ref);
|
|
17020
|
+
if (set2 !== void 0) return set2;
|
|
17021
|
+
const named = resolved.sets.find((candidate) => candidate.id === splitSetRef(ref).id);
|
|
17022
|
+
if (named !== void 0) {
|
|
17023
|
+
warn(path6, "weighing-set-ref-major", `${who} names ${ref}, but "${named.id}" is at ${named.version} \u2014 levels are comparable only within a major, so the ref resolves to nothing`);
|
|
17024
|
+
} else {
|
|
17025
|
+
warn(path6, unknownRule, `${who} names set "${ref}", which is neither built in nor in this section`);
|
|
17026
|
+
}
|
|
17027
|
+
return void 0;
|
|
17028
|
+
};
|
|
17029
|
+
const positioningIds = new Set(
|
|
17030
|
+
resolved.matrices.map((matrix) => matrix.positioning).filter((id) => typeof id === "string")
|
|
17031
|
+
);
|
|
17032
|
+
const checkStatus = (path6, who, entry) => {
|
|
17033
|
+
if (entry.status !== void 0 && entry.status !== "draft" && entry.status !== "active") {
|
|
17034
|
+
warn(`${path6}.status`, "weighing-set-status", `${who}: status ${JSON.stringify(entry.status)} is not "draft" or "active" \u2014 it is read as a draft, which feeds no roll-up`);
|
|
17035
|
+
}
|
|
17036
|
+
};
|
|
17037
|
+
const isLevelMap = (value) => isObject3(value) && Object.values(value).every((anchor) => typeof anchor === "string");
|
|
17038
|
+
const seenSets = /* @__PURE__ */ new Set();
|
|
17039
|
+
sets.forEach((entry, index) => {
|
|
17040
|
+
const path6 = `weighing.sets[${index}]`;
|
|
17041
|
+
if (!isObject3(entry)) {
|
|
17042
|
+
warn(path6, "weighing-set-shape", "A set is not an object \u2014 it is ignored");
|
|
17043
|
+
return;
|
|
17044
|
+
}
|
|
17045
|
+
const who = `Set "${String(entry.id)}"`;
|
|
17046
|
+
const wellFormed = isWeighingSetShape(entry);
|
|
17047
|
+
if (!wellFormed) {
|
|
17048
|
+
warn(path6, "weighing-set-shape", `${who} needs a string id and version, a criteria array and a scale object (a positioning may leave the scale out) \u2014 it is ignored`);
|
|
17049
|
+
}
|
|
17050
|
+
if (typeof entry.id === "string") {
|
|
17051
|
+
if (BUILT_IN_SETS.some((set2) => set2.id === entry.id)) {
|
|
17052
|
+
warn(`${path6}.id`, "weighing-pinned-set-redefined", `${who} is built in and pinned by version \u2014 the project's copy is ignored`);
|
|
17053
|
+
} else if (wellFormed) {
|
|
17054
|
+
if (seenSets.has(entry.id)) warn(`${path6}.id`, "weighing-duplicate-set", `Duplicate set id "${entry.id}" \u2014 the first well-formed one wins, this one is ignored`);
|
|
17055
|
+
seenSets.add(entry.id);
|
|
17056
|
+
}
|
|
17057
|
+
}
|
|
17058
|
+
checkStatus(path6, who, entry);
|
|
17059
|
+
if (isObject3(entry.scale)) {
|
|
17060
|
+
const scale = entry.scale;
|
|
17061
|
+
if (typeof scale.min !== "number" || typeof scale.max !== "number" || !isLevelMap(scale.anchors)) {
|
|
17062
|
+
warn(`${path6}.scale`, "weighing-scale-shape", `${who}: a scale needs a numeric min and max and an anchors object of strings`);
|
|
17063
|
+
}
|
|
17064
|
+
}
|
|
17065
|
+
if (Array.isArray(entry.criteria)) {
|
|
17066
|
+
entry.criteria.forEach((criterion, at2) => {
|
|
17067
|
+
const cpath = `${path6}.criteria[${at2}]`;
|
|
17068
|
+
if (!isObject3(criterion) || typeof criterion.id !== "string" || criterion.anchors !== void 0 && !isLevelMap(criterion.anchors)) {
|
|
17069
|
+
warn(cpath, "weighing-criterion-shape", `${who}: criterion ${at2} needs a string id, and its anchors (if any) must be an object of strings`);
|
|
17070
|
+
}
|
|
17071
|
+
});
|
|
17072
|
+
}
|
|
17073
|
+
if (entry.role === "positioning" && !(typeof entry.id === "string" && positioningIds.has(entry.id))) {
|
|
17074
|
+
warn(`${path6}.id`, "weighing-positioning-id", `A positioning set must have the id "${POSITIONING_SET_ID}" (the one a matrix points at) \u2014 "${String(entry.id)}" would never be applied`);
|
|
17075
|
+
} else if (entry.role !== "positioning" && entry.id === POSITIONING_SET_ID) {
|
|
17076
|
+
warn(`${path6}.role`, "weighing-positioning-id", `Set "${POSITIONING_SET_ID}" is where a matrix looks for its positioning, but its role is ${JSON.stringify(entry.role)}, not "positioning" \u2014 it would never be applied`);
|
|
17077
|
+
}
|
|
17078
|
+
if (entry.role === "positioning") {
|
|
17079
|
+
const ruler = typeof entry.extends === "string" ? resolveRef2(entry.extends, `${path6}.extends`, `Positioning "${String(entry.id)}"`, "weighing-positioning-unknown-ruler") : void 0;
|
|
17080
|
+
if (typeof entry.extends !== "string") {
|
|
17081
|
+
warn(`${path6}.extends`, "weighing-positioning-unknown-ruler", `Positioning "${String(entry.id)}" does not say which set it re-weights \u2014 set extends to e.g. value-contribution@1`);
|
|
17082
|
+
} else if (ruler !== void 0 && ruler.role === "positioning") {
|
|
17083
|
+
warn(`${path6}.extends`, "weighing-positioning-unknown-ruler", `Positioning "${String(entry.id)}" extends "${entry.extends}", which is itself a positioning \u2014 it must extend a criteria set such as value-contribution@1`);
|
|
17084
|
+
}
|
|
17085
|
+
const known = new Set(ruler !== void 0 && ruler.role !== "positioning" ? ruler.criteria.map((criterion) => criterion?.id) : []);
|
|
17086
|
+
(Array.isArray(entry.criteria) ? entry.criteria : []).forEach((criterion, at2) => {
|
|
17087
|
+
if (!isObject3(criterion)) return;
|
|
17088
|
+
const cpath = `${path6}.criteria[${at2}]`;
|
|
17089
|
+
if (known.size > 0 && typeof criterion.id === "string" && !known.has(criterion.id)) {
|
|
17090
|
+
warn(`${cpath}.id`, "weighing-positioning-unknown-element", `Positioning names "${criterion.id}", which is not in ${String(entry.extends)}`);
|
|
17091
|
+
}
|
|
17092
|
+
if (criterion.weight !== void 0 && (typeof criterion.weight !== "number" || !(criterion.weight > 0))) {
|
|
17093
|
+
warn(`${cpath}.weight`, "weighing-positioning-weight", `Positioning weight for "${String(criterion.id)}" must be a number above 0 \u2014 leave the element out to leave it unpositioned`);
|
|
17094
|
+
}
|
|
17095
|
+
});
|
|
17096
|
+
}
|
|
17097
|
+
});
|
|
17098
|
+
const seenMatrices = /* @__PURE__ */ new Set();
|
|
17099
|
+
matrices.forEach((entry, index) => {
|
|
17100
|
+
const path6 = `weighing.matrices[${index}]`;
|
|
17101
|
+
if (!isObject3(entry)) {
|
|
17102
|
+
warn(path6, "weighing-matrix-shape", "A matrix is not an object \u2014 it is ignored");
|
|
17103
|
+
return;
|
|
17104
|
+
}
|
|
17105
|
+
const who = `Matrix "${String(entry.id)}"`;
|
|
17106
|
+
const wellFormed = isWeighingMatrixShape(entry);
|
|
17107
|
+
if (!wellFormed) {
|
|
17108
|
+
warn(path6, "weighing-matrix-shape", `${who} needs a string id, a set ref and a subjects object of kind query or list \u2014 it is ignored`);
|
|
17109
|
+
}
|
|
17110
|
+
if (typeof entry.id === "string") {
|
|
17111
|
+
if (BUILT_IN_MATRICES.some((matrix) => matrix.id === entry.id)) {
|
|
17112
|
+
warn(`${path6}.id`, "weighing-pinned-matrix-redefined", `${who} is built in \u2014 the project's copy is ignored`);
|
|
17113
|
+
} else if (wellFormed) {
|
|
17114
|
+
if (seenMatrices.has(entry.id)) warn(`${path6}.id`, "weighing-duplicate-matrix", `Duplicate matrix id "${entry.id}" \u2014 the first well-formed one wins, this one is ignored`);
|
|
17115
|
+
seenMatrices.add(entry.id);
|
|
17116
|
+
}
|
|
17117
|
+
}
|
|
17118
|
+
checkStatus(path6, who, entry);
|
|
17119
|
+
if (wellFormed) resolveRef2(entry.set, `${path6}.set`, who, "weighing-unknown-set");
|
|
17120
|
+
});
|
|
17121
|
+
const seenCells = /* @__PURE__ */ new Set();
|
|
17122
|
+
assessments.forEach((entry, index) => {
|
|
17123
|
+
const path6 = `weighing.assessments[${index}]`;
|
|
17124
|
+
const label = `Assessment ${index}`;
|
|
17125
|
+
if (!isWeighingAssessmentShape(entry)) {
|
|
17126
|
+
warn(path6, "weighing-assessment-shape", `${label}: not an object with a string matrix, subject and criterion \u2014 it cannot be addressed, so every reader skips it`);
|
|
17127
|
+
return;
|
|
17128
|
+
}
|
|
17129
|
+
if (typeof entry.ts !== "string" || Number.isNaN(Date.parse(entry.ts))) {
|
|
17130
|
+
warn(`${path6}.ts`, "weighing-assessment-ts", `${label}: ts must be an ISO 8601 string \u2014 without it "latest wins" cannot order this row`);
|
|
17131
|
+
}
|
|
17132
|
+
const matrix = resolved.matrices.find((candidate) => candidate.id === entry.matrix);
|
|
17133
|
+
if (matrix === void 0) {
|
|
17134
|
+
warn(`${path6}.matrix`, "weighing-unknown-matrix", `${label}: matrix "${entry.matrix}" is not defined`);
|
|
17135
|
+
}
|
|
17136
|
+
const set2 = matrix === void 0 ? void 0 : setOfRef(resolved, matrix.set);
|
|
17137
|
+
const criterion = set2?.criteria.find((candidate) => candidate?.id === entry.criterion);
|
|
17138
|
+
if (set2 !== void 0 && criterion === void 0) {
|
|
17139
|
+
warn(`${path6}.criterion`, "weighing-unknown-criterion", `${label}: criterion "${entry.criterion}" is not in set "${set2.id}"`);
|
|
17140
|
+
}
|
|
17141
|
+
if (criterion !== void 0 && typeof criterion.superseded_by === "string" && criterion.superseded_by !== "") {
|
|
17142
|
+
warn(`${path6}.criterion`, "weighing-retired-criterion", `${label}: criterion "${criterion.id}" is retired \u2014 superseded by "${criterion.superseded_by}"`);
|
|
17143
|
+
}
|
|
17144
|
+
const scale = set2 === void 0 ? void 0 : weighingScaleOf(set2, resolved);
|
|
17145
|
+
const min = typeof scale?.min === "number" ? scale.min : -3;
|
|
17146
|
+
const max = typeof scale?.max === "number" ? scale.max : 3;
|
|
17147
|
+
if (typeof entry.level !== "number" || !Number.isInteger(entry.level) || entry.level < min || entry.level > max) {
|
|
17148
|
+
warn(`${path6}.level`, "weighing-level-range", `${label}: level must be an integer ${min}..${max} (a blank cell is the absence of the row; 0 means weighed and unrelated)`);
|
|
17149
|
+
}
|
|
17150
|
+
if (![0, 1, 2, 3].includes(entry.confidence)) {
|
|
17151
|
+
warn(`${path6}.confidence`, "weighing-confidence-range", `${label}: confidence must be 0, 1, 2 or 3`);
|
|
17152
|
+
}
|
|
17153
|
+
const scorer = isObject3(entry.scorer) ? entry.scorer : void 0;
|
|
17154
|
+
if (scorer === void 0 || typeof scorer.kind !== "string" || typeof scorer.id !== "string" || scorer.id === "") {
|
|
17155
|
+
warn(`${path6}.scorer`, "weighing-scorer-missing", `${label}: no scorer with a string kind and id \u2014 human, agent and rule levels become indistinguishable, and the row can win no cell`);
|
|
17156
|
+
} else if (!SCORER_KINDS.includes(scorer.kind)) {
|
|
17157
|
+
warn(`${path6}.scorer.kind`, "weighing-scorer-kind", `${label}: scorer kind "${scorer.kind}" is not one of ${SCORER_KINDS.join(", ")} \u2014 it ranks below every other scorer`);
|
|
17158
|
+
} else if (!STORED_SCORER_KINDS.includes(scorer.kind)) {
|
|
17159
|
+
warn(`${path6}.scorer.kind`, "weighing-rule-stored", `${label}: scorer kind "${scorer.kind}" is never stored \u2014 a seeding rule is computed on read`);
|
|
17160
|
+
}
|
|
17161
|
+
if (matrix?.subjects.kind === "query") {
|
|
17162
|
+
const species = nodeSpecies.get(entry.subject);
|
|
17163
|
+
if (species === void 0) {
|
|
17164
|
+
warn(`${path6}.subject`, "weighing-unknown-subject", `${label}: subject "${entry.subject}" is not a node in this bundle`);
|
|
17165
|
+
} else if (species !== matrix.subjects.species) {
|
|
17166
|
+
warn(`${path6}.subject`, "weighing-subject-species", `${label}: subject "${entry.subject}" is a ${species}, and matrix "${matrix.id}" judges ${String(matrix.subjects.species)} nodes`);
|
|
17167
|
+
}
|
|
17168
|
+
}
|
|
17169
|
+
if (entry.evidence !== void 0 && typeof entry.evidence !== "string") {
|
|
17170
|
+
warn(`${path6}.evidence`, "weighing-evidence-type", `${label}: evidence must be a markdown string`);
|
|
17171
|
+
} else if ((entry.confidence === 2 || entry.confidence === 3) && (entry.evidence === void 0 || entry.evidence.trim() === "")) {
|
|
17172
|
+
warn(`${path6}.evidence`, "weighing-no-evidence", `${label}: confidence ${String(entry.confidence)} claims evidence and cites none`);
|
|
17173
|
+
}
|
|
17174
|
+
if (entry.refs !== void 0 && !(Array.isArray(entry.refs) && entry.refs.every((ref) => typeof ref === "string"))) {
|
|
17175
|
+
warn(`${path6}.refs`, "weighing-refs-type", `${label}: refs must be an array of id strings`);
|
|
17176
|
+
}
|
|
17177
|
+
if (entry.basis !== void 0 && !(isObject3(entry.basis) && ["fingerprint", "commit", "set_version"].every((key) => entry.basis[key] === void 0 || typeof entry.basis[key] === "string"))) {
|
|
17178
|
+
warn(`${path6}.basis`, "weighing-basis-shape", `${label}: basis must be an object whose fingerprint, commit and set_version are strings`);
|
|
17179
|
+
}
|
|
17180
|
+
if (scorer !== void 0 && typeof scorer.kind === "string") {
|
|
17181
|
+
const key = assessmentKey(entry);
|
|
17182
|
+
if (seenCells.has(key)) {
|
|
17183
|
+
warn(path6, "weighing-duplicate-assessment", `${label}: a second ${scorer.kind} score for the same cell \u2014 the section stores latest-per-scorer-kind, so this cell is ambiguous`);
|
|
17184
|
+
}
|
|
17185
|
+
seenCells.add(key);
|
|
17186
|
+
}
|
|
17187
|
+
const setVersion = isObject3(entry.basis) && typeof entry.basis.set_version === "string" ? entry.basis.set_version : void 0;
|
|
17188
|
+
if (set2 !== void 0 && setVersion !== void 0 && majorOf(setVersion) !== majorOf(set2.version)) {
|
|
17189
|
+
warn(`${path6}.basis.set_version`, "weighing-set-major", `${label}: scored against ${set2.id} ${setVersion}, and the set is now ${set2.version} \u2014 levels are comparable only within a major`);
|
|
17190
|
+
}
|
|
17191
|
+
});
|
|
17192
|
+
}
|
|
17193
|
+
journal.forEach((entry, index) => {
|
|
17194
|
+
if (!isObject3(entry)) return;
|
|
17195
|
+
const type = typeof entry.type === "string" ? entry.type : "";
|
|
17196
|
+
if (type !== WEIGHING_ASSESSMENT_RECORDED && type !== WEIGHING_SET_SAVED) return;
|
|
17197
|
+
if (typeof entry.actor !== "string" || entry.actor.trim() === "") {
|
|
17198
|
+
warn(`journal[${index}].actor`, "weighing-event-no-actor", `Journal event ${index}: ${type} has no actor \u2014 human, agent and CI scores become indistinguishable`);
|
|
17199
|
+
}
|
|
17200
|
+
});
|
|
17201
|
+
return out;
|
|
17202
|
+
}
|
|
17203
|
+
|
|
16705
17204
|
// ../schema/src/validate.ts
|
|
16706
17205
|
var VALID_STAGES = ["beta", "monitoring", "deprecated"];
|
|
16707
17206
|
var VALID_VIEW_CARD_VARIANTS = ["compact", "large"];
|
|
@@ -17552,6 +18051,13 @@ function validateBundle(input) {
|
|
|
17552
18051
|
}
|
|
17553
18052
|
});
|
|
17554
18053
|
}
|
|
18054
|
+
const weighing = bundle.weighing;
|
|
18055
|
+
const embeddedJournal = Array.isArray(bundle.journal) ? bundle.journal : [];
|
|
18056
|
+
const weighingSpecies = /* @__PURE__ */ new Map();
|
|
18057
|
+
for (const [id, node] of nodeMap) weighingSpecies.set(id, String(node.species));
|
|
18058
|
+
for (const finding of validateWeighingSection(weighing, weighingSpecies, embeddedJournal)) {
|
|
18059
|
+
warn(finding.path, finding.rule, finding.message);
|
|
18060
|
+
}
|
|
17555
18061
|
for (const finding of crossCheckJournal(bundle)) findings.push(finding);
|
|
17556
18062
|
return result();
|
|
17557
18063
|
}
|
|
@@ -17885,7 +18391,7 @@ function edgeRemovedInput(edgeId2) {
|
|
|
17885
18391
|
}
|
|
17886
18392
|
var TOP_LEVEL_FIELDS = ["species", "title", "description", "status", "platforms"];
|
|
17887
18393
|
var MAX_SCALAR_LEN = 512;
|
|
17888
|
-
function
|
|
18394
|
+
function isRecord4(value) {
|
|
17889
18395
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
17890
18396
|
}
|
|
17891
18397
|
function isShortScalar(value) {
|
|
@@ -17896,8 +18402,8 @@ function valueEqual(a, b) {
|
|
|
17896
18402
|
return JSON.stringify(a) === JSON.stringify(b);
|
|
17897
18403
|
}
|
|
17898
18404
|
function changedMapKeys(prev, next) {
|
|
17899
|
-
const p =
|
|
17900
|
-
const n =
|
|
18405
|
+
const p = isRecord4(prev) ? prev : {};
|
|
18406
|
+
const n = isRecord4(next) ? next : {};
|
|
17901
18407
|
const changed = [];
|
|
17902
18408
|
for (const key of /* @__PURE__ */ new Set([...Object.keys(p), ...Object.keys(n)])) {
|
|
17903
18409
|
if (!valueEqual(p[key], n[key])) changed.push(key);
|
|
@@ -17905,8 +18411,8 @@ function changedMapKeys(prev, next) {
|
|
|
17905
18411
|
return changed.sort();
|
|
17906
18412
|
}
|
|
17907
18413
|
function diffPlatformStatuses(nodeId, currentBase, nextBase, prev, next) {
|
|
17908
|
-
const p =
|
|
17909
|
-
const n =
|
|
18414
|
+
const p = isRecord4(prev) ? prev : {};
|
|
18415
|
+
const n = isRecord4(next) ? next : {};
|
|
17910
18416
|
const events = [];
|
|
17911
18417
|
for (const platform of [.../* @__PURE__ */ new Set([...Object.keys(p), ...Object.keys(n)])].sort()) {
|
|
17912
18418
|
const from = p[platform];
|
|
@@ -17930,7 +18436,7 @@ function diffRefs(nodeId, prev, next) {
|
|
|
17930
18436
|
const byId = (arr) => {
|
|
17931
18437
|
const map2 = /* @__PURE__ */ new Map();
|
|
17932
18438
|
for (const item of arr) {
|
|
17933
|
-
if (
|
|
18439
|
+
if (isRecord4(item) && typeof item.id === "string") map2.set(item.id, item);
|
|
17934
18440
|
}
|
|
17935
18441
|
return map2;
|
|
17936
18442
|
};
|
|
@@ -17970,8 +18476,8 @@ function diffNodeUpdate(current, patch) {
|
|
|
17970
18476
|
}
|
|
17971
18477
|
}
|
|
17972
18478
|
if ("metadata" in pat) {
|
|
17973
|
-
const prevMeta =
|
|
17974
|
-
const nextMeta =
|
|
18479
|
+
const prevMeta = isRecord4(current.metadata) ? current.metadata : {};
|
|
18480
|
+
const nextMeta = isRecord4(patch.metadata) ? patch.metadata : {};
|
|
17975
18481
|
const currentBase = current.status;
|
|
17976
18482
|
const nextBase = "status" in pat && pat.status !== void 0 ? pat.status : current.status;
|
|
17977
18483
|
for (const key of /* @__PURE__ */ new Set([...Object.keys(prevMeta), ...Object.keys(nextMeta)])) {
|
|
@@ -18378,13 +18884,13 @@ var REGRESSION_SIGNALS = {
|
|
|
18378
18884
|
"new-severe-finding": "no open Critical or High finding on this cell",
|
|
18379
18885
|
"reopened-finding": "a resolved finding stays resolved"
|
|
18380
18886
|
};
|
|
18381
|
-
var
|
|
18887
|
+
var cellKey2 = (criterionId, surface) => `${criterionId}::${surface}`;
|
|
18382
18888
|
var rowsOf = (value) => Array.isArray(value) ? value : [];
|
|
18383
18889
|
function assessmentsByCell(state) {
|
|
18384
18890
|
const cells = /* @__PURE__ */ new Map();
|
|
18385
18891
|
for (const assessment of rowsOf(state?.assessments)) {
|
|
18386
18892
|
if (typeof assessment?.criterion_id !== "string" || typeof assessment?.surface !== "string") continue;
|
|
18387
|
-
cells.set(
|
|
18893
|
+
cells.set(cellKey2(assessment.criterion_id, assessment.surface), assessment);
|
|
18388
18894
|
}
|
|
18389
18895
|
return cells;
|
|
18390
18896
|
}
|
|
@@ -18395,7 +18901,7 @@ function severeByCell(state, library) {
|
|
|
18395
18901
|
if (!isOpenFinding(finding)) continue;
|
|
18396
18902
|
const severity = severityOf(finding, library);
|
|
18397
18903
|
if (severity !== "critical" && severity !== "high") continue;
|
|
18398
|
-
const key =
|
|
18904
|
+
const key = cellKey2(finding.criterion_id, finding.surface);
|
|
18399
18905
|
const existing = cells.get(key);
|
|
18400
18906
|
if (existing === void 0) cells.set(key, [finding]);
|
|
18401
18907
|
else existing.push(finding);
|
|
@@ -18451,7 +18957,7 @@ function detectRegressions(previous, next, library) {
|
|
|
18451
18957
|
|
|
18452
18958
|
// ../schema/src/quality-trend.ts
|
|
18453
18959
|
var NO_DELTA = { previous: null, delta: null };
|
|
18454
|
-
var
|
|
18960
|
+
var isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18455
18961
|
function frameworkMajor(version2) {
|
|
18456
18962
|
if (typeof version2 !== "string") return null;
|
|
18457
18963
|
const match = /^\s*v?(\d+)/.exec(version2);
|
|
@@ -18464,27 +18970,27 @@ function sameFrameworkMajor(a, b) {
|
|
|
18464
18970
|
}
|
|
18465
18971
|
function scopeOf(raw) {
|
|
18466
18972
|
if (readPlanScope(raw) !== null) return void 0;
|
|
18467
|
-
if (!
|
|
18973
|
+
if (!isRecord5(raw) || typeof raw.since !== "string" || raw.since === "") return void 0;
|
|
18468
18974
|
return { scope: { since: raw.since, cells: typeof raw.cells === "number" && Number.isFinite(raw.cells) ? raw.cells : null } };
|
|
18469
18975
|
}
|
|
18470
18976
|
function cleanScores(raw) {
|
|
18471
18977
|
const scores = {};
|
|
18472
|
-
if (!
|
|
18978
|
+
if (!isRecord5(raw)) return scores;
|
|
18473
18979
|
for (const surface of Object.keys(raw)) {
|
|
18474
18980
|
const bySurface = raw[surface];
|
|
18475
|
-
if (!
|
|
18476
|
-
const
|
|
18981
|
+
if (!isRecord5(bySurface)) continue;
|
|
18982
|
+
const cleaned2 = {};
|
|
18477
18983
|
for (const domain2 of Object.keys(bySurface)) {
|
|
18478
18984
|
const score = bySurface[domain2];
|
|
18479
|
-
if (typeof score === "number" && Number.isFinite(score))
|
|
18985
|
+
if (typeof score === "number" && Number.isFinite(score)) cleaned2[domain2] = score;
|
|
18480
18986
|
}
|
|
18481
|
-
scores[surface] =
|
|
18987
|
+
scores[surface] = cleaned2;
|
|
18482
18988
|
}
|
|
18483
18989
|
return scores;
|
|
18484
18990
|
}
|
|
18485
18991
|
function cleanCounts(raw) {
|
|
18486
18992
|
const counts = { critical: 0, high: 0, medium: 0, low: 0, info: 0 };
|
|
18487
|
-
if (!
|
|
18993
|
+
if (!isRecord5(raw)) return counts;
|
|
18488
18994
|
for (const severity of Object.keys(counts)) {
|
|
18489
18995
|
const value = raw[severity];
|
|
18490
18996
|
if (typeof value === "number" && Number.isFinite(value)) counts[severity] = value;
|
|
@@ -18502,7 +19008,7 @@ function liveScores(live) {
|
|
|
18502
19008
|
const scores = {};
|
|
18503
19009
|
for (const domain2 of Object.keys(live.matrix ?? {})) {
|
|
18504
19010
|
const row = live.matrix[domain2];
|
|
18505
|
-
if (!
|
|
19011
|
+
if (!isRecord5(row)) continue;
|
|
18506
19012
|
for (const surface of Object.keys(row)) {
|
|
18507
19013
|
const cell = row[surface];
|
|
18508
19014
|
if (!cell || typeof cell.score !== "number") continue;
|
|
@@ -18522,7 +19028,7 @@ function deriveQualityTrend(events, profile, live) {
|
|
|
18522
19028
|
const weights = profile?.domain_weights;
|
|
18523
19029
|
const byAudit = /* @__PURE__ */ new Map();
|
|
18524
19030
|
const audits = (Array.isArray(events) ? events : []).filter(
|
|
18525
|
-
(event) =>
|
|
19031
|
+
(event) => isRecord5(event) && event.type === "quality.audit.completed"
|
|
18526
19032
|
);
|
|
18527
19033
|
for (const event of orderEvents(audits)) {
|
|
18528
19034
|
const auditId = typeof event.audit_id === "string" ? event.audit_id : typeof event.id === "string" ? event.id : "";
|
|
@@ -18629,7 +19135,7 @@ function formatDelta(delta) {
|
|
|
18629
19135
|
var rowsOf2 = (value) => Array.isArray(value) ? value : [];
|
|
18630
19136
|
var isString = (value) => typeof value === "string" && value !== "";
|
|
18631
19137
|
var stringsOf = (value) => rowsOf2(value).filter(isString);
|
|
18632
|
-
var
|
|
19138
|
+
var cellKey3 = (criterionId, surface) => `${criterionId}::${surface}`;
|
|
18633
19139
|
var orderedRows = (events) => orderEvents(rowsOf2(events).filter((event) => typeof event === "object" && event !== null));
|
|
18634
19140
|
function isPlanRecord(event) {
|
|
18635
19141
|
if (typeof event !== "object" || event === null) return false;
|
|
@@ -18713,7 +19219,7 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18713
19219
|
for (const assessment of rowsOf2(section?.assessments)) {
|
|
18714
19220
|
if (!isString(assessment?.criterion_id) || !isString(assessment?.surface) || !isString(assessment?.audit_id)) continue;
|
|
18715
19221
|
if (!isString(assessment.ts)) continue;
|
|
18716
|
-
const key =
|
|
19222
|
+
const key = cellKey3(assessment.criterion_id, assessment.surface);
|
|
18717
19223
|
const byAudit = scoredAt.get(key) ?? /* @__PURE__ */ new Map();
|
|
18718
19224
|
const seen = byAudit.get(assessment.audit_id);
|
|
18719
19225
|
if (seen === void 0 || seen < assessment.ts) byAudit.set(assessment.audit_id, assessment.ts);
|
|
@@ -18769,7 +19275,7 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18769
19275
|
const assessmentByCell = /* @__PURE__ */ new Map();
|
|
18770
19276
|
for (const assessment of rowsOf2(section?.assessments)) {
|
|
18771
19277
|
if (!isString(assessment?.criterion_id) || !isString(assessment?.surface)) continue;
|
|
18772
|
-
assessmentByCell.set(
|
|
19278
|
+
assessmentByCell.set(cellKey3(assessment.criterion_id, assessment.surface), assessment);
|
|
18773
19279
|
}
|
|
18774
19280
|
const declared = rowsOf2(section?.profile?.surfaces).map((surface) => surface?.id).filter((id) => isString(id) && id !== CROSS_SURFACE_ID);
|
|
18775
19281
|
const surfaces = declared.length > 0 ? [...new Set(declared)] : [...new Set([...assessmentByCell.values()].map((assessment) => assessment.surface))].filter((id) => id !== CROSS_SURFACE_ID).sort();
|
|
@@ -18782,7 +19288,7 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18782
19288
|
};
|
|
18783
19289
|
const cells = /* @__PURE__ */ new Map();
|
|
18784
19290
|
const addDirect = (criterionId, surface, findingId) => {
|
|
18785
|
-
const key =
|
|
19291
|
+
const key = cellKey3(criterionId, surface);
|
|
18786
19292
|
const existing = cells.get(key);
|
|
18787
19293
|
if (existing === void 0) cells.set(key, { criterion_id: criterionId, surface, kind: "direct", because: [findingId] });
|
|
18788
19294
|
else if (!existing.because.includes(findingId)) existing.because.push(findingId);
|
|
@@ -18811,7 +19317,7 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18811
19317
|
unscorable.push(findingId);
|
|
18812
19318
|
continue;
|
|
18813
19319
|
}
|
|
18814
|
-
const live = targets.filter((surface) => countsFor(
|
|
19320
|
+
const live = targets.filter((surface) => countsFor(cellKey3(finding.criterion_id, surface), resolution.last));
|
|
18815
19321
|
if (live.length === 0) continue;
|
|
18816
19322
|
drivers.push(findingId);
|
|
18817
19323
|
if (resolution.resolved_by !== void 0) resolvedBy[findingId] = resolution.resolved_by;
|
|
@@ -18821,7 +19327,7 @@ function deriveAuditScope(events, section, library, options = {}) {
|
|
|
18821
19327
|
if (options.widen !== false && resolvedNodes.size > 0) {
|
|
18822
19328
|
const nodesByCell = /* @__PURE__ */ new Map();
|
|
18823
19329
|
const noteNodes = (criterionId, surface, nodes) => {
|
|
18824
|
-
const key =
|
|
19330
|
+
const key = cellKey3(criterionId, surface);
|
|
18825
19331
|
const bucket = nodesByCell.get(key) ?? /* @__PURE__ */ new Set();
|
|
18826
19332
|
for (const node of nodes) bucket.add(node);
|
|
18827
19333
|
nodesByCell.set(key, bucket);
|
|
@@ -18930,13 +19436,13 @@ var EVENT_CAUSE = {
|
|
|
18930
19436
|
"quality.finding.accepted": "accepted",
|
|
18931
19437
|
"quality.audit.completed": "audit"
|
|
18932
19438
|
};
|
|
18933
|
-
var
|
|
19439
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18934
19440
|
var isString2 = (value) => typeof value === "string" && value !== "";
|
|
18935
19441
|
var emptyCounts = () => ({ critical: 0, high: 0, medium: 0, low: 0, info: 0 });
|
|
18936
19442
|
var asSeverity = (value) => typeof value === "string" && FINDING_SEVERITIES.includes(value) ? value : null;
|
|
18937
19443
|
function cleanCounts2(raw) {
|
|
18938
19444
|
const counts = emptyCounts();
|
|
18939
|
-
if (!
|
|
19445
|
+
if (!isRecord6(raw)) return counts;
|
|
18940
19446
|
for (const severity of FINDING_SEVERITIES) {
|
|
18941
19447
|
const value = raw[severity];
|
|
18942
19448
|
if (typeof value === "number" && Number.isFinite(value) && value > 0) counts[severity] = value;
|
|
@@ -18951,7 +19457,7 @@ function deriveFindingsBurndown(events, options = {}) {
|
|
|
18951
19457
|
const filtered = surface !== void 0 || domain2 !== void 0;
|
|
18952
19458
|
const sectionById = /* @__PURE__ */ new Map();
|
|
18953
19459
|
for (const finding of Array.isArray(options.findings) ? options.findings : []) {
|
|
18954
|
-
if (
|
|
19460
|
+
if (isRecord6(finding) && isString2(finding.id)) sectionById.set(finding.id, finding);
|
|
18955
19461
|
}
|
|
18956
19462
|
const inView = (where2) => {
|
|
18957
19463
|
if (!filtered) return true;
|
|
@@ -18963,7 +19469,7 @@ function deriveFindingsBurndown(events, options = {}) {
|
|
|
18963
19469
|
return true;
|
|
18964
19470
|
};
|
|
18965
19471
|
const relevant = (Array.isArray(events) ? events : []).filter(
|
|
18966
|
-
(event) =>
|
|
19472
|
+
(event) => isRecord6(event) && typeof event.type === "string" && event.type in EVENT_CAUSE
|
|
18967
19473
|
);
|
|
18968
19474
|
const openedIds = /* @__PURE__ */ new Set();
|
|
18969
19475
|
const decidedIds = /* @__PURE__ */ new Set();
|
|
@@ -19084,6 +19590,10 @@ function burndownSummary(burndown, openNow) {
|
|
|
19084
19590
|
return `${closed} closed${where2} (${tally.resolved} resolved, ${tally.accepted} accepted) \xB7 ${tally.opened} opened \xB7 ${open} open`;
|
|
19085
19591
|
}
|
|
19086
19592
|
|
|
19593
|
+
// ../schema/src/weighing-derive.ts
|
|
19594
|
+
var SEED_SCORER_ID = "seed-by-claim-order";
|
|
19595
|
+
var SEED_SCORER = Object.freeze({ kind: "rule", id: SEED_SCORER_ID });
|
|
19596
|
+
|
|
19087
19597
|
// src/commands/init.ts
|
|
19088
19598
|
var DEFAULT_BUNDLE_PATH = "docs/arkaik/bundle.json";
|
|
19089
19599
|
var DEFAULT_JOURNAL_PATH = "docs/arkaik/journal.jsonl";
|
|
@@ -20459,7 +20969,7 @@ ${USAGE6}`);
|
|
|
20459
20969
|
}
|
|
20460
20970
|
|
|
20461
20971
|
// src/commands/pack.ts
|
|
20462
|
-
import { existsSync as
|
|
20972
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync6 } from "node:fs";
|
|
20463
20973
|
import { dirname as dirname5, extname, resolve as resolve5 } from "node:path";
|
|
20464
20974
|
|
|
20465
20975
|
// src/lib/kritik-io.ts
|
|
@@ -20765,15 +21275,72 @@ function resolveQualityRoot(options) {
|
|
|
20765
21275
|
return options.fallback;
|
|
20766
21276
|
}
|
|
20767
21277
|
|
|
21278
|
+
// ../schema/src/cli/weighing-files.ts
|
|
21279
|
+
import { existsSync as existsSync8, readdirSync as readdirSync3 } from "node:fs";
|
|
21280
|
+
import { join as join6 } from "node:path";
|
|
21281
|
+
var WEIGHING_DIR = "docs/weighing";
|
|
21282
|
+
var WEIGHING_SETS_DIR = "sets";
|
|
21283
|
+
var WEIGHING_ASSESSMENTS_DIR = "assessments";
|
|
21284
|
+
var weighingDir = (root) => join6(root, WEIGHING_DIR);
|
|
21285
|
+
function jsonFilesIn(dir) {
|
|
21286
|
+
if (!existsSync8(dir)) return [];
|
|
21287
|
+
return readdirSync3(dir).filter((name) => name.endsWith(".json")).sort().map((name) => join6(dir, name));
|
|
21288
|
+
}
|
|
21289
|
+
function assessmentsOfFile(file2) {
|
|
21290
|
+
const parsed = readJson(file2);
|
|
21291
|
+
const assessments = typeof parsed === "object" && parsed !== null ? parsed.assessments : void 0;
|
|
21292
|
+
if (!Array.isArray(assessments)) throw new Error(`${file2}: expected { "matrix": \u2026, "assessments": [] }`);
|
|
21293
|
+
return assessments;
|
|
21294
|
+
}
|
|
21295
|
+
function loadWeighingSets(root) {
|
|
21296
|
+
return jsonFilesIn(join6(weighingDir(root), WEIGHING_SETS_DIR)).map((file2) => {
|
|
21297
|
+
const parsed = readJson(file2);
|
|
21298
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error(`${file2}: expected a criteria set object`);
|
|
21299
|
+
return parsed;
|
|
21300
|
+
});
|
|
21301
|
+
}
|
|
21302
|
+
function loadWeighingAssessments(root) {
|
|
21303
|
+
return jsonFilesIn(join6(weighingDir(root), WEIGHING_ASSESSMENTS_DIR)).flatMap(assessmentsOfFile);
|
|
21304
|
+
}
|
|
21305
|
+
function loadWeighingSection(root) {
|
|
21306
|
+
const sets = loadWeighingSets(root);
|
|
21307
|
+
const assessments = loadWeighingAssessments(root);
|
|
21308
|
+
if (sets.length === 0 && assessments.length === 0) return void 0;
|
|
21309
|
+
return { sets, matrices: [], assessments: sortWeighingAssessments(assessments) };
|
|
21310
|
+
}
|
|
21311
|
+
|
|
21312
|
+
// src/lib/weighing-io.ts
|
|
21313
|
+
function isSection(value) {
|
|
21314
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
21315
|
+
}
|
|
21316
|
+
function foldWeighingSection(bundle, root) {
|
|
21317
|
+
const section = loadWeighingSection(root);
|
|
21318
|
+
if (section === void 0) {
|
|
21319
|
+
const carriedSection = isSection(bundle.weighing);
|
|
21320
|
+
return {
|
|
21321
|
+
folded: false,
|
|
21322
|
+
carriedSection,
|
|
21323
|
+
notice: carriedSection ? `Weighing: none to fold \u2014 no files under ${weighingDir(root)}
|
|
21324
|
+
Kept the weighing section this bundle already carried \u2014 nothing replaced it.` : `Weighing: none to fold \u2014 no files under ${weighingDir(root)}`
|
|
21325
|
+
};
|
|
21326
|
+
}
|
|
21327
|
+
bundle.weighing = section;
|
|
21328
|
+
return {
|
|
21329
|
+
folded: true,
|
|
21330
|
+
carriedSection: false,
|
|
21331
|
+
notice: `Weighing: folded ${section.assessments?.length ?? 0} assessment(s), ${section.sets?.length ?? 0} set(s) from ${weighingDir(root)}`
|
|
21332
|
+
};
|
|
21333
|
+
}
|
|
21334
|
+
|
|
20768
21335
|
// src/commands/pack.ts
|
|
20769
21336
|
var DEFAULT_BUNDLE_PATH6 = "docs/arkaik/bundle.json";
|
|
20770
|
-
var USAGE7 = `arkaik pack [--no-journal] [--no-quality] [--
|
|
20771
|
-
[--root <dir>] [--out <path>] [path]
|
|
21337
|
+
var USAGE7 = `arkaik pack [--no-journal] [--no-quality] [--no-weighing] [--inline-assets]
|
|
21338
|
+
[--audit <id>] [--root <dir>] [--out <path>] [path]
|
|
20772
21339
|
|
|
20773
21340
|
Produce a single self-contained interchange bundle: fold in the sidecar
|
|
20774
21341
|
journal (or keep an existing embedded one), fold docs/quality/ into the
|
|
20775
|
-
quality section,
|
|
20776
|
-
data: URIs. Written canonically via serializeBundle. Unknown top-level keys
|
|
21342
|
+
quality section, fold docs/weighing/ into the weighing section, and, with
|
|
21343
|
+
--inline-assets, inline local screenshot files as data: URIs. Written canonically via serializeBundle. Unknown top-level keys
|
|
20777
21344
|
and unknown fields always round-trip.
|
|
20778
21345
|
|
|
20779
21346
|
Arguments:
|
|
@@ -20794,6 +21361,10 @@ Options:
|
|
|
20794
21361
|
find it in. ("arkaik push" packs this way by default;
|
|
20795
21362
|
its --include-quality opts back in.)
|
|
20796
21363
|
Default: docs/quality/ IS folded in.
|
|
21364
|
+
--no-weighing DELETE the weighing section rather than folding one in, for
|
|
21365
|
+
the same reason --no-quality deletes: a source bundle that
|
|
21366
|
+
already carried one must not be packed with it either.
|
|
21367
|
+
Default: docs/weighing/ IS folded in.
|
|
20797
21368
|
--inline-assets Convert relative-path metadata.platformScreenshots values
|
|
20798
21369
|
into data: URIs by reading the file from disk (resolved
|
|
20799
21370
|
against the bundle's directory). Absolute https:// URLs
|
|
@@ -20885,6 +21456,20 @@ function runPack(options = {}) {
|
|
|
20885
21456
|
return fatalResult2(filePath, e.message);
|
|
20886
21457
|
}
|
|
20887
21458
|
}
|
|
21459
|
+
let weighingFolded;
|
|
21460
|
+
let weighingNotice;
|
|
21461
|
+
if (options.noWeighing ?? false) {
|
|
21462
|
+
delete bundle.weighing;
|
|
21463
|
+
} else {
|
|
21464
|
+
const root = resolveQualityRoot({ root: options.root, bundlePath: filePath, fallback: cwd });
|
|
21465
|
+
try {
|
|
21466
|
+
const fold = foldWeighingSection(bundle, root);
|
|
21467
|
+
weighingFolded = fold.folded;
|
|
21468
|
+
weighingNotice = fold.notice;
|
|
21469
|
+
} catch (e) {
|
|
21470
|
+
return fatalResult2(filePath, e.message);
|
|
21471
|
+
}
|
|
21472
|
+
}
|
|
20888
21473
|
const inlinedAssets = [];
|
|
20889
21474
|
const assetWarnings = [];
|
|
20890
21475
|
if (inlineAssets) {
|
|
@@ -20900,7 +21485,7 @@ function runPack(options = {}) {
|
|
|
20900
21485
|
for (const [platform, value] of Object.entries(map2)) {
|
|
20901
21486
|
if (typeof value !== "string" || !isRelativeAssetPath(value)) continue;
|
|
20902
21487
|
const assetPath = resolve5(bundleDir, value);
|
|
20903
|
-
if (!
|
|
21488
|
+
if (!existsSync9(assetPath)) {
|
|
20904
21489
|
assetWarnings.push(`${nodeId}/${platform}: asset not found at ${assetPath} \u2014 left as-is`);
|
|
20905
21490
|
continue;
|
|
20906
21491
|
}
|
|
@@ -20918,11 +21503,25 @@ function runPack(options = {}) {
|
|
|
20918
21503
|
mkdirSync4(dirname5(outPath), { recursive: true });
|
|
20919
21504
|
writeFileSync6(outPath, output);
|
|
20920
21505
|
}
|
|
20921
|
-
return {
|
|
21506
|
+
return {
|
|
21507
|
+
ok: true,
|
|
21508
|
+
bundlePath: filePath,
|
|
21509
|
+
outPath,
|
|
21510
|
+
journalIncluded,
|
|
21511
|
+
journalEventCount,
|
|
21512
|
+
inlinedAssets,
|
|
21513
|
+
assetWarnings,
|
|
21514
|
+
qualityFolded,
|
|
21515
|
+
qualityNotice,
|
|
21516
|
+
weighingFolded,
|
|
21517
|
+
weighingNotice,
|
|
21518
|
+
output
|
|
21519
|
+
};
|
|
20922
21520
|
}
|
|
20923
21521
|
function runPackCli(args) {
|
|
20924
21522
|
let noJournal = false;
|
|
20925
21523
|
let noQuality = false;
|
|
21524
|
+
let noWeighing = false;
|
|
20926
21525
|
let inlineAssets = false;
|
|
20927
21526
|
let audit;
|
|
20928
21527
|
let root;
|
|
@@ -20937,6 +21536,8 @@ function runPackCli(args) {
|
|
|
20937
21536
|
noJournal = true;
|
|
20938
21537
|
} else if (arg === "--no-quality") {
|
|
20939
21538
|
noQuality = true;
|
|
21539
|
+
} else if (arg === "--no-weighing") {
|
|
21540
|
+
noWeighing = true;
|
|
20940
21541
|
} else if (arg === "--inline-assets") {
|
|
20941
21542
|
inlineAssets = true;
|
|
20942
21543
|
} else if (arg === "--audit") {
|
|
@@ -20971,7 +21572,7 @@ ${USAGE7}`);
|
|
|
20971
21572
|
${USAGE7}`);
|
|
20972
21573
|
}
|
|
20973
21574
|
const filePath = positionals[0] ?? DEFAULT_BUNDLE_PATH6;
|
|
20974
|
-
const result = runPack({ path: filePath, out, noJournal, inlineAssets, noQuality, audit, root });
|
|
21575
|
+
const result = runPack({ path: filePath, out, noJournal, inlineAssets, noQuality, noWeighing, audit, root });
|
|
20975
21576
|
if (!result.ok) fail7(`FATAL: ${result.fatal}`);
|
|
20976
21577
|
if (result.journalIncluded) {
|
|
20977
21578
|
console.error(`Journal: embedded ${result.journalEventCount} event(s)`);
|
|
@@ -20983,6 +21584,9 @@ ${USAGE7}`);
|
|
|
20983
21584
|
if (result.qualityNotice !== void 0) {
|
|
20984
21585
|
console.error(result.qualityNotice);
|
|
20985
21586
|
}
|
|
21587
|
+
if (result.weighingNotice !== void 0) {
|
|
21588
|
+
console.error(result.weighingNotice);
|
|
21589
|
+
}
|
|
20986
21590
|
for (const asset of result.inlinedAssets) {
|
|
20987
21591
|
console.error(`Inlined asset: ${asset.nodeId}/${asset.platform} (${asset.path})`);
|
|
20988
21592
|
}
|
|
@@ -21001,7 +21605,7 @@ ${USAGE7}`);
|
|
|
21001
21605
|
import { spawn } from "node:child_process";
|
|
21002
21606
|
import { mkdtempSync, writeFileSync as writeFileSync7 } from "node:fs";
|
|
21003
21607
|
import { tmpdir } from "node:os";
|
|
21004
|
-
import { join as
|
|
21608
|
+
import { join as join7, resolve as resolve6 } from "node:path";
|
|
21005
21609
|
var DEFAULT_BUNDLE_PATH7 = "docs/arkaik/bundle.json";
|
|
21006
21610
|
var OPEN_URL = "https://arkaik.app/projects";
|
|
21007
21611
|
var USAGE8 = `arkaik open [--out <path>] [--no-open] [path]
|
|
@@ -21054,8 +21658,8 @@ async function runOpen(options = {}) {
|
|
|
21054
21658
|
}
|
|
21055
21659
|
let outPath = packed.outPath;
|
|
21056
21660
|
if (outPath === void 0) {
|
|
21057
|
-
const dir = mkdtempSync(
|
|
21058
|
-
outPath =
|
|
21661
|
+
const dir = mkdtempSync(join7(tmpdir(), "arkaik-open-"));
|
|
21662
|
+
outPath = join7(dir, "bundle.json");
|
|
21059
21663
|
writeFileSync7(outPath, packed.output);
|
|
21060
21664
|
}
|
|
21061
21665
|
let opened = false;
|
|
@@ -21131,7 +21735,8 @@ ${USAGE8}`);
|
|
|
21131
21735
|
import { resolve as resolve7 } from "node:path";
|
|
21132
21736
|
var DEFAULT_BUNDLE_PATH8 = "docs/arkaik/bundle.json";
|
|
21133
21737
|
var DEFAULT_API_BASE = "https://arkaik.app";
|
|
21134
|
-
var USAGE9 = `arkaik push [--include-journal] [--include-quality] [--
|
|
21738
|
+
var USAGE9 = `arkaik push [--include-journal] [--include-quality] [--include-weighing]
|
|
21739
|
+
[--api <base-url>] [path]
|
|
21135
21740
|
arkaik push --delete <id> --key <owner_key> [--api <base-url>]
|
|
21136
21741
|
|
|
21137
21742
|
Publish a project bundle to Publik (anonymous, account-less snapshot
|
|
@@ -21147,7 +21752,9 @@ knows to keep it.
|
|
|
21147
21752
|
|
|
21148
21753
|
A Kritik "quality" section is stripped by default too, and separately:
|
|
21149
21754
|
publishing your history and publishing your open findings are two decisions,
|
|
21150
|
-
not one, and both default to no. --include-quality opts in.
|
|
21755
|
+
not one, and both default to no. --include-quality opts in. A "weighing"
|
|
21756
|
+
section (a positioning and the assessments scored against it) is a third
|
|
21757
|
+
decision with a third default of no: --include-weighing opts in.
|
|
21151
21758
|
|
|
21152
21759
|
Snapshots are immutable: there is no update verb. Pushing again always mints
|
|
21153
21760
|
a new id. The owner key printed on success is shown exactly once and cannot
|
|
@@ -21168,6 +21775,11 @@ Options:
|
|
|
21168
21775
|
\xA7 8.3) \u2014 publishing that is a decision worth typing.
|
|
21169
21776
|
Default: deleted before packing, so it is never in the
|
|
21170
21777
|
request body at all.
|
|
21778
|
+
--include-weighing Embed the weighing section and forward
|
|
21779
|
+
?include_weighing=true. Opt-in: it holds what the
|
|
21780
|
+
product scores its own promises, costs included.
|
|
21781
|
+
Default: deleted before packing, so it is never in
|
|
21782
|
+
the request body at all.
|
|
21171
21783
|
--api <base-url> Publik API base URL (default: ${DEFAULT_API_BASE}).
|
|
21172
21784
|
Point at a self-hosted deployment.
|
|
21173
21785
|
--delete <id> Delete a snapshot by id instead of pushing. Requires
|
|
@@ -21195,6 +21807,7 @@ async function runPush(options = {}) {
|
|
|
21195
21807
|
const filePath = resolve7(cwd, options.path ?? DEFAULT_BUNDLE_PATH8);
|
|
21196
21808
|
const includeJournal = options.includeJournal ?? false;
|
|
21197
21809
|
const includeQuality = options.includeQuality ?? false;
|
|
21810
|
+
const includeWeighing = options.includeWeighing ?? false;
|
|
21198
21811
|
const apiBase = options.apiBase ?? DEFAULT_API_BASE;
|
|
21199
21812
|
const httpClient = options.httpClient ?? DEFAULT_HTTP_CLIENT;
|
|
21200
21813
|
let v;
|
|
@@ -21208,7 +21821,13 @@ async function runPush(options = {}) {
|
|
|
21208
21821
|
if (!v.valid) {
|
|
21209
21822
|
return { ok: true, bundlePath: filePath, valid: false, errorLines, warningLines, requestSent: false };
|
|
21210
21823
|
}
|
|
21211
|
-
const packed = runPack({
|
|
21824
|
+
const packed = runPack({
|
|
21825
|
+
path: filePath,
|
|
21826
|
+
noJournal: !includeJournal,
|
|
21827
|
+
noQuality: !includeQuality,
|
|
21828
|
+
noWeighing: !includeWeighing,
|
|
21829
|
+
cwd
|
|
21830
|
+
});
|
|
21212
21831
|
if (!packed.ok) {
|
|
21213
21832
|
return fatalResult4(filePath, packed.fatal ?? "pack failed");
|
|
21214
21833
|
}
|
|
@@ -21216,6 +21835,7 @@ async function runPush(options = {}) {
|
|
|
21216
21835
|
const params = [];
|
|
21217
21836
|
if (includeJournal) params.push("include_journal=true");
|
|
21218
21837
|
if (includeQuality) params.push("include_quality=true");
|
|
21838
|
+
if (includeWeighing) params.push("include_weighing=true");
|
|
21219
21839
|
const url2 = `${apiBase}/api/publik${params.length > 0 ? `?${params.join("&")}` : ""}`;
|
|
21220
21840
|
let res;
|
|
21221
21841
|
try {
|
|
@@ -21361,6 +21981,7 @@ function reportDelete(id, result) {
|
|
|
21361
21981
|
function runPushCli(args) {
|
|
21362
21982
|
let includeJournal = false;
|
|
21363
21983
|
let includeQuality = false;
|
|
21984
|
+
let includeWeighing = false;
|
|
21364
21985
|
let apiBase;
|
|
21365
21986
|
let deleteId;
|
|
21366
21987
|
let key;
|
|
@@ -21374,6 +21995,8 @@ function runPushCli(args) {
|
|
|
21374
21995
|
includeJournal = true;
|
|
21375
21996
|
} else if (arg === "--include-quality") {
|
|
21376
21997
|
includeQuality = true;
|
|
21998
|
+
} else if (arg === "--include-weighing") {
|
|
21999
|
+
includeWeighing = true;
|
|
21377
22000
|
} else if (arg === "--api") {
|
|
21378
22001
|
const value = args[++i];
|
|
21379
22002
|
if (value === void 0) fail9(`Missing value for --api
|
|
@@ -21416,7 +22039,7 @@ ${USAGE9}`);
|
|
|
21416
22039
|
|
|
21417
22040
|
${USAGE9}`);
|
|
21418
22041
|
const filePath = positionals[0] ?? DEFAULT_BUNDLE_PATH8;
|
|
21419
|
-
runPush({ path: filePath, includeJournal, includeQuality, apiBase }).then((result) => {
|
|
22042
|
+
runPush({ path: filePath, includeJournal, includeQuality, includeWeighing, apiBase }).then((result) => {
|
|
21420
22043
|
if (!result.ok) fail9(`FATAL: ${result.fatal}`);
|
|
21421
22044
|
reportPush(result);
|
|
21422
22045
|
}).catch((e) => fail9(`FATAL: ${e.message}`));
|
|
@@ -21424,7 +22047,7 @@ ${USAGE9}`);
|
|
|
21424
22047
|
|
|
21425
22048
|
// src/commands/link.ts
|
|
21426
22049
|
import { mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
21427
|
-
import { dirname as dirname6, join as
|
|
22050
|
+
import { dirname as dirname6, join as join8, resolve as resolve8 } from "node:path";
|
|
21428
22051
|
var LINK_FILE = "docs/arkaik/arkaik.json";
|
|
21429
22052
|
var DEFAULT_BASE_URL = "https://arkaik.app";
|
|
21430
22053
|
var USAGE10 = `arkaik link \u2014 point this repo at a hosted Arkaik project
|
|
@@ -21496,7 +22119,7 @@ async function runLink(argv, options = {}) {
|
|
|
21496
22119
|
}
|
|
21497
22120
|
const { bundle } = await res.json();
|
|
21498
22121
|
const target = resolve8(cwd, argv.find((a) => !a.startsWith("--") && a !== projectId && a !== baseUrl) ?? ".");
|
|
21499
|
-
const linkPath =
|
|
22122
|
+
const linkPath = join8(target, LINK_FILE);
|
|
21500
22123
|
mkdirSync5(dirname6(linkPath), { recursive: true });
|
|
21501
22124
|
let existing = {};
|
|
21502
22125
|
try {
|
|
@@ -21531,7 +22154,7 @@ function runLinkCli(argv) {
|
|
|
21531
22154
|
|
|
21532
22155
|
// src/commands/live.ts
|
|
21533
22156
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
21534
|
-
import { join as
|
|
22157
|
+
import { join as join9, resolve as resolve9 } from "node:path";
|
|
21535
22158
|
var LINK_FILE2 = "docs/arkaik/arkaik.json";
|
|
21536
22159
|
var DEFAULT_BASE_URL2 = "https://arkaik.app";
|
|
21537
22160
|
var MAX_ENTRIES_PER_REQUEST = 50;
|
|
@@ -21665,7 +22288,7 @@ async function runLive(argv, options = {}) {
|
|
|
21665
22288
|
const mentionsFile = flagValue2(argv, "--mentions");
|
|
21666
22289
|
const paths = (flagValue2(argv, "--paths") ?? "").split(",").map((p) => p.trim()).filter(Boolean);
|
|
21667
22290
|
const dryRun = argv.includes("--dry-run");
|
|
21668
|
-
const linkPath =
|
|
22291
|
+
const linkPath = join9(cwd, LINK_FILE2);
|
|
21669
22292
|
let link;
|
|
21670
22293
|
try {
|
|
21671
22294
|
link = JSON.parse(readFileSync9(linkPath, "utf8"));
|
|
@@ -21790,8 +22413,8 @@ function runLiveCli(argv) {
|
|
|
21790
22413
|
}
|
|
21791
22414
|
|
|
21792
22415
|
// src/commands/shot.ts
|
|
21793
|
-
import { existsSync as
|
|
21794
|
-
import { join as
|
|
22416
|
+
import { existsSync as existsSync10, readFileSync as readFileSync10, writeFileSync as writeFileSync9 } from "node:fs";
|
|
22417
|
+
import { join as join10, resolve as resolve10 } from "node:path";
|
|
21795
22418
|
var LINK_FILE3 = "docs/arkaik/arkaik.json";
|
|
21796
22419
|
var DEFAULT_BUNDLE_PATH9 = "docs/arkaik/bundle.json";
|
|
21797
22420
|
var DEFAULT_BASE_URL3 = "https://arkaik.app";
|
|
@@ -21926,8 +22549,8 @@ async function runShot(argv, options = {}) {
|
|
|
21926
22549
|
return { ok: false };
|
|
21927
22550
|
}
|
|
21928
22551
|
}
|
|
21929
|
-
const linkPath =
|
|
21930
|
-
if (
|
|
22552
|
+
const linkPath = join10(cwd, LINK_FILE3);
|
|
22553
|
+
if (existsSync10(linkPath)) {
|
|
21931
22554
|
return runHosted({ entries, commit, order, dryRun, linkPath, argv, env, doFetch, log, errorLog });
|
|
21932
22555
|
}
|
|
21933
22556
|
return runKommit({ entries, commit, order, dryRun, cwd, argv, log, errorLog });
|
|
@@ -22071,8 +22694,8 @@ function runShotCli(argv) {
|
|
|
22071
22694
|
}
|
|
22072
22695
|
|
|
22073
22696
|
// src/commands/restore.ts
|
|
22074
|
-
import { existsSync as
|
|
22075
|
-
import { join as
|
|
22697
|
+
import { existsSync as existsSync11, linkSync, mkdirSync as mkdirSync6, readFileSync as readFileSync11, unlinkSync, writeFileSync as writeFileSync10 } from "node:fs";
|
|
22698
|
+
import { join as join11, resolve as resolve11 } from "node:path";
|
|
22076
22699
|
var LINK_FILE4 = "docs/arkaik/arkaik.json";
|
|
22077
22700
|
var DEFAULT_BUNDLE_PATH10 = "docs/arkaik/bundle.json";
|
|
22078
22701
|
var DEFAULT_API_BASE2 = "https://arkaik.app";
|
|
@@ -22118,11 +22741,27 @@ Options:
|
|
|
22118
22741
|
one \u2014 that needs --allow-quality-loss too, because
|
|
22119
22742
|
"don't send mine" and "destroy theirs" are different
|
|
22120
22743
|
decisions and only one of them is irreversible.
|
|
22744
|
+
--no-weighing Do not send a weighing section: skip the docs/weighing/
|
|
22745
|
+
fold AND drop any section the local bundle already
|
|
22746
|
+
carries. WARNING: a restore replaces the hosted
|
|
22747
|
+
journal, and an assessment recorded only on the hosted
|
|
22748
|
+
project lives in that journal. The history guard
|
|
22749
|
+
compares COUNTS, so it does NOT reliably protect those
|
|
22750
|
+
events: a repo whose journal is as long as the hosted
|
|
22751
|
+
one passes it while still erasing them. The backup this
|
|
22752
|
+
command writes first holds them; the proper fix is
|
|
22753
|
+
issue #624 (restore appends by default).
|
|
22121
22754
|
--allow-quality-loss Proceed even though the restore would erase a quality
|
|
22122
22755
|
section the hosted project currently has. Without this
|
|
22123
22756
|
flag, that refuses outright \u2014 it usually means
|
|
22124
22757
|
docs/quality/ was looked for in the wrong place, which
|
|
22125
22758
|
--root fixes, rather than an intended wipe.
|
|
22759
|
+
--allow-metadata-loss Proceed even though the local bundle's project.metadata
|
|
22760
|
+
lacks settings the hosted project has (products, maps,
|
|
22761
|
+
ref_policy, pollen, ...). Without this flag, that
|
|
22762
|
+
refuses outright and names the keys \u2014 those settings
|
|
22763
|
+
are usually edited in the app and never reach the
|
|
22764
|
+
repo bundle, so a restore would silently delete them.
|
|
22126
22765
|
--audit <id> Fold ONE audit's snapshot rather than merging every
|
|
22127
22766
|
audit into current state. An id that is not on disk is
|
|
22128
22767
|
an error, not an empty section.
|
|
@@ -22296,7 +22935,7 @@ function describeQualityLoss(hostedQuality, qualityRoot, noQuality, foldNotice)
|
|
|
22296
22935
|
lines.push("The outbound bundle has no section because the fold found nothing to build one from:");
|
|
22297
22936
|
lines.push(` ${foldNotice}`);
|
|
22298
22937
|
}
|
|
22299
|
-
if (!
|
|
22938
|
+
if (!existsSync11(join11(qualityRoot, QUALITY_DIR))) {
|
|
22300
22939
|
lines.push(
|
|
22301
22940
|
`There is no ${QUALITY_DIR}/ under ${qualityRoot} at all. If this project's sidecars live somewhere else, point --root at that repo and the section is rebuilt rather than removed.`
|
|
22302
22941
|
);
|
|
@@ -22305,6 +22944,21 @@ function describeQualityLoss(hostedQuality, qualityRoot, noQuality, foldNotice)
|
|
|
22305
22944
|
}
|
|
22306
22945
|
return lines.join("\n");
|
|
22307
22946
|
}
|
|
22947
|
+
function droppedMetadataKeys(hostedProject, outboundProject) {
|
|
22948
|
+
const metadataOf = (project) => {
|
|
22949
|
+
if (typeof project !== "object" || project === null || Array.isArray(project)) return {};
|
|
22950
|
+
const metadata = project.metadata;
|
|
22951
|
+
return typeof metadata === "object" && metadata !== null && !Array.isArray(metadata) ? metadata : {};
|
|
22952
|
+
};
|
|
22953
|
+
const outbound = metadataOf(outboundProject);
|
|
22954
|
+
return Object.keys(metadataOf(hostedProject)).filter((key) => !(key in outbound)).sort();
|
|
22955
|
+
}
|
|
22956
|
+
function describeMetadataLoss(dropped, bundlePath) {
|
|
22957
|
+
return [
|
|
22958
|
+
`This restore would DELETE ${dropped.length} hosted project setting${dropped.length === 1 ? "" : "s"} (project.metadata: ${dropped.join(", ")}) that ${bundlePath} does not carry. Nothing was sent.`,
|
|
22959
|
+
`Those settings are usually edited in the app and never reach the repo bundle. Copy them into the local bundle's project.metadata (GET .../export has them) so the restore keeps them, or re-run with --allow-metadata-loss if they really are meant to go.`
|
|
22960
|
+
].join("\n");
|
|
22961
|
+
}
|
|
22308
22962
|
async function runRestore(options = {}) {
|
|
22309
22963
|
const cwd = options.cwd ?? process.cwd();
|
|
22310
22964
|
const env = options.env ?? process.env;
|
|
@@ -22312,10 +22966,12 @@ async function runRestore(options = {}) {
|
|
|
22312
22966
|
const allowHistoryLoss = options.allowHistoryLoss ?? false;
|
|
22313
22967
|
const allowDeletions = options.allowDeletions ?? false;
|
|
22314
22968
|
const noQuality = options.noQuality ?? false;
|
|
22969
|
+
const noWeighing = options.noWeighing ?? false;
|
|
22315
22970
|
const allowQualityLoss = options.allowQualityLoss ?? false;
|
|
22971
|
+
const allowMetadataLoss = options.allowMetadataLoss ?? false;
|
|
22316
22972
|
const httpClient = options.httpClient ?? DEFAULT_HTTP_CLIENT;
|
|
22317
|
-
const linkPath =
|
|
22318
|
-
if (!
|
|
22973
|
+
const linkPath = join11(cwd, LINK_FILE4);
|
|
22974
|
+
if (!existsSync11(linkPath)) {
|
|
22319
22975
|
return fatalResult5(dryRun, `No ${LINK_FILE4}. Run \`arkaik link\` first \u2014 restore only targets hosted projects.`);
|
|
22320
22976
|
}
|
|
22321
22977
|
let link;
|
|
@@ -22331,7 +22987,7 @@ async function runRestore(options = {}) {
|
|
|
22331
22987
|
const token = env.ARKAIK_TOKEN;
|
|
22332
22988
|
if (!token) return fatalResult5(dryRun, `ARKAIK_TOKEN is not set. Create a token at ${baseUrl}/settings/tokens and export it.`);
|
|
22333
22989
|
const bundlePath = resolve11(cwd, options.path ?? DEFAULT_BUNDLE_PATH10);
|
|
22334
|
-
if (!
|
|
22990
|
+
if (!existsSync11(bundlePath)) return fatalResult5(dryRun, `No bundle at ${bundlePath}. Run \`arkaik merge\` (or \`arkaik pack\`) first.`);
|
|
22335
22991
|
let localRaw;
|
|
22336
22992
|
try {
|
|
22337
22993
|
localRaw = JSON.parse(readFileSync11(bundlePath, "utf8"));
|
|
@@ -22360,6 +23016,15 @@ async function runRestore(options = {}) {
|
|
|
22360
23016
|
}
|
|
22361
23017
|
}
|
|
22362
23018
|
const qualityFields = { qualityFolded, qualityNotice };
|
|
23019
|
+
if (noWeighing) {
|
|
23020
|
+
delete outboundBundle.weighing;
|
|
23021
|
+
} else {
|
|
23022
|
+
try {
|
|
23023
|
+
foldWeighingSection(outboundBundle, qualityRoot);
|
|
23024
|
+
} catch (e) {
|
|
23025
|
+
return fatalResult5(dryRun, e.message);
|
|
23026
|
+
}
|
|
23027
|
+
}
|
|
22363
23028
|
const headers = { Authorization: `Bearer ${token}` };
|
|
22364
23029
|
let version2;
|
|
22365
23030
|
try {
|
|
@@ -22423,14 +23088,18 @@ async function runRestore(options = {}) {
|
|
|
22423
23088
|
if (isQualitySection(hostedQuality) && !isQualitySection(outboundBundle.quality) && !allowQualityLoss) {
|
|
22424
23089
|
return fatalResult5(dryRun, describeQualityLoss(hostedQuality, qualityRoot, noQuality, qualityNotice), qualityFields);
|
|
22425
23090
|
}
|
|
23091
|
+
const droppedKeys = droppedMetadataKeys(exportedBundle.project, outboundBundle.project);
|
|
23092
|
+
if (droppedKeys.length > 0 && !allowMetadataLoss) {
|
|
23093
|
+
return fatalResult5(dryRun, describeMetadataLoss(droppedKeys, bundlePath), qualityFields);
|
|
23094
|
+
}
|
|
22426
23095
|
const removedNodes = removedIds(exportedBundle.nodes, Array.isArray(local.nodes) ? local.nodes : []);
|
|
22427
23096
|
const removedEdges = removedIds(exportedBundle.edges, Array.isArray(local.edges) ? local.edges : []);
|
|
22428
23097
|
if ((removedNodes.length > 0 || removedEdges.length > 0) && !allowDeletions) {
|
|
22429
23098
|
return fatalResult5(dryRun, describeDeletions(removedNodes, removedEdges, bundlePath), qualityFields);
|
|
22430
23099
|
}
|
|
22431
|
-
const backupDir =
|
|
23100
|
+
const backupDir = join11(cwd, "docs", "arkaik", ".backups");
|
|
22432
23101
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
22433
|
-
const backupPath =
|
|
23102
|
+
const backupPath = join11(backupDir, `${stamp}-bundle.json`);
|
|
22434
23103
|
const backupContent = `${JSON.stringify(exported, null, 2)}
|
|
22435
23104
|
`;
|
|
22436
23105
|
try {
|
|
@@ -22505,7 +23174,7 @@ function reportRestore(result) {
|
|
|
22505
23174
|
console.log("[dry-run] server preview \u2014 nothing was written:");
|
|
22506
23175
|
printDelta(result.delta);
|
|
22507
23176
|
console.log(
|
|
22508
|
-
"Re-run without --dry-run to apply \u2014 that run takes the backup, and only that run checks the history, deletion and
|
|
23177
|
+
"Re-run without --dry-run to apply \u2014 that run takes the backup, and only that run checks the history, deletion, quality-loss and metadata-loss guards (all four read the export, which a dry run never fetches)."
|
|
22509
23178
|
);
|
|
22510
23179
|
} else {
|
|
22511
23180
|
console.log(`Restored. New version ${result.version}.`);
|
|
@@ -22528,7 +23197,9 @@ function runRestoreCli(argv) {
|
|
|
22528
23197
|
let allowHistoryLoss = false;
|
|
22529
23198
|
let allowDeletions = false;
|
|
22530
23199
|
let noQuality = false;
|
|
23200
|
+
let noWeighing = false;
|
|
22531
23201
|
let allowQualityLoss = false;
|
|
23202
|
+
let allowMetadataLoss = false;
|
|
22532
23203
|
let audit;
|
|
22533
23204
|
let root;
|
|
22534
23205
|
let apiBase;
|
|
@@ -22547,8 +23218,12 @@ function runRestoreCli(argv) {
|
|
|
22547
23218
|
allowDeletions = true;
|
|
22548
23219
|
} else if (arg === "--no-quality") {
|
|
22549
23220
|
noQuality = true;
|
|
23221
|
+
} else if (arg === "--no-weighing") {
|
|
23222
|
+
noWeighing = true;
|
|
22550
23223
|
} else if (arg === "--allow-quality-loss") {
|
|
22551
23224
|
allowQualityLoss = true;
|
|
23225
|
+
} else if (arg === "--allow-metadata-loss") {
|
|
23226
|
+
allowMetadataLoss = true;
|
|
22552
23227
|
} else if (arg === "--audit") {
|
|
22553
23228
|
const value = argv[++i];
|
|
22554
23229
|
if (value === void 0) fail10(`Missing value for --audit
|
|
@@ -22583,21 +23258,33 @@ ${USAGE13}`);
|
|
|
22583
23258
|
|
|
22584
23259
|
${USAGE13}`);
|
|
22585
23260
|
}
|
|
22586
|
-
runRestore({
|
|
23261
|
+
runRestore({
|
|
23262
|
+
path: positionals[0],
|
|
23263
|
+
dryRun,
|
|
23264
|
+
allowHistoryLoss,
|
|
23265
|
+
allowDeletions,
|
|
23266
|
+
noQuality,
|
|
23267
|
+
noWeighing,
|
|
23268
|
+
allowQualityLoss,
|
|
23269
|
+
allowMetadataLoss,
|
|
23270
|
+
audit,
|
|
23271
|
+
root,
|
|
23272
|
+
apiBase
|
|
23273
|
+
}).then((result) => reportRestore(result)).catch((e) => fail10(`FATAL: ${e.message}`));
|
|
22587
23274
|
}
|
|
22588
23275
|
|
|
22589
23276
|
// src/commands/bootstrap.ts
|
|
22590
23277
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
22591
|
-
import { existsSync as
|
|
23278
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync8, renameSync, writeFileSync as writeFileSync14 } from "node:fs";
|
|
22592
23279
|
import path5 from "node:path";
|
|
22593
23280
|
|
|
22594
23281
|
// src/lib/bootstrap/corpus.ts
|
|
22595
23282
|
import { spawnSync } from "node:child_process";
|
|
22596
|
-
import { existsSync as
|
|
23283
|
+
import { existsSync as existsSync13, readdirSync as readdirSync4, readFileSync as readFileSync13, writeFileSync as writeFileSync12 } from "node:fs";
|
|
22597
23284
|
import path2 from "node:path";
|
|
22598
23285
|
|
|
22599
23286
|
// src/lib/bootstrap/paths.ts
|
|
22600
|
-
import { existsSync as
|
|
23287
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync7, readFileSync as readFileSync12, writeFileSync as writeFileSync11 } from "node:fs";
|
|
22601
23288
|
import path from "node:path";
|
|
22602
23289
|
var BOOTSTRAP_ROOT = ".arkaik";
|
|
22603
23290
|
var CORPUS_DIR = ".arkaik/corpus";
|
|
@@ -22617,7 +23304,7 @@ function ensureDir(dirPath) {
|
|
|
22617
23304
|
function ensureGitignored(cwd) {
|
|
22618
23305
|
const file2 = path.join(cwd, ".gitignore");
|
|
22619
23306
|
const line2 = `${BOOTSTRAP_ROOT}/`;
|
|
22620
|
-
const current =
|
|
23307
|
+
const current = existsSync12(file2) ? readFileSync12(file2, "utf8") : "";
|
|
22621
23308
|
const ignored = current.split("\n").map((l) => l.trim()).some((l) => l === line2 || l === BOOTSTRAP_ROOT);
|
|
22622
23309
|
if (ignored) return false;
|
|
22623
23310
|
const prefix = current.length > 0 && !current.endsWith("\n") ? "\n" : "";
|
|
@@ -22718,7 +23405,7 @@ function fetchPrsViaGit(cwd) {
|
|
|
22718
23405
|
function walk(root, cwd, out) {
|
|
22719
23406
|
let entries;
|
|
22720
23407
|
try {
|
|
22721
|
-
entries =
|
|
23408
|
+
entries = readdirSync4(root, { withFileTypes: true });
|
|
22722
23409
|
} catch {
|
|
22723
23410
|
return;
|
|
22724
23411
|
}
|
|
@@ -22781,12 +23468,12 @@ function buildCorpus(options) {
|
|
|
22781
23468
|
}
|
|
22782
23469
|
function readCorpusPrs(cwd) {
|
|
22783
23470
|
const file2 = at(cwd, PRS_FILE);
|
|
22784
|
-
if (!
|
|
23471
|
+
if (!existsSync13(file2)) return [];
|
|
22785
23472
|
return readFileSync13(file2, "utf8").split("\n").filter(Boolean).map((line2) => JSON.parse(line2));
|
|
22786
23473
|
}
|
|
22787
23474
|
|
|
22788
23475
|
// src/lib/bootstrap/fragments.ts
|
|
22789
|
-
import { existsSync as
|
|
23476
|
+
import { existsSync as existsSync14, readFileSync as readFileSync14 } from "node:fs";
|
|
22790
23477
|
import path3 from "node:path";
|
|
22791
23478
|
function isArrayOfObjects(value) {
|
|
22792
23479
|
return value === void 0 || Array.isArray(value) && value.every((v) => typeof v === "object" && v !== null && !Array.isArray(v));
|
|
@@ -22812,7 +23499,7 @@ function loadFragments(cwd, manifest) {
|
|
|
22812
23499
|
problems.push({ unit: String(unit2.id), message: err instanceof Error ? err.message : String(err) });
|
|
22813
23500
|
continue;
|
|
22814
23501
|
}
|
|
22815
|
-
if (!
|
|
23502
|
+
if (!existsSync14(file2)) {
|
|
22816
23503
|
missing.push(unit2.id);
|
|
22817
23504
|
continue;
|
|
22818
23505
|
}
|
|
@@ -22855,7 +23542,7 @@ function renderIndex(bundle) {
|
|
|
22855
23542
|
}
|
|
22856
23543
|
|
|
22857
23544
|
// src/lib/bootstrap/manifest.ts
|
|
22858
|
-
import { existsSync as
|
|
23545
|
+
import { existsSync as existsSync15, readFileSync as readFileSync15, writeFileSync as writeFileSync13 } from "node:fs";
|
|
22859
23546
|
import path4 from "node:path";
|
|
22860
23547
|
|
|
22861
23548
|
// src/lib/bootstrap/era-window.ts
|
|
@@ -22964,7 +23651,7 @@ function assertValidProfile(profile) {
|
|
|
22964
23651
|
// src/lib/bootstrap/manifest.ts
|
|
22965
23652
|
function readProfile(cwd) {
|
|
22966
23653
|
const file2 = at(cwd, PROFILE_FILE2);
|
|
22967
|
-
if (!
|
|
23654
|
+
if (!existsSync15(file2)) return null;
|
|
22968
23655
|
try {
|
|
22969
23656
|
return JSON.parse(readFileSync15(file2, "utf8"));
|
|
22970
23657
|
} catch (err) {
|
|
@@ -22973,7 +23660,7 @@ function readProfile(cwd) {
|
|
|
22973
23660
|
}
|
|
22974
23661
|
function readManifest2(cwd) {
|
|
22975
23662
|
const file2 = at(cwd, MANIFEST_FILE);
|
|
22976
|
-
if (!
|
|
23663
|
+
if (!existsSync15(file2)) return null;
|
|
22977
23664
|
try {
|
|
22978
23665
|
return JSON.parse(readFileSync15(file2, "utf8"));
|
|
22979
23666
|
} catch (err) {
|
|
@@ -22988,7 +23675,7 @@ function writeManifest(cwd, manifest) {
|
|
|
22988
23675
|
}
|
|
22989
23676
|
function detectMode(cwd, bundlePath) {
|
|
22990
23677
|
const file2 = path4.resolve(cwd, bundlePath);
|
|
22991
|
-
if (!
|
|
23678
|
+
if (!existsSync15(file2)) return "greenfield";
|
|
22992
23679
|
let parsed;
|
|
22993
23680
|
try {
|
|
22994
23681
|
parsed = JSON.parse(readFileSync15(file2, "utf8"));
|
|
@@ -23444,7 +24131,7 @@ function mergeFragments(input) {
|
|
|
23444
24131
|
}
|
|
23445
24132
|
|
|
23446
24133
|
// src/lib/bootstrap/slice.ts
|
|
23447
|
-
import { existsSync as
|
|
24134
|
+
import { existsSync as existsSync16, readFileSync as readFileSync16 } from "node:fs";
|
|
23448
24135
|
|
|
23449
24136
|
// src/lib/bootstrap/body-budget.ts
|
|
23450
24137
|
var LAB_NOTE_HEADING_RE = /^##\s+Lab Note.*$/m;
|
|
@@ -23486,7 +24173,7 @@ function boundBody(body) {
|
|
|
23486
24173
|
|
|
23487
24174
|
// src/lib/bootstrap/slice.ts
|
|
23488
24175
|
function readJsonArray(file2) {
|
|
23489
|
-
if (!
|
|
24176
|
+
if (!existsSync16(file2)) return [];
|
|
23490
24177
|
const parsed = JSON.parse(readFileSync16(file2, "utf8"));
|
|
23491
24178
|
return Array.isArray(parsed) ? parsed : [];
|
|
23492
24179
|
}
|
|
@@ -23632,7 +24319,7 @@ ${CORPUS_USAGE}`);
|
|
|
23632
24319
|
${CORPUS_USAGE}`);
|
|
23633
24320
|
}
|
|
23634
24321
|
}
|
|
23635
|
-
if (!
|
|
24322
|
+
if (!existsSync17(path5.join(cwd, ".git"))) {
|
|
23636
24323
|
fail11("`arkaik bootstrap corpus` must run from the repository root (no .git here).");
|
|
23637
24324
|
}
|
|
23638
24325
|
try {
|
|
@@ -23694,7 +24381,7 @@ ${PLAN_USAGE}`);
|
|
|
23694
24381
|
|
|
23695
24382
|
${PLAN_USAGE}`);
|
|
23696
24383
|
}
|
|
23697
|
-
if (!
|
|
24384
|
+
if (!existsSync17(path5.join(cwd, ".git"))) {
|
|
23698
24385
|
fail11("`arkaik bootstrap plan` must run from the repository root (no .git here).");
|
|
23699
24386
|
}
|
|
23700
24387
|
try {
|
|
@@ -23833,7 +24520,7 @@ ${MERGE_USAGE}`);
|
|
|
23833
24520
|
}
|
|
23834
24521
|
try {
|
|
23835
24522
|
const bundlePath = path5.resolve(cwd, manifest.bundle);
|
|
23836
|
-
const base =
|
|
24523
|
+
const base = existsSync17(bundlePath) ? readBundle(bundlePath) : {
|
|
23837
24524
|
schema_version: 3,
|
|
23838
24525
|
project: {
|
|
23839
24526
|
id: path5.basename(cwd),
|
|
@@ -24048,17 +24735,17 @@ Pass --domain-name "<display name>" to define it, or use an existing domain code
|
|
|
24048
24735
|
|
|
24049
24736
|
// ../schema/src/cli/kritik-plan.ts
|
|
24050
24737
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
24051
|
-
import { existsSync as
|
|
24052
|
-
import { join as
|
|
24053
|
-
var plansDir = (root) =>
|
|
24054
|
-
var planPath = (root, planId2) =>
|
|
24738
|
+
import { existsSync as existsSync18, readdirSync as readdirSync5, statSync as statSync2 } from "node:fs";
|
|
24739
|
+
import { join as join12 } from "node:path";
|
|
24740
|
+
var plansDir = (root) => join12(root, QUALITY_DIR, PLAN_PLANS_DIR);
|
|
24741
|
+
var planPath = (root, planId2) => join12(plansDir(root), `${planId2}.json`);
|
|
24055
24742
|
function listPlanIds(root) {
|
|
24056
24743
|
const dir = plansDir(root);
|
|
24057
|
-
if (!
|
|
24058
|
-
return
|
|
24744
|
+
if (!existsSync18(dir)) return [];
|
|
24745
|
+
return readdirSync5(dir).filter((name) => name.endsWith(".json") && statSync2(join12(dir, name)).isFile()).map((name) => name.slice(0, -".json".length)).filter((id) => isPlanId(id)).sort();
|
|
24059
24746
|
}
|
|
24060
24747
|
function readPlanFile(path6) {
|
|
24061
|
-
if (!
|
|
24748
|
+
if (!existsSync18(path6)) throw new Error(`no plan at ${path6}`);
|
|
24062
24749
|
const parsed = parseKritikPlan(readJson(path6));
|
|
24063
24750
|
if (!parsed.ok) throw new Error(`${path6}: ${parsed.issue}`);
|
|
24064
24751
|
return parsed.plan;
|
|
@@ -24224,7 +24911,7 @@ Record each first, or remove its scores (docs/quality/audits/<id>/scores.json),
|
|
|
24224
24911
|
}
|
|
24225
24912
|
|
|
24226
24913
|
// src/commands/kritik.ts
|
|
24227
|
-
import { existsSync as
|
|
24914
|
+
import { existsSync as existsSync19, readFileSync as readFileSync17 } from "node:fs";
|
|
24228
24915
|
import { resolve as resolve12 } from "node:path";
|
|
24229
24916
|
var USAGE15 = `arkaik kritik <subcommand> [options]
|
|
24230
24917
|
|
|
@@ -24486,7 +25173,7 @@ function collect(args, repeatable = [], boolean4 = []) {
|
|
|
24486
25173
|
function textOrFile(value) {
|
|
24487
25174
|
if (!value.startsWith("@")) return value;
|
|
24488
25175
|
const path6 = value.slice(1);
|
|
24489
|
-
if (!
|
|
25176
|
+
if (!existsSync19(path6)) fail12(`kritik: no file at ${path6}`);
|
|
24490
25177
|
return readFileSync17(path6, "utf8").trim();
|
|
24491
25178
|
}
|
|
24492
25179
|
function currentAuditId() {
|
|
@@ -24625,7 +25312,7 @@ ${PROFILE_USAGE}`);
|
|
|
24625
25312
|
weights[code] = value;
|
|
24626
25313
|
}
|
|
24627
25314
|
const path6 = profilePath(common.root);
|
|
24628
|
-
if (
|
|
25315
|
+
if (existsSync19(path6) && !flags.has("force")) {
|
|
24629
25316
|
fail12(
|
|
24630
25317
|
`kritik: ${path6} already exists.
|
|
24631
25318
|
Changing the surface list invalidates every score recorded against the old one, so this refuses by default.
|
|
@@ -25732,10 +26419,10 @@ ${PLAN_USAGE2}`);
|
|
|
25732
26419
|
const target = single.out ?? home;
|
|
25733
26420
|
let written = null;
|
|
25734
26421
|
if (!flags.has("dry-run")) {
|
|
25735
|
-
if (single.out !== void 0 &&
|
|
26422
|
+
if (single.out !== void 0 && existsSync19(target)) {
|
|
25736
26423
|
fail12(`kritik: ${target} already exists \u2014 a plan file is written once. Pick another --out.`);
|
|
25737
26424
|
}
|
|
25738
|
-
if (
|
|
26425
|
+
if (existsSync19(target)) {
|
|
25739
26426
|
fail12(`kritik: ${target} already exists \u2014 a plan file is written once, and another plan took ${plan.planId} meanwhile. Run the command again for the next id.`);
|
|
25740
26427
|
}
|
|
25741
26428
|
savePlan(target, plan);
|
|
@@ -25825,7 +26512,7 @@ ${CRITERION_USAGE}`);
|
|
|
25825
26512
|
let criterion;
|
|
25826
26513
|
try {
|
|
25827
26514
|
if (single.from !== void 0) {
|
|
25828
|
-
if (!
|
|
26515
|
+
if (!existsSync19(single.from)) fail12(`kritik: no file at ${single.from}`);
|
|
25829
26516
|
criterion = JSON.parse(readFileSync17(single.from, "utf8"));
|
|
25830
26517
|
} else {
|
|
25831
26518
|
const anchors = {};
|
|
@@ -25947,7 +26634,7 @@ Options:
|
|
|
25947
26634
|
-v, --version Print the version.
|
|
25948
26635
|
|
|
25949
26636
|
Run "arkaik <command> --help" for command-specific help.`;
|
|
25950
|
-
var VERSION = "0.
|
|
26637
|
+
var VERSION = "0.12.0";
|
|
25951
26638
|
function main(argv) {
|
|
25952
26639
|
const [command, ...rest] = argv;
|
|
25953
26640
|
if (command === void 0 || command === "--help" || command === "-h" || command === "help") {
|