@plurnk/plurnk-contracts 1.14.2 → 1.16.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.
Files changed (46) hide show
  1. package/SPEC.md +106 -123
  2. package/dist/plurnk.gemma.gbnf +62 -87
  3. package/dist/plurnk.qwen.gbnf +62 -87
  4. package/dist/schema/ClientStatement.json +114 -40
  5. package/dist/schema/PlurnkStatement.json +29 -199
  6. package/dist/schema/RangeExtent.json +1 -1
  7. package/dist/src/AstBuilder.d.ts +2 -2
  8. package/dist/src/AstBuilder.d.ts.map +1 -1
  9. package/dist/src/AstBuilder.js +68 -146
  10. package/dist/src/AstBuilder.js.map +1 -1
  11. package/dist/src/PlurnkErrorStrategy.d.ts +0 -1
  12. package/dist/src/PlurnkErrorStrategy.d.ts.map +1 -1
  13. package/dist/src/PlurnkErrorStrategy.js +72 -61
  14. package/dist/src/PlurnkErrorStrategy.js.map +1 -1
  15. package/dist/src/PlurnkParser.d.ts +1 -2
  16. package/dist/src/PlurnkParser.d.ts.map +1 -1
  17. package/dist/src/PlurnkParser.js +15 -104
  18. package/dist/src/PlurnkParser.js.map +1 -1
  19. package/dist/src/generated/plurnkLexer.d.ts +42 -69
  20. package/dist/src/generated/plurnkLexer.d.ts.map +1 -1
  21. package/dist/src/generated/plurnkLexer.js +495 -647
  22. package/dist/src/generated/plurnkLexer.js.map +1 -1
  23. package/dist/src/generated/plurnkParser.d.ts +76 -215
  24. package/dist/src/generated/plurnkParser.d.ts.map +1 -1
  25. package/dist/src/generated/plurnkParser.js +643 -1829
  26. package/dist/src/generated/plurnkParser.js.map +1 -1
  27. package/dist/src/generated/plurnkParserVisitor.d.ts +3 -87
  28. package/dist/src/generated/plurnkParserVisitor.d.ts.map +1 -1
  29. package/dist/src/generated/plurnkParserVisitor.js +2 -74
  30. package/dist/src/generated/plurnkParserVisitor.js.map +1 -1
  31. package/dist/src/index.d.ts +0 -2
  32. package/dist/src/index.d.ts.map +1 -1
  33. package/dist/src/index.js +0 -1
  34. package/dist/src/index.js.map +1 -1
  35. package/dist/src/types.d.ts +1 -1
  36. package/dist/src/types.d.ts.map +1 -1
  37. package/dist/src/types.generated.d.ts +18 -50
  38. package/dist/src/types.generated.d.ts.map +1 -1
  39. package/dist/src/types.js +1 -1
  40. package/dist/src/types.js.map +1 -1
  41. package/package.json +1 -1
  42. package/plurnk.md +67 -73
  43. package/dist/src/TagSignal.d.ts +0 -15
  44. package/dist/src/TagSignal.d.ts.map +0 -1
  45. package/dist/src/TagSignal.js +0 -53
  46. package/dist/src/TagSignal.js.map +0 -1
