@primitive.ai/prim 0.1.0-alpha.70 → 0.1.0-alpha.72
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/hook-runtime/index.js +34 -4
- package/dist/index.js +34 -4
- package/package.json +1 -1
|
@@ -32185,7 +32185,6 @@ var API_KEY_ID = /^api_key_[A-Za-z0-9_-]+$/u;
|
|
|
32185
32185
|
var API_KEY_NAME = /^[\x21-\x7e](?:[\x20-\x7e]{0,126}[\x21-\x7e])?$/u;
|
|
32186
32186
|
var API_KEY_PERMISSION = /^[\x21-\x7e]+$/u;
|
|
32187
32187
|
var API_KEY_SECRET = /^sk_[\x21-\x7e]+(?: [\x21-\x7e]+)*$/u;
|
|
32188
|
-
var API_KEY_OBFUSCATED_VALUE = /^[\x20-\x7e]+$/u;
|
|
32189
32188
|
var MINT_PATH = "/api/cli/auth/api-keys";
|
|
32190
32189
|
var REQUEST_ID = /^[a-f0-9]{64}$/u;
|
|
32191
32190
|
function record(value) {
|
|
@@ -32206,6 +32205,16 @@ function isApiKeyId(value) {
|
|
|
32206
32205
|
function isApiKeyName(value) {
|
|
32207
32206
|
return isBoundedString(value, 1, 128, API_KEY_NAME);
|
|
32208
32207
|
}
|
|
32208
|
+
function isSafeObfuscatedValue(value) {
|
|
32209
|
+
if (!isBoundedString(value, 1, 256)) return false;
|
|
32210
|
+
for (const character of value) {
|
|
32211
|
+
const point = character.codePointAt(0) ?? 0;
|
|
32212
|
+
if (point <= 31 || point >= 127 && point <= 159 || point === 8232 || point === 8233 || point === 1564 || point >= 8203 && point <= 8207 || point >= 8234 && point <= 8238 || point === 8288 || point >= 8294 && point <= 8297 || point === 65279) {
|
|
32213
|
+
return false;
|
|
32214
|
+
}
|
|
32215
|
+
}
|
|
32216
|
+
return true;
|
|
32217
|
+
}
|
|
32209
32218
|
function isMetadata(value) {
|
|
32210
32219
|
const parsed = record(value);
|
|
32211
32220
|
if (parsed === void 0 || !hasExactKeys(parsed, [
|
|
@@ -32221,7 +32230,7 @@ function isMetadata(value) {
|
|
|
32221
32230
|
return void 0;
|
|
32222
32231
|
}
|
|
32223
32232
|
const { id, name, obfuscatedValue, permissions, lastUsedAt, expiresAt, createdAt, updatedAt } = parsed;
|
|
32224
|
-
if (!isApiKeyId(id) || !isApiKeyName(name) || !
|
|
32233
|
+
if (!isApiKeyId(id) || !isApiKeyName(name) || !isSafeObfuscatedValue(obfuscatedValue) || !Array.isArray(permissions) || permissions.length > 100 || !permissions.every((permission) => isBoundedString(permission, 1, 128, API_KEY_PERMISSION)) || lastUsedAt !== null && !isSafeTimestamp(lastUsedAt) || expiresAt !== null && !isSafeTimestamp(expiresAt) || !isSafeTimestamp(createdAt) || !isSafeTimestamp(updatedAt)) {
|
|
32225
32234
|
return void 0;
|
|
32226
32235
|
}
|
|
32227
32236
|
return {
|
|
@@ -36628,7 +36637,8 @@ function toRequestBody(request2) {
|
|
|
36628
36637
|
reversibility: request2.reversibility,
|
|
36629
36638
|
files: request2.files,
|
|
36630
36639
|
protocolVersion: request2.protocolVersion,
|
|
36631
|
-
repoSyncId: request2.repoSyncId
|
|
36640
|
+
repoSyncId: request2.repoSyncId,
|
|
36641
|
+
stageOverride: request2.stageOverride
|
|
36632
36642
|
};
|
|
36633
36643
|
const body = {};
|
|
36634
36644
|
for (const [key, value] of Object.entries(candidate)) {
|
|
@@ -36671,16 +36681,19 @@ var defaultDependencies2 = {
|
|
|
36671
36681
|
var EXPECTED_STAGE = {
|
|
36672
36682
|
publish: "provisional",
|
|
36673
36683
|
restore: "draft",
|
|
36684
|
+
ratify: "adopted",
|
|
36674
36685
|
supersede: "superseded"
|
|
36675
36686
|
};
|
|
36676
36687
|
var PATH = {
|
|
36677
36688
|
publish: "/api/cli/decisions/publish",
|
|
36678
36689
|
restore: "/api/cli/decisions/restore",
|
|
36690
|
+
ratify: "/api/cli/decisions/ratify",
|
|
36679
36691
|
supersede: "/api/cli/decisions/supersede"
|
|
36680
36692
|
};
|
|
36681
36693
|
var PAST_PARTICIPLE = {
|
|
36682
36694
|
publish: "published",
|
|
36683
36695
|
restore: "restored",
|
|
36696
|
+
ratify: "ratified",
|
|
36684
36697
|
supersede: "superseded"
|
|
36685
36698
|
};
|
|
36686
36699
|
var ORG_UNBOUND_MESSAGE = "CLI token is not bound to an organization";
|
|
@@ -36731,6 +36744,9 @@ function formatSuccessHuman(operation, request2, response) {
|
|
|
36731
36744
|
if (operation === "restore") {
|
|
36732
36745
|
return `[prim] ${identifier} restored as a private draft.`;
|
|
36733
36746
|
}
|
|
36747
|
+
if (operation === "ratify") {
|
|
36748
|
+
return `[prim] ${identifier} ratified as ${response.stage}.`;
|
|
36749
|
+
}
|
|
36734
36750
|
const replacement = safeRequestedIdentifier(
|
|
36735
36751
|
request2.by,
|
|
36736
36752
|
"the replacement Decision"
|
|
@@ -36877,6 +36893,10 @@ function restoreDecision(id, dependencies = defaultDependencies2) {
|
|
|
36877
36893
|
const request2 = { id };
|
|
36878
36894
|
return executeLifecycle("restore", request2, dependencies);
|
|
36879
36895
|
}
|
|
36896
|
+
function ratifyDecision(id, dependencies = defaultDependencies2) {
|
|
36897
|
+
const request2 = { id };
|
|
36898
|
+
return executeLifecycle("ratify", request2, dependencies);
|
|
36899
|
+
}
|
|
36880
36900
|
function supersedeDecision(id, by, dependencies = defaultDependencies2) {
|
|
36881
36901
|
const request2 = { id, by };
|
|
36882
36902
|
return executeLifecycle("supersede", request2, dependencies);
|
|
@@ -37831,6 +37851,9 @@ function registerDecisionsCommands(program3) {
|
|
|
37831
37851
|
decisions.command("restore <idOrShortId>").description("Restore an authored abandoned Decision to a private draft").action(async (idOrShortId) => {
|
|
37832
37852
|
process.exitCode = await restoreDecision(idOrShortId);
|
|
37833
37853
|
});
|
|
37854
|
+
decisions.command("ratify <idOrShortId>").description("Ratify an authored Decision as adopted").action(async (idOrShortId) => {
|
|
37855
|
+
process.exitCode = await ratifyDecision(idOrShortId);
|
|
37856
|
+
});
|
|
37834
37857
|
decisions.command("supersede <idOrShortId>").description("Supersede a Decision with a distinct replacement Decision").requiredOption("--by <replacementIdOrShortId>", "Decision that replaces the named Decision").action(async (idOrShortId, opts) => {
|
|
37835
37858
|
process.exitCode = await supersedeDecision(idOrShortId, opts.by);
|
|
37836
37859
|
});
|
|
@@ -37907,11 +37930,17 @@ function registerDecisionsCommands(program3) {
|
|
|
37907
37930
|
"One rejected option, verbatim; repeat the flag for each",
|
|
37908
37931
|
collectItem,
|
|
37909
37932
|
[]
|
|
37910
|
-
).option("--confidence <level>", "high | medium | low (default high)").option("--reversibility <level>", "high | low (default high)").option(
|
|
37933
|
+
).option("--confidence <level>", "high | medium | low (default high)").option("--reversibility <level>", "high | low (default high)").option("--draft", "Create a private draft instead of publishing immediately").option("--adopt", "Create an adopted Decision as the authenticated author").option(
|
|
37911
37934
|
"--files <paths>",
|
|
37912
37935
|
"Comma-separated exact repo-relative paths this decision governs (repeatable)",
|
|
37913
37936
|
collectPaths
|
|
37914
37937
|
).action(async (opts, command) => {
|
|
37938
|
+
if (opts.draft && opts.adopt) {
|
|
37939
|
+
console.error("[prim] create rejected: --draft and --adopt cannot be used together.");
|
|
37940
|
+
console.log(JSON.stringify({ ok: false, error: "conflicting_stage_override" }, null, 2));
|
|
37941
|
+
process.exitCode = EXIT_USAGE;
|
|
37942
|
+
return;
|
|
37943
|
+
}
|
|
37915
37944
|
const requestedFiles = opts.files ?? [];
|
|
37916
37945
|
let explicitScope = {};
|
|
37917
37946
|
if (requestedFiles.length > 0) {
|
|
@@ -37956,6 +37985,7 @@ function registerDecisionsCommands(program3) {
|
|
|
37956
37985
|
alternatives: opts.alternatives,
|
|
37957
37986
|
confidence: opts.confidence,
|
|
37958
37987
|
reversibility: opts.reversibility,
|
|
37988
|
+
stageOverride: opts.draft ? "draft" : opts.adopt ? "adopted" : void 0,
|
|
37959
37989
|
...explicitScope
|
|
37960
37990
|
};
|
|
37961
37991
|
try {
|
package/dist/index.js
CHANGED
|
@@ -9981,7 +9981,6 @@ var API_KEY_ID = /^api_key_[A-Za-z0-9_-]+$/u;
|
|
|
9981
9981
|
var API_KEY_NAME = /^[\x21-\x7e](?:[\x20-\x7e]{0,126}[\x21-\x7e])?$/u;
|
|
9982
9982
|
var API_KEY_PERMISSION = /^[\x21-\x7e]+$/u;
|
|
9983
9983
|
var API_KEY_SECRET = /^sk_[\x21-\x7e]+(?: [\x21-\x7e]+)*$/u;
|
|
9984
|
-
var API_KEY_OBFUSCATED_VALUE = /^[\x20-\x7e]+$/u;
|
|
9985
9984
|
var MINT_PATH = "/api/cli/auth/api-keys";
|
|
9986
9985
|
var REQUEST_ID = /^[a-f0-9]{64}$/u;
|
|
9987
9986
|
function record(value) {
|
|
@@ -10002,6 +10001,16 @@ function isApiKeyId(value) {
|
|
|
10002
10001
|
function isApiKeyName(value) {
|
|
10003
10002
|
return isBoundedString(value, 1, 128, API_KEY_NAME);
|
|
10004
10003
|
}
|
|
10004
|
+
function isSafeObfuscatedValue(value) {
|
|
10005
|
+
if (!isBoundedString(value, 1, 256)) return false;
|
|
10006
|
+
for (const character of value) {
|
|
10007
|
+
const point = character.codePointAt(0) ?? 0;
|
|
10008
|
+
if (point <= 31 || point >= 127 && point <= 159 || point === 8232 || point === 8233 || point === 1564 || point >= 8203 && point <= 8207 || point >= 8234 && point <= 8238 || point === 8288 || point >= 8294 && point <= 8297 || point === 65279) {
|
|
10009
|
+
return false;
|
|
10010
|
+
}
|
|
10011
|
+
}
|
|
10012
|
+
return true;
|
|
10013
|
+
}
|
|
10005
10014
|
function isMetadata(value) {
|
|
10006
10015
|
const parsed = record(value);
|
|
10007
10016
|
if (parsed === void 0 || !hasExactKeys(parsed, [
|
|
@@ -10017,7 +10026,7 @@ function isMetadata(value) {
|
|
|
10017
10026
|
return void 0;
|
|
10018
10027
|
}
|
|
10019
10028
|
const { id, name, obfuscatedValue, permissions, lastUsedAt, expiresAt, createdAt, updatedAt } = parsed;
|
|
10020
|
-
if (!isApiKeyId(id) || !isApiKeyName(name) || !
|
|
10029
|
+
if (!isApiKeyId(id) || !isApiKeyName(name) || !isSafeObfuscatedValue(obfuscatedValue) || !Array.isArray(permissions) || permissions.length > 100 || !permissions.every((permission) => isBoundedString(permission, 1, 128, API_KEY_PERMISSION)) || lastUsedAt !== null && !isSafeTimestamp(lastUsedAt) || expiresAt !== null && !isSafeTimestamp(expiresAt) || !isSafeTimestamp(createdAt) || !isSafeTimestamp(updatedAt)) {
|
|
10021
10030
|
return void 0;
|
|
10022
10031
|
}
|
|
10023
10032
|
return {
|
|
@@ -14234,7 +14243,8 @@ function toRequestBody(request) {
|
|
|
14234
14243
|
reversibility: request.reversibility,
|
|
14235
14244
|
files: request.files,
|
|
14236
14245
|
protocolVersion: request.protocolVersion,
|
|
14237
|
-
repoSyncId: request.repoSyncId
|
|
14246
|
+
repoSyncId: request.repoSyncId,
|
|
14247
|
+
stageOverride: request.stageOverride
|
|
14238
14248
|
};
|
|
14239
14249
|
const body = {};
|
|
14240
14250
|
for (const [key, value] of Object.entries(candidate)) {
|
|
@@ -14277,16 +14287,19 @@ var defaultDependencies2 = {
|
|
|
14277
14287
|
var EXPECTED_STAGE = {
|
|
14278
14288
|
publish: "provisional",
|
|
14279
14289
|
restore: "draft",
|
|
14290
|
+
ratify: "adopted",
|
|
14280
14291
|
supersede: "superseded"
|
|
14281
14292
|
};
|
|
14282
14293
|
var PATH = {
|
|
14283
14294
|
publish: "/api/cli/decisions/publish",
|
|
14284
14295
|
restore: "/api/cli/decisions/restore",
|
|
14296
|
+
ratify: "/api/cli/decisions/ratify",
|
|
14285
14297
|
supersede: "/api/cli/decisions/supersede"
|
|
14286
14298
|
};
|
|
14287
14299
|
var PAST_PARTICIPLE = {
|
|
14288
14300
|
publish: "published",
|
|
14289
14301
|
restore: "restored",
|
|
14302
|
+
ratify: "ratified",
|
|
14290
14303
|
supersede: "superseded"
|
|
14291
14304
|
};
|
|
14292
14305
|
var ORG_UNBOUND_MESSAGE = "CLI token is not bound to an organization";
|
|
@@ -14337,6 +14350,9 @@ function formatSuccessHuman(operation, request, response) {
|
|
|
14337
14350
|
if (operation === "restore") {
|
|
14338
14351
|
return `[prim] ${identifier} restored as a private draft.`;
|
|
14339
14352
|
}
|
|
14353
|
+
if (operation === "ratify") {
|
|
14354
|
+
return `[prim] ${identifier} ratified as ${response.stage}.`;
|
|
14355
|
+
}
|
|
14340
14356
|
const replacement = safeRequestedIdentifier(
|
|
14341
14357
|
request.by,
|
|
14342
14358
|
"the replacement Decision"
|
|
@@ -14483,6 +14499,10 @@ function restoreDecision(id, dependencies = defaultDependencies2) {
|
|
|
14483
14499
|
const request = { id };
|
|
14484
14500
|
return executeLifecycle("restore", request, dependencies);
|
|
14485
14501
|
}
|
|
14502
|
+
function ratifyDecision(id, dependencies = defaultDependencies2) {
|
|
14503
|
+
const request = { id };
|
|
14504
|
+
return executeLifecycle("ratify", request, dependencies);
|
|
14505
|
+
}
|
|
14486
14506
|
function supersedeDecision(id, by, dependencies = defaultDependencies2) {
|
|
14487
14507
|
const request = { id, by };
|
|
14488
14508
|
return executeLifecycle("supersede", request, dependencies);
|
|
@@ -15349,6 +15369,9 @@ function registerDecisionsCommands(program2) {
|
|
|
15349
15369
|
decisions.command("restore <idOrShortId>").description("Restore an authored abandoned Decision to a private draft").action(async (idOrShortId) => {
|
|
15350
15370
|
process.exitCode = await restoreDecision(idOrShortId);
|
|
15351
15371
|
});
|
|
15372
|
+
decisions.command("ratify <idOrShortId>").description("Ratify an authored Decision as adopted").action(async (idOrShortId) => {
|
|
15373
|
+
process.exitCode = await ratifyDecision(idOrShortId);
|
|
15374
|
+
});
|
|
15352
15375
|
decisions.command("supersede <idOrShortId>").description("Supersede a Decision with a distinct replacement Decision").requiredOption("--by <replacementIdOrShortId>", "Decision that replaces the named Decision").action(async (idOrShortId, opts) => {
|
|
15353
15376
|
process.exitCode = await supersedeDecision(idOrShortId, opts.by);
|
|
15354
15377
|
});
|
|
@@ -15425,11 +15448,17 @@ function registerDecisionsCommands(program2) {
|
|
|
15425
15448
|
"One rejected option, verbatim; repeat the flag for each",
|
|
15426
15449
|
collectItem,
|
|
15427
15450
|
[]
|
|
15428
|
-
).option("--confidence <level>", "high | medium | low (default high)").option("--reversibility <level>", "high | low (default high)").option(
|
|
15451
|
+
).option("--confidence <level>", "high | medium | low (default high)").option("--reversibility <level>", "high | low (default high)").option("--draft", "Create a private draft instead of publishing immediately").option("--adopt", "Create an adopted Decision as the authenticated author").option(
|
|
15429
15452
|
"--files <paths>",
|
|
15430
15453
|
"Comma-separated exact repo-relative paths this decision governs (repeatable)",
|
|
15431
15454
|
collectPaths
|
|
15432
15455
|
).action(async (opts, command) => {
|
|
15456
|
+
if (opts.draft && opts.adopt) {
|
|
15457
|
+
console.error("[prim] create rejected: --draft and --adopt cannot be used together.");
|
|
15458
|
+
console.log(JSON.stringify({ ok: false, error: "conflicting_stage_override" }, null, 2));
|
|
15459
|
+
process.exitCode = EXIT_USAGE;
|
|
15460
|
+
return;
|
|
15461
|
+
}
|
|
15433
15462
|
const requestedFiles = opts.files ?? [];
|
|
15434
15463
|
let explicitScope = {};
|
|
15435
15464
|
if (requestedFiles.length > 0) {
|
|
@@ -15474,6 +15503,7 @@ function registerDecisionsCommands(program2) {
|
|
|
15474
15503
|
alternatives: opts.alternatives,
|
|
15475
15504
|
confidence: opts.confidence,
|
|
15476
15505
|
reversibility: opts.reversibility,
|
|
15506
|
+
stageOverride: opts.draft ? "draft" : opts.adopt ? "adopted" : void 0,
|
|
15477
15507
|
...explicitScope
|
|
15478
15508
|
};
|
|
15479
15509
|
try {
|
package/package.json
CHANGED