@productbrain/cli 0.1.0-beta.13746 → 0.1.0-beta.13759
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/lib/limits.d.ts +16 -7
- package/dist/lib/limits.d.ts.map +1 -1
- package/dist/lib/limits.js +38 -13
- package/dist/lib/limits.js.map +1 -1
- package/dist/lib/nameFromText.d.ts.map +1 -1
- package/dist/lib/nameFromText.js +3 -1
- package/dist/lib/nameFromText.js.map +1 -1
- package/package.json +1 -1
package/dist/lib/limits.d.ts
CHANGED
|
@@ -14,13 +14,21 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const ENTRY_BODY_MAX_CHARS = 150000;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
17
|
+
* A rule's title limit, in UTF-8 bytes (RULE-703, DEC-2219): the rule row of the name cap table below. It is defined here, with
|
|
18
|
+
* the other name caps, because this file is copied verbatim into the connectors and cannot import the rule lists; the rule
|
|
19
|
+
* lists (kernel/governance/ruleLists.ts) re-export it and the rule gate refuses with it, so the number lives once.
|
|
20
|
+
*/
|
|
21
|
+
export declare const RULE_TITLE_MAX_BYTES = 110;
|
|
22
|
+
/**
|
|
23
|
+
* The cap on an entry's `name` (top-level, not a data field) per kind (DEC-2512, DEC-2343, DEC-2550, DEC-2552): the one table
|
|
24
|
+
* every surface reads, so no other file holds a cap number. Characters are code points; the rule row is bytes. An objective or
|
|
25
|
+
* key result holds one label line (the Rail's); working kinds one short line, purpose, vision and strategy a sentence; every
|
|
26
|
+
* other collection keeps 250 until a ruling names it.
|
|
21
27
|
*/
|
|
22
28
|
export declare const ENTRY_NAME_CAPS: {
|
|
29
|
+
readonly outcome: 40;
|
|
23
30
|
readonly working: 80;
|
|
31
|
+
readonly rule: 110;
|
|
24
32
|
readonly direction: 250;
|
|
25
33
|
readonly other: 250;
|
|
26
34
|
};
|
|
@@ -28,16 +36,17 @@ export declare const ENTRY_NAME_CAPS: {
|
|
|
28
36
|
export declare const ENTRY_NAME_MAX_CHARS: number;
|
|
29
37
|
/** A name's length as a person counts it: code points, never bytes or UTF-16 units (one emoji is one character). */
|
|
30
38
|
export declare function nameChars(name: string): number;
|
|
31
|
-
/** The cap on a name in this collection (the catalog slug); a slug with no row of its own, or none, takes the `other` cap. */
|
|
39
|
+
/** The cap on a name in this collection (the catalog slug), in characters; a rule's is in bytes. A slug with no row of its own, or none, takes the `other` cap. */
|
|
32
40
|
export declare function nameCapFor(collectionSlug: string | null | undefined): number;
|
|
33
41
|
/** What a name refusal says to do, in words; the surface adds its own way to do it (DEC-1994). */
|
|
34
42
|
export declare const NAME_REFUSAL_FIX = "Shorten the name; the detail goes in the body.";
|
|
35
43
|
/**
|
|
36
44
|
* The one refusal for a name over its kind's cap, with the count and the cap (RULE-17), or null when the name fits. Every
|
|
37
|
-
* door that writes a name says this and nothing else (RULE-664).
|
|
45
|
+
* door that writes a name says this and nothing else (RULE-664). A rule's title is held in bytes by the rule gate, which
|
|
46
|
+
* refuses with its own sentence (`ruleLengthRefusal`), so this says nothing for the rule row.
|
|
38
47
|
*/
|
|
39
48
|
export declare function entryNameRefusal(name: string, collectionSlug: string | null | undefined): string | null;
|
|
40
|
-
/** The help for a capture's name and body, the same words in the CLI and the MCP capture tool (RULE-664). */
|
|
49
|
+
/** The help for a capture's name and body, the same words in the CLI and the MCP capture tool (RULE-664, DEC-2551). */
|
|
41
50
|
export declare const ENTRY_NAME_HELP: string;
|
|
42
51
|
export declare const ENTRY_BODY_HELP = "The detail, in Markdown.";
|
|
43
52
|
/** The verbatim excerpt that backs an entry's claims (`sourceExcerpt`). */
|
package/dist/lib/limits.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../../src/lib/limits.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,oBAAoB,SAAS,CAA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@@ -17,15 +17,21 @@
|
|
|
17
17
|
*/
|
|
18
18
|
export const ENTRY_BODY_MAX_CHARS = 150000;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* gate's and stays there.
|
|
20
|
+
* A rule's title limit, in UTF-8 bytes (RULE-703, DEC-2219): the rule row of the name cap table below. It is defined here, with
|
|
21
|
+
* the other name caps, because this file is copied verbatim into the connectors and cannot import the rule lists; the rule
|
|
22
|
+
* lists (kernel/governance/ruleLists.ts) re-export it and the rule gate refuses with it, so the number lives once.
|
|
24
23
|
*/
|
|
25
|
-
export const
|
|
24
|
+
export const RULE_TITLE_MAX_BYTES = 110;
|
|
25
|
+
/**
|
|
26
|
+
* The cap on an entry's `name` (top-level, not a data field) per kind (DEC-2512, DEC-2343, DEC-2550, DEC-2552): the one table
|
|
27
|
+
* every surface reads, so no other file holds a cap number. Characters are code points; the rule row is bytes. An objective or
|
|
28
|
+
* key result holds one label line (the Rail's); working kinds one short line, purpose, vision and strategy a sentence; every
|
|
29
|
+
* other collection keeps 250 until a ruling names it.
|
|
30
|
+
*/
|
|
31
|
+
export const ENTRY_NAME_CAPS = { outcome: 40, working: 80, rule: RULE_TITLE_MAX_BYTES, direction: 250, other: 250 };
|
|
26
32
|
/** The longest name any kind may hold, derived from the table: the bound for a path that cannot know the kind (a schema, a platform seed). */
|
|
27
33
|
export const ENTRY_NAME_MAX_CHARS = Math.max(...Object.values(ENTRY_NAME_CAPS));
|
|
28
|
-
/** The kinds that have a cap of their own and the word a refusal
|
|
34
|
+
/** The kinds that have a cap of their own and the word a refusal and the help call each. A kind not listed takes the `other` cap. */
|
|
29
35
|
const NAME_KINDS = {
|
|
30
36
|
decisions: { word: 'decision', tier: 'working' },
|
|
31
37
|
tensions: { word: 'tension', tier: 'working' },
|
|
@@ -36,8 +42,9 @@ const NAME_KINDS = {
|
|
|
36
42
|
purpose: { word: 'purpose', tier: 'direction' },
|
|
37
43
|
vision: { word: 'vision', tier: 'direction' },
|
|
38
44
|
strategy: { word: 'strategy', tier: 'direction' },
|
|
39
|
-
objectives: { word: 'objective', tier: '
|
|
40
|
-
'key-results': { word: 'key result', tier: '
|
|
45
|
+
objectives: { word: 'objective', tier: 'outcome' },
|
|
46
|
+
'key-results': { word: 'key result', tier: 'outcome' },
|
|
47
|
+
rules: { word: 'rule', tier: 'rule' },
|
|
41
48
|
teams: { word: 'team', tier: 'other' },
|
|
42
49
|
labels: { word: 'label', tier: 'other' },
|
|
43
50
|
};
|
|
@@ -45,7 +52,7 @@ const NAME_KINDS = {
|
|
|
45
52
|
export function nameChars(name) {
|
|
46
53
|
return Array.from(name).length;
|
|
47
54
|
}
|
|
48
|
-
/** The cap on a name in this collection (the catalog slug); a slug with no row of its own, or none, takes the `other` cap. */
|
|
55
|
+
/** The cap on a name in this collection (the catalog slug), in characters; a rule's is in bytes. A slug with no row of its own, or none, takes the `other` cap. */
|
|
49
56
|
export function nameCapFor(collectionSlug) {
|
|
50
57
|
return ENTRY_NAME_CAPS[(collectionSlug ? NAME_KINDS[collectionSlug]?.tier : undefined) ?? 'other'];
|
|
51
58
|
}
|
|
@@ -53,18 +60,36 @@ export function nameCapFor(collectionSlug) {
|
|
|
53
60
|
export const NAME_REFUSAL_FIX = 'Shorten the name; the detail goes in the body.';
|
|
54
61
|
/**
|
|
55
62
|
* The one refusal for a name over its kind's cap, with the count and the cap (RULE-17), or null when the name fits. Every
|
|
56
|
-
* door that writes a name says this and nothing else (RULE-664).
|
|
63
|
+
* door that writes a name says this and nothing else (RULE-664). A rule's title is held in bytes by the rule gate, which
|
|
64
|
+
* refuses with its own sentence (`ruleLengthRefusal`), so this says nothing for the rule row.
|
|
57
65
|
*/
|
|
58
66
|
export function entryNameRefusal(name, collectionSlug) {
|
|
67
|
+
const kind = collectionSlug ? NAME_KINDS[collectionSlug] : undefined;
|
|
68
|
+
if (kind?.tier === 'rule')
|
|
69
|
+
return null;
|
|
59
70
|
const chars = nameChars(name);
|
|
60
71
|
const cap = nameCapFor(collectionSlug);
|
|
61
72
|
if (chars <= cap)
|
|
62
73
|
return null;
|
|
63
|
-
const word =
|
|
74
|
+
const word = kind?.word ?? 'entry';
|
|
64
75
|
return `Name is ${chars} characters; the cap for ${/^[aeiou]/.test(word) ? 'an' : 'a'} ${word} is ${cap}. ${NAME_REFUSAL_FIX}`;
|
|
65
76
|
}
|
|
66
|
-
/** The
|
|
67
|
-
|
|
77
|
+
/** The kinds that share a cap, worded as one list: "a decision, tension or task". */
|
|
78
|
+
function kindsWithCap(cap) {
|
|
79
|
+
const words = Object.values(NAME_KINDS).filter((k) => ENTRY_NAME_CAPS[k.tier] === cap && k.tier !== 'other').map((k) => k.word);
|
|
80
|
+
return words.length < 2 ? words.join('') : `${words.slice(0, -1).join(', ')} or ${words[words.length - 1]}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The longest name each kind may hold, worded from the table so the help cannot drift from the refusal (DEC-2551): one clause
|
|
84
|
+
* per cap in order, then the cap every other kind takes. A kind whose cap equals the `other` cap is left to that last clause.
|
|
85
|
+
*/
|
|
86
|
+
function nameLimitsSentence() {
|
|
87
|
+
const caps = [...new Set(Object.values(NAME_KINDS).map((k) => ENTRY_NAME_CAPS[k.tier]))].filter((cap) => cap !== ENTRY_NAME_CAPS.other).sort((a, b) => a - b);
|
|
88
|
+
const clauses = caps.map((cap, i) => `${cap}${cap === ENTRY_NAME_CAPS.rule ? ' bytes' : i === 0 ? ' characters' : ''} for ${/^[aeiou]/.test(kindsWithCap(cap)) ? 'an' : 'a'} ${kindsWithCap(cap)}`);
|
|
89
|
+
return `At most ${[...clauses, `${ENTRY_NAME_CAPS.other} for any other kind`].join(', ')}.`;
|
|
90
|
+
}
|
|
91
|
+
/** The help for a capture's name and body, the same words in the CLI and the MCP capture tool (RULE-664, DEC-2551). */
|
|
92
|
+
export const ENTRY_NAME_HELP = `A short name. ${nameLimitsSentence()}`;
|
|
68
93
|
export const ENTRY_BODY_HELP = 'The detail, in Markdown.';
|
|
69
94
|
/** The verbatim excerpt that backs an entry's claims (`sourceExcerpt`). */
|
|
70
95
|
export const SOURCE_EXCERPT_MAX_CHARS = 4000;
|
package/dist/lib/limits.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/lib/limits.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,gEAAgE;AAChE,uDAAuD;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../../src/lib/limits.ts"],"names":[],"mappings":"AAAA,uFAAuF;AACvF,gEAAgE;AAChE,uDAAuD;AAEvD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC;AAE3C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAG,CAAC;AAExC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE,SAAS,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAW,CAAC;AAE7H,8IAA8I;AAC9I,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC;AAIhF,qIAAqI;AACrI,MAAM,UAAU,GAA+D;IAC9E,SAAS,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;IAChD,QAAQ,EAAE,EAAE,IAAI,EAAE,S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GAAG,IAAI,CAAC;AAE7C,mGAAmG;AACnG,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,iGAAiG;AACjG,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAa;IACxC,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,kBAAkB,KAAK,qBAAqB,CAAC,CAAC,CAAC,2DAA2D,CAAC;AAC/H,CAAC;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,uCAAuC,CAAC;AAEhF,yIAAyI;AACzI,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC7C,OAAO,6BAA6B,KAAK,gGAAgG,CAAC;AAC3I,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nameFromText.d.ts","sourceRoot":"","sources":["../../src/lib/nameFromText.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"nameFromText.d.ts","sourceRoot":"","sources":["../../src/lib/nameFromText.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAepE"}
|
package/dist/lib/nameFromText.js
CHANGED
|
@@ -28,7 +28,9 @@ export function deriveNameFromText(text, cap) {
|
|
|
28
28
|
const hardCap = chars.slice(0, cap).join('');
|
|
29
29
|
if (chars[cap] === ' ')
|
|
30
30
|
return hardCap.trim(); // the cut already falls between two words
|
|
31
|
+
// A kind prefix ("DEC: ") is not a name by itself: a space inside it is no place to cut, so a first token longer than the room left (a path, a url) is cut hard at the cap.
|
|
32
|
+
const prefixLen = /^[A-Za-z]{2,5}:\s/.exec(hardCap)?.[0].length ?? 0;
|
|
31
33
|
const lastSpace = hardCap.lastIndexOf(' ');
|
|
32
|
-
return (lastSpace
|
|
34
|
+
return (lastSpace >= Math.max(prefixLen, 1) ? hardCap.slice(0, lastSpace) : hardCap).trim();
|
|
33
35
|
}
|
|
34
36
|
//# sourceMappingURL=nameFromText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nameFromText.js","sourceRoot":"","sources":["../../src/lib/nameFromText.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,gEAAgE;AAChE,uDAAuD;AAEvD;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,GAAW;IAC3D,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IAC9C,MAAM,cAAc,GAAG,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;QACzB,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,cAAc,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC/D,IAAI,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,IAAI,GAAG;YAAE,OAAO,aAAa,CAAC;IACnE,CAAC;IACD,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG;QAAE,OAAO,IAAI,CAAC;IACrC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC7C,IAAI,KAAK,CAAC,GAAG,CAAC,KAAK,GAAG;QAAE,OAAO,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC,0CAA0C;IACzF,MAAM,SAAS,GAAG,OAAO,C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