package/dist/src/types.js CHANGED
@@ -6,7 +6,7 @@ import reasoningPolicySchema from "../schema/ReasoningPolicy.json" with { type:
6
6
  // expressed in JSON Schema. Hand-maintained.
7
7
  // Runtime protocol alphabet; PlurnkOp is structurally derived from this tuple. {§op-shapes}
8
8
  export const PLURNK_OPS = [
9
- "FIND", "READ", "EDIT", "COPY", "MOVE", "OPEN", "FOLD", "SEND", "EXEC", "BARE", "WORK", "FORK", "KILL", "PLAN",
9
+ "FIND", "READ", "EDIT", "COPY", "MOVE", "SEND", "EXEC", "BARE", "WORK", "FORK", "KILL", "PLAN",
10
10
  ];
11
11
  // Markerless model-facing retrievals share one fixed first page. Producers use
12
12
  // an explicit <1,-1> when they deliberately require the complete projection.
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,oFAAoF;AACpF,cAAc,sBAAsB,CAAC;AAErC,OAAO,qBAAqB,MAAM,gCAAgC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAWzF,0EAA0E;AAC1E,6CAA6C;AAE7C,4FAA4F;AAC5F,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,M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,MAAM,EAAE,MAAM;CACxF,CAAC;AAEX,+EAA+E;AAC/E,6EAA6E;AAC7E,MAAM,CAAC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AAoB1C,2EAA2E;AAC3E,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAC3C,qBAAqB,CAAC,IAAyB,CACpB,CAAC;AAEhC,MAAM,CAAC,MAAM,yBAAyB,GAAqB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE7E,MAAM,CAAC,MAAM,mBAAmB,GAAe,MAAM,CAAC,MAAM,CAAC;IACzD,YAAY,EAAE,yBAAyB;IACvC,SAAS,EAAE,QAAQ;CACtB,CAAC,CAAC;AAEH,wFAAwF;AACxF,MAAM,CAAC,MAAM,WAAW,GAAG,sCAAsC,CAAC;AAElE,+EAA+E;AAC/E,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,CAAU,CAAC,CAAC;AAElF,sFAAsF;AACtF,MAAM,CAAC,MAAM,gBAAgB,GAAuB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plurnk/plurnk-contracts",
3
- "version": "1.14.2",
3
+ "version": "1.16.0",
4
4
  "description": "Canonical PLURNK language, schemas, generated types, parser, rails, and runtime-neutral wire contracts",
5
5
  "keywords": [
6
6
  "plurnk",
package/plurnk.md CHANGED
@@ -1,108 +1,102 @@
1
1
  # Plurnk Service
2
2
 
3
- YOU MUST ONLY use the Plurnk OPs (PLAN|FIND|READ|EDIT|COPY|MOVE|FOLD|OPEN|EXEC|WORK|FORK|KILL|SEND).
4
- YOU MUST continue performing OPs until every Active User Prompt requirement and every pending or in_progress item is completed.
3
+ YOU MUST ONLY use the Plurnk OPs (PLAN|FIND|READ|EDIT|COPY|MOVE|EXEC|WORK|FORK|KILL|SEND).
4
+ YOU MUST proceed until every Active User Prompt requirement and every pending or in_progress item is completed.
5
5
 
6
- ### Syntax
6
+ ## Syntax
7
7
 
8
- ```plurnk-syntax
9
- # PLANdelimiter <!-- terse annotation on same line as OP -->?
8
+ ```example
9
+ ## PLANdelimiter <!-- terse annotation on same line as OP -->?
10
10
  [{"content": string, "status": "pending" | "in_progress" | "completed" | "memory"},
11
11
  …]
12
- ## OPdelimiter [signal]? (path)? <scope>? <!-- terse annotation on same line as OP -->?
12
+ ### OPdelimiter (path)? <scope>? <!-- terse annotation on same line as OP -->?
13
13
  body?
14
+ ### SENDdelimiter (NEXT|WAIT|TERM|FAIL)
15
+ message
14
16
  ```
15
17
 
16
- * Every non-PLAN OP starts with `## `, as in `## FIND0`, and shares PLAN's delimiter.
17
- * Every OP's `[signal]`, `(path)`, `<scope>`, and `<!-- annotation -->` go only on the OP heading line.
18
+ * Every non-PLAN OP starts with `### `, as in `### FIND0`, and shares PLAN's delimiter.
19
+ * Every OP's `(path)`, `<scope>`, and `<!-- annotation -->` go only on the OP heading line.
18
20
  * `body` content must be immediately beneath the OP heading line.
19
21
 
20
- ### OPs
22
+ ## OPs
21
23
 
22
- * Plurnk grammar is overloaded and polymorphic, with `[signal]`, `(path)`, `<scope>`, and `body` components depending on the OP.
23
- * `[signal]`, `(path)`, `<scope>`, `<!-- annotations -->` and `body` are optional, but at least one must be present.
24
- * A scoped EDIT with no `body` deletes the selected region; an unscoped EDIT only creates a new file or entry.
25
- * Code fences are not part of the OP syntax. Do not add them around OPs.
24
+ * Plurnk grammar is overloaded and polymorphic, with `(path)`, `<scope>`, and `body` components depending on the OP.
25
+ * An unscoped EDIT only creates a new file or entry.
26
26
 
27
- ```plurnk-syntax
28
- # PLAN0 <!-- determinations, decisions, and docket items -->
27
+ ```example
28
+ ## PLAN0 <!-- determinations, decisions, and docket items -->
29
29
  [{"content": string, "status": "pending" | "in_progress" | "completed" | "memory"}]
30
30
 
31
- ## FIND0 [+tag] (target or glob) <result page> <!-- list matching targets -->
31
+ ### FIND0 (target or glob) <result range> <!-- list matching targets -->
32
32
  filter pattern
33
33
 
34
- ## READ0 [+tag] (target) <text region> <!-- retrieve target content -->
34
+ ### READ0 (target) <text region> <!-- retrieve target content -->
35
35
 
36
- ## EDIT0 [+tag] (target) <text region> <!-- edit/replace/delete text -->
36
+ ### EDIT0 (target) <text region> <!-- edit/replace/delete text -->
37
37
  literal replacement text
38
38
 
39
- ## COPY0 [+tag] (source) <source text region> (destination) <destination text region> <!-- copy between targets -->
40
-
41
- ## MOVE0 [+tag] (source) <source text region> (destination) <destination text region> <!-- move between targets -->
39
+ ### COPY0 (source) <source text region> (destination) <destination text region> <!-- copy between targets -->
42
40
 
43
- ## FOLD0 [±tag] (log items) <log body lines> <!-- hide matching log bodies -->
44
- filter pattern
41
+ ### MOVE0 (source) <source text region> (destination) <destination text region> <!-- move between targets -->
45
42
 
46
- ## OPEN0 [±tag] (log items) <log body lines> <!-- reveal matching log bodies -->
47
- filter pattern
48
-
49
- ## EXEC0 <!-- run a command, script, or tool -->
43
+ ### EXEC0 <!-- run a command, script, or tool -->
50
44
  command, script, or tool input
51
45
 
52
- ## WORK0 (worker://name) <!-- spawn a child worker -->
46
+ ### WORK0 (worker://name) <!-- spawn a child worker -->
53
47
  prompt
54
48
 
55
- ## FORK0 (worker://name) <!-- fork current worker -->
49
+ ### FORK0 (worker://name) <!-- fork current worker -->
56
50
  prompt
57
51
 
58
- ## KILL0 [code] (target, including log item) <!-- delete or terminate -->
52
+ ### KILL0 (target or glob) <range or region> <!-- delete or terminate -->
53
+ filter pattern
59
54
 
60
- ## SEND0 [code] (recipient) <!-- message a worker://name, a resource, or the user (default) -->
55
+ ### SEND0 (recipient) <!-- message a worker://name, a path, or the user (default) -->
61
56
  message
62
57
  ```
63
58
 
64
- ### Standard Workflow
59
+ ## Standard Workflow
65
60
 
66
- YOU MUST begin every turn with a `# PLAN0`, including determinations, decisions, and docket items.
67
61
  YOU MUST use the same delimiter, such as `0`, for every OP.
68
- YOU MUST end every turn with `## SEND0 [submit code]`, as in `## SEND0 [102]`.
69
-
70
- | submit code | meaning | body message |
71
- |------------------|----------------------------------|---------------------------------------------|
72
- | `## SEND0 [102]` | Continue to results in next turn | Describe expected or intended next steps |
73
- | `## SEND0 [202]` | Wait for workers or streams | Describe expected or intended next steps |
74
- | `## SEND0 [200]` | Successful conclusion | Response to the Active User Prompt |
75
- | `## SEND0 [499]` | Abort and fail prompt | Describe error or issue |
62
+ YOU SHOULD begin every turn with a `## PLAN0`, including determinations, decisions, and docket items.
63
+ YOU SHOULD end every turn with `### SEND0 (NEXT|WAIT|TERM|FAIL)`.
64
+ YOU SHOULD NOT `(TERM)` when the turn OPs contain delegation, streams, or side effects.
76
65
 
77
- YOU SHOULD continue with `[102]` or wait with `[202]` rather than conclude with `[200]` when the turn includes OPs with side effects.
66
+ | submit code | meaning | body message |
67
+ |------------------|-----------------------------------|------------------------------------------|
68
+ | `### SEND0 (NEXT)` | Continue to results in next turn | Describe expected or intended next steps |
69
+ | `### SEND0 (WAIT)` | Wait for workers or streams | Describe expected or intended next steps |
70
+ | `### SEND0 (TERM)` | Successful conclusion | Response to the Active User Prompt |
71
+ | `### SEND0 (FAIL)` | Abort and fail prompt | Describe error or issue |
78
72
 
79
- * The results of OPs are observable after submitting a continuing `## SEND0 [102]` or waiting `## SEND0 [202]`.
80
- * The concluding `## SEND0 [200]` response contains no references to internal operations unless directly requested.
73
+ * The results of OPs are not observable until after submitting with `(NEXT)`, or `(WAIT)`.
81
74
 
82
- ```plurnk-example
83
- # PLAN0
75
+ ```example
76
+ ## PLAN0
84
77
  [{"content":"report.md is very large, requiring chunking.","status":"memory"},
85
78
  {"content":"Update the existing private summary entry with relevant findings from report.md.","status":"in_progress"}]
86
- ## EDIT0 [+quarterly] (worker://~/report-summary.md) <@wCf7x>
79
+ ### EDIT0 (worker://~/report-summary.md) <@wCf7x>
87
80
  * Q3 results: 42%
88
81
 
89
- ## EDIT0 [+quarterly] (worker://~/report-summary.md) <-1>
82
+ ### EDIT0 (worker://~/report-summary.md) <-1>
90
83
  * Q4 results exceeded Q3
91
84
 
92
- ## READ0 [+quarterly] (report.md) <501,700>
93
- ## SEND0 [102]
85
+ ### KILL0 (log:///1/5/4/READ) <!-- purge previous chunk -->
86
+ ### READ0 (report.md) <401,600> <!-- retrieve next chunk -->
87
+ ### SEND0 (NEXT)
94
88
  Next: Distill relevant findings from this chunk, then continue reading.
95
89
  ```
96
90
 
97
- ### The PLAN
91
+ ## The PLAN
98
92
 
99
93
  * Determinations: "memory" entries recording findings or learnings.
100
94
  * Decisions: "memory" entries recording conclusions, decisions, or policies.
101
95
  * Docket: "pending", "in_progress", or "completed" work.
102
96
 
103
- ### Pattern Filtering
97
+ ## Pattern Filtering
104
98
 
105
- * Pattern matchers in the OP's `body` select resources by content:
99
+ * Pattern matchers in the OP's `body` select paths by content:
106
100
 
107
101
  | prefix | dialect | form | example | engine |
108
102
  |--------|----------|------------------------------------|-------------------------|------------------|
@@ -116,21 +110,20 @@ Next: Distill relevant findings from this chunk, then continue reading.
116
110
  * The leading symbol commits its dialect.
117
111
  * In a path target, `*` maps one level and `**` crosses directories.
118
112
  * Mapping is universal: JSONPath can query XML and XPath can query JSON.
119
- * Patterned FIND returns resources for broad targets and locations for exact targets.
113
+ * Patterned FIND returns paths for broad targets and locations for exact targets.
120
114
 
121
- ### `(path)`
115
+ ## `(path)`
122
116
 
123
- * Each OP's `(path)` slot takes exactly one bare project-relative path or resource URI.
124
- * Log item paths are nested: `log:///1/2/3/READ` is loop/turn/item/OP; omit the OP segment to match any OP.
125
- * In FIND results, each inner array lists one resource's channels, default first. Append `#channel` to override the default.
117
+ * Log item paths are nested: `log:///1/2/3/READ` is loop/turn/item/OP.
118
+ * In FIND results, each inner array lists one path's channels, default first. Append `#channel` to override the default.
126
119
  * A file or entry extension declares its mimetype.
127
- * Percent-encode reserved path characters: `(` becomes `%28`, `)` becomes `%29`, and `<` becomes `%3C`.
120
+ * Percent-encode reserved path characters: `(` becomes `%28` and `)` becomes `%29`.
128
121
  * Creating a file automatically creates missing parent directories.
129
122
 
130
- * Parent traversal: `## READ0 (../AGENTS.md)`.
131
- * Stream channel: `## READ0 (sh:///1/2/3#stderr)`.
123
+ * Parent traversal: `### READ0 (../AGENTS.md)`.
124
+ * Stream channel: `### READ0 (sh:///1/2/3/EXEC#stderr)`.
132
125
 
133
- ### `<scope>`
126
+ ## `<scope>`
134
127
 
135
128
  * Text scopes use 1-based lines and Unicode code-point columns consistently across textual mimetypes:
136
129
 
@@ -143,19 +136,21 @@ Next: Distill relevant findings from this chunk, then continue reading.
143
136
  | `<SL,SC,EL,EC>` | start included, end excluded — `<2,1,2,5>` is columns 1-4 of line 2 |
144
137
  | `<0>`, `<-1>` | prepend / append on mutations; as an end line, `-1` is the last line |
145
138
 
146
- * Unscoped FIND returns items 1-16; unscoped READ returns lines 1–16.
147
- * Rendered READ lines and an applied EDIT's resulting lines begin with a per-line `@hash` anchor and `L:` line number; neither is content.
139
+ * The hash anchor and line number (`@abcde 42:`) in results are not content.
148
140
 
149
- YOU SHOULD prefer `<@hash>` or `<@start,@end>` for EDIT line coordinates; they reject stale targets.
141
+ YOU SHOULD prefer `<@hash>` or `<@start,@end>` to EDIT or KILL line coordinates; they reject stale targets.
150
142
 
151
- ### The Log
143
+ ## KILL
152
144
 
153
- * `[+tag]` adds, `[-tag]` removes; FOLD/OPEN apply signed tags or select by unsigned `[tag]` for folksonomic log curation.
154
- * `## KILL0 (log:///1/[1-7]/*/{PLAN,READ})` removes irrelevant log items.
155
- * `## FOLD0 [+trimmed] (log:///**/READ) <17,-1>` tags every READ and folds each body after line 16.
156
- * `## OPEN0 (log:///1/2/3/READ) <@aB3dE>` restores one anchored line.
145
+ * `### KILL0 (worker://~/notes.md)` without a scope deletes an entry.
146
+ * `### KILL0 (src/app.js) <@zyxwv>` removes one line by anchor.
147
+ * `### KILL0 (sh:///1/2/3/EXEC)` stops a running command.
148
+ * `### KILL0 (worker://recheck)` terminates a worker.
149
+ * `### KILL0 (log:///1/[1-7]/*/{PLAN,READ})` removes matching log items.
150
+ * `### KILL0 (log:///**/READ) <17,-1>` removes each item's lines from 17 on.
151
+ * A log KILL never touches the source.
157
152
 
158
- YOU SHOULD FOLD, KILL, or trim superseded, stale, or irrelevant log content.
153
+ YOU MAY KILL superseded, stale, or irrelevant log items to avoid `tokensActiveTotal` overflow.
159
154
 
160
155
  ## Delegation
161
156
 
@@ -165,5 +160,4 @@ YOU SHOULD FOLD, KILL, or trim superseded, stale, or irrelevant log content.
165
160
  | FORK | forked log | Do two things at once | distinct objective prompt; prior context is inherited |
166
161
 
167
162
  * Delegation `body` must contain a prompt, not OPs.
168
- * Send a worker another message: `## SEND0 (worker://recheck)` with body `Also verify the alternative against the existing tests.`.
169
- * Terminate a worker: `## KILL0 (worker://recheck)`.
163
+ * Send a worker another message: `### SEND0 (worker://recheck)` with body `Also verify the alternative against the existing tests.`.
@@ -1,15 +0,0 @@
1
- export declare class InvalidTagSignalError extends TypeError {
2
- }
3
- export type AppliedTagSignal = Readonly<{
4
- add: readonly string[];
5
- }>;
6
- export type CurationTagSignal = Readonly<{
7
- filter: readonly string[];
8
- add: readonly string[];
9
- remove: readonly string[];
10
- }>;
11
- export default class TagSignal {
12
- static applied(terms: readonly string[] | null): AppliedTagSignal;
13
- static curation(terms: readonly string[] | null): CurationTagSignal;
14
- }
15
- //# sourceMappingURL=TagSignal.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TagSignal.d.ts","sourceRoot":"","sources":["../../src/TagSignal.ts"],"names":[],"mappings":"AAAA,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACpC,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B,CAAC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACrC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;IAC1B,GAAG,EAAE,SAAS,MAAM,EAAE,CAAC;IACvB,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAwBH,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,gBAAgB,CAUhE;IAED,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,GAAG,iBAAiB,CAmBlE;CACJ"}
@@ -1,53 +0,0 @@
1
- export class InvalidTagSignalError extends TypeError {
2
- }
3
- const canonicalName = (term, prefix) => {
4
- const name = prefix === "" ? term : term.slice(1);
5
- if (name.length === 0
6
- || name.startsWith("+")
7
- || name.startsWith("-")
8
- || /[[\],\s\p{Cc}]/u.test(name)) {
9
- throw new InvalidTagSignalError(`invalid log tag term '${term}'`);
10
- }
11
- // #433 — a matcher written in the signal slot (`[/require/]`, `[$.a]`, `[~topic]`, `[&x]`)
12
- // would otherwise be applied as a folksonomic tag of that name.
13
- if (/^[/$~&]/.test(name)) {
14
- throw new InvalidTagSignalError(`\`[${term}]\` is not a tag - a matcher belongs in the body beneath the heading; \`[+tag]\` adds, \`[tag]\` filters`);
15
- }
16
- return name;
17
- };
18
- const unique = (values) => [...new Set(values)];
19
- export default class TagSignal {
20
- static applied(terms) {
21
- const add = (terms ?? []).map((term) => {
22
- if (term.startsWith("-")) {
23
- throw new InvalidTagSignalError(`classifying operations cannot remove tags; '${term}' is a removal`);
24
- }
25
- return canonicalName(term, term.startsWith("+") ? "+" : "");
26
- });
27
- return { add: unique(add) };
28
- }
29
- static curation(terms) {
30
- const filter = [];
31
- const add = [];
32
- const remove = [];
33
- for (const term of terms ?? []) {
34
- if (term.startsWith("+"))
35
- add.push(canonicalName(term, "+"));
36
- else if (term.startsWith("-"))
37
- remove.push(canonicalName(term, "-"));
38
- else
39
- filter.push(canonicalName(term, ""));
40
- }
41
- const result = {
42
- filter: unique(filter),
43
- add: unique(add),
44
- remove: unique(remove),
45
- };
46
- const conflict = result.add.find((tag) => result.remove.includes(tag));
47
- if (conflict !== undefined) {
48
- throw new InvalidTagSignalError(`a curation signal cannot both add and remove tag '${conflict}'`);
49
- }
50
- return result;
51
- }
52
- }
53
- //# sourceMappingURL=TagSignal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TagSignal.js","sourceRoot":"","sources":["../../src/TagSignal.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,qBAAsB,SAAQ,SAAS;CAAG;AAYvD,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,MAAsB,EAAU,EAAE;IACnE,MAAM,IAAI,GAAG,MAAM,KAAK,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAClD,IACI,IAAI,CAAC,MAAM,KAAK,CAAC;WACd,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;WACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;WACpB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EACjC,CAAC;QACC,MAAM,IAAI,qBAAqB,CAAC,yBAAyB,IAAI,GAAG,CAAC,CAAC;IACtE,CAAC;IACD,2FAA2F;IAC3F,gEAAgE;IAChE,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,qBAAqB,CAC3B,MAAM,IAAI,0GAA0G,CACvH,CAAC;IACN,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,MAAyB,EAAY,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7E,MAAM,CAAC,OAAO,OAAO,SAAS;IAC1B,MAAM,CAAC,OAAO,CAAC,KAA+B;QAC1C,MA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