@shrkcrft/boundaries 0.1.0-alpha.28 → 0.1.0-alpha.29

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/index.d.ts CHANGED
@@ -11,6 +11,7 @@ export * from './wiring/explain-wiring.js';
11
11
  export * from './wiring/registry-query.js';
12
12
  export * from './wiring/registration-graph.js';
13
13
  export * from './wiring/trace-literal.js';
14
+ export * from './wiring/plan-wiring-fix.js';
14
15
  export * from './policy/extract-templates.js';
15
16
  export * from './policy/evaluate-policy.js';
16
17
  export * from './policy/run-policy.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ export * from "./wiring/explain-wiring.js";
11
11
  export * from "./wiring/registry-query.js";
12
12
  export * from "./wiring/registration-graph.js";
13
13
  export * from "./wiring/trace-literal.js";
14
+ export * from "./wiring/plan-wiring-fix.js";
14
15
  export * from "./policy/extract-templates.js";
15
16
  export * from "./policy/evaluate-policy.js";
16
17
  export * from "./policy/run-policy.js";
@@ -1,4 +1,4 @@
1
- import type { IPolicyRule, PolicySurface } from '@shrkcrft/core';
1
+ import { type IPolicyRule, type PolicySurface } from '@shrkcrft/core';
2
2
  export declare const POLICY_LINT_SCHEMA: "sharkcraft.policy-lint/v1";
3
3
  /**
4
4
  * A chunk of content to scan for one rule. For whole files `baseLine` is 1; for
@@ -1 +1 @@
1
- {"version":3,"file":"evaluate-policy.d.ts","sourceRoot":"","sources":["../../src/policy/evaluate-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIjF,eAAO,MAAM,kBAAkB,EAAG,2BAAoC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;IAClC,wEAAwE;IACxE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MA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AM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,kBAAkB,CAAC;IAC3C,QAAQ,CAAC,KAAK,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACnD,kCAAkC;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;CAClD;AAED,6FAA6F;AAC7F,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,WAAW,KAAK,SAAS,WAAW,EAAE,CAAC;AA0C/E;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,EAAE,OAAO,EAAE,kBAAkB,GAAG,aAAa,CAyJxG"}
@@ -1,3 +1,4 @@
1
+ import { failsWhenEmpty } from '@shrkcrft/core';
1
2
  import { lexCodeZones, zoneAt } from "../extract/code-zones.js";
2
3
  import { safeCompile } from "../util/safe-regex.js";
3
4
  export const POLICY_LINT_SCHEMA = 'sharkcraft.policy-lint/v1';
@@ -152,7 +153,7 @@ export function evaluatePolicy(rules, resolve) {
152
153
  continue;
153
154
  }
154
155
  if (units.length === 0) {
155
- const failed = rule.failOnEmpty === true;
156
+ const failed = failsWhenEmpty(rule);
156
157
  skipped.push({
157
158
  ruleId: rule.id,
158
159
  reason: '0 content units matched the rule globs',
@@ -1 +1 @@
1
- {"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AAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;CAClD;AAED,mFAAmF;AACnF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,aAAa,KAAK,SAAS,gBAAgB,EAAE,CAAC;AAExF,mFAAmF;AACnF,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC,GAAG,SAAS,aAAa,EAAE,CAG1F;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa,GAAG,SAAS,CAG7E;AAED,4DAA4D;AAC5D,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,SAAS,aAAa,EAAE,CAM3E;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,EAAE,CAEzD;AAmBD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,SAAS,gBAAgB,EAAE,GACjC;IAAE,KAAK,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAGxD;AAyCD,mFAAmF;AACnF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS,CAyBxE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,SAAS,WAAW,EAAE,EAC7B,OAAO,EAAE,kBAAkB,GAC1B,aAAa,CAoMf"}
@@ -1,4 +1,4 @@
1
- import { validateWiringSource, } from '@shrkcrft/core';
1
+ import { failsWhenEmpty, validateWiringSource, } from '@shrkcrft/core';
2
2
  import { extractTokens, } from "../extract/extract-tokens.js";
3
3
  export const WIRING_SCHEMA = 'sharkcraft.wiring/v1';
4
4
  /** Normalize the `registered` field (single source or union array) to an array. */
@@ -277,7 +277,7 @@ export function evaluateWiring(rules, resolve) {
277
277
  ? '0 ids extracted from the source side'
278
278
  : undefined;
279
279
  if (skipReason !== undefined) {
280
- const failed = rule.failOnEmpty === true;
280
+ const failed = failsWhenEmpty(rule);
281
281
  skipped.push({ ruleId: rule.id, reason: skipReason, failed, severity });
282
282
  if (failed) {
283
283
  if (severity === 'error')
@@ -0,0 +1,60 @@
1
+ import type { IWiringRule } from '@shrkcrft/core';
2
+ import { type IWiringViolation } from './evaluate-wiring.js';
3
+ export declare const WIRING_FIX_SCHEMA: "sharkcraft.wiring-fix/v1";
4
+ /** Why a violation could not be fixed mechanically. */
5
+ export type WiringFixRefusal =
6
+ /** More than one registered sink — which array should it go in? */
7
+ 'ambiguous-sink'
8
+ /** The sink is not an array literal the engine can append to. */
9
+ | 'sink-not-an-array'
10
+ /** The sink glob resolves to several files, or none. */
11
+ | 'ambiguous-sink-file'
12
+ /** The array literal could not be located in the sink file. */
13
+ | 'array-not-found'
14
+ /** The token is a quoted string in the sink; the declared side is a symbol (or vice versa). */
15
+ | 'token-shape-mismatch';
16
+ /** One planned edit: append `token` into the anchor array of `file`. */
17
+ export interface IWiringFixEdit {
18
+ readonly ruleId: string;
19
+ readonly token: string;
20
+ /** Project-relative sink file the edit lands in. */
21
+ readonly file: string;
22
+ /** 1-based line of the array's closing bracket, where the token is inserted before. */
23
+ readonly line: number;
24
+ /** The exact text inserted, including indentation and trailing comma. */
25
+ readonly insert: string;
26
+ /** The full new file contents, ready to write. */
27
+ readonly nextContent: string;
28
+ }
29
+ /** A violation the planner deliberately did not touch. */
30
+ export interface IWiringFixSkip {
31
+ readonly ruleId: string;
32
+ readonly token: string;
33
+ readonly reason: WiringFixRefusal;
34
+ readonly detail: string;
35
+ }
36
+ export interface IWiringFixPlan {
37
+ readonly schema: typeof WIRING_FIX_SCHEMA;
38
+ readonly edits: readonly IWiringFixEdit[];
39
+ readonly skipped: readonly IWiringFixSkip[];
40
+ }
41
+ /** A file the planner may read/rewrite. */
42
+ export interface IWiringFixFile {
43
+ readonly path: string;
44
+ readonly content: string;
45
+ }
46
+ /**
47
+ * Plan the mechanically-unambiguous fixes for `declared-but-not-registered`
48
+ * violations.
49
+ *
50
+ * The bar is deliberately high, because a wrong autofix in a gate is worse than
51
+ * no autofix: the tool would be writing the very thing it is supposed to
52
+ * verify. An edit is planned ONLY when there is exactly one registered sink,
53
+ * that sink is an `array-members` source, its glob resolves to exactly one
54
+ * file, and the anchor array is found exactly once in it. Every other shape is
55
+ * reported as skipped WITH the reason — never guessed at.
56
+ *
57
+ * Pure: the caller supplies file contents and performs any writes.
58
+ */
59
+ export declare function planWiringFix(rule: IWiringRule, violations: readonly IWiringViolation[], files: readonly IWiringFixFile[]): IWiringFixPlan;
60
+ //# sourceMappingURL=plan-wiring-fix.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan-wiring-fix.d.ts","sourceRoot":"","sources":["../../src/wiring/plan-wiring-fix.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAiB,MAAM,gBAAgB,CAAC;AAGjE,OAAO,EAAqB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGhF,eAAO,MAAM,iBAAiB,EAAG,0BAAmC,CAAC;AAErE,uDAAuD;AACvD,MAAM,MAAM,gBAAgB;AAC1B,mEAAmE;AACjE,gBAAgB;AAClB,iEAAiE;GAC/D,mBAAmB;AACrB,wDAAwD;GACtD,qBAAqB;AACvB,+DAA+D;GAC7D,iBAAiB;AACnB,+FAA+F;GAC7F,sBAAsB,CAAC;AAE3B,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,0DAA0D;AAC1D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,MAAM,EAAE,OAAO,iBAAiB,CAAC;IAC1C,QAAQ,CAAC,KAAK,EAAE,SAAS,cAAc,EAAE,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;CAC7C;AAED,2CAA2C;AAC3C,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAiBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,WAAW,EACjB,UAAU,EAAE,SAAS,gBAAgB,EAAE,EACvC,KAAK,EAAE,SAAS,cAAc,EAAE,GAC/B,cAAc,CAqHhB"}
@@ -0,0 +1,129 @@
1
+ import { matchesAny } from "../scan/glob.js";
2
+ import { escapeRegex, scanBalanced } from "../extract/scan-literals.js";
3
+ import { registeredSources } from "./evaluate-wiring.js";
4
+ import { resolveExtractorAnchor, resolveExtractorKind } from '@shrkcrft/core';
5
+ export const WIRING_FIX_SCHEMA = 'sharkcraft.wiring-fix/v1';
6
+ /** Indentation of the line containing `index`. */
7
+ function indentOf(content, index) {
8
+ const lineStart = content.lastIndexOf('\n', index - 1) + 1;
9
+ const m = /^[ \t]*/.exec(content.slice(lineStart, index));
10
+ return m ? m[0] : ' ';
11
+ }
12
+ function lineOf(content, index) {
13
+ let line = 1;
14
+ for (let i = 0; i < index && i < content.length; i += 1) {
15
+ if (content[i] === '\n')
16
+ line += 1;
17
+ }
18
+ return line;
19
+ }
20
+ /**
21
+ * Plan the mechanically-unambiguous fixes for `declared-but-not-registered`
22
+ * violations.
23
+ *
24
+ * The bar is deliberately high, because a wrong autofix in a gate is worse than
25
+ * no autofix: the tool would be writing the very thing it is supposed to
26
+ * verify. An edit is planned ONLY when there is exactly one registered sink,
27
+ * that sink is an `array-members` source, its glob resolves to exactly one
28
+ * file, and the anchor array is found exactly once in it. Every other shape is
29
+ * reported as skipped WITH the reason — never guessed at.
30
+ *
31
+ * Pure: the caller supplies file contents and performs any writes.
32
+ */
33
+ export function planWiringFix(rule, violations, files) {
34
+ const edits = [];
35
+ const skipped = [];
36
+ const declaredMissing = violations.filter((v) => v.ruleId === rule.id && v.direction === 'declared-missing');
37
+ if (declaredMissing.length === 0)
38
+ return { schema: WIRING_FIX_SCHEMA, edits, skipped };
39
+ const refuseAll = (reason, detail) => ({
40
+ schema: WIRING_FIX_SCHEMA,
41
+ edits: [],
42
+ skipped: declaredMissing.map((v) => ({ ruleId: rule.id, token: v.token, reason, detail })),
43
+ });
44
+ // A chain rule has no single "the sink"; refuse rather than pick one.
45
+ const sinks = rule.chain
46
+ ? []
47
+ : registeredSources(rule.registered);
48
+ if (sinks.length !== 1) {
49
+ return refuseAll('ambiguous-sink', sinks.length === 0
50
+ ? 'rule has no single registered sink (chain rules are never auto-fixed)'
51
+ : `rule has ${sinks.length} registered sinks — which one should the token join?`);
52
+ }
53
+ const sink = sinks[0];
54
+ if (resolveExtractorKind(sink) !== 'array-members') {
55
+ return refuseAll('sink-not-an-array', `sink uses extract "${resolveExtractorKind(sink) ?? 'unknown'}" — only an array literal can be appended to`);
56
+ }
57
+ const anchor = resolveExtractorAnchor(sink);
58
+ if (anchor === undefined)
59
+ return refuseAll('sink-not-an-array', 'sink declares no anchor');
60
+ const sinkFiles = files.filter((f) => matchesAny(f.path, sink.files ?? []));
61
+ if (sinkFiles.length !== 1) {
62
+ return refuseAll('ambiguous-sink-file', `sink glob matched ${sinkFiles.length} files — the insertion point must be unique`);
63
+ }
64
+ const target = sinkFiles[0];
65
+ // Locate the anchor array. More than one occurrence is ambiguous.
66
+ const head = new RegExp(`(?<![\\w$])${escapeRegex(anchor)}\\s*(?::[^=\\n]*)?[:=]\\s*(?:[A-Za-z_$][\\w$.]*\\s*\\(\\s*)?\\[`, 'g');
67
+ const opens = [];
68
+ let m;
69
+ while ((m = head.exec(target.content)) !== null)
70
+ opens.push(m.index + m[0].length - 1);
71
+ if (opens.length !== 1) {
72
+ return refuseAll('array-not-found', opens.length === 0
73
+ ? `array \`${anchor}\` not found in ${target.path}`
74
+ : `array \`${anchor}\` appears ${opens.length} times in ${target.path}`);
75
+ }
76
+ const openIndex = opens[0];
77
+ const { elements, end } = scanBalanced(target.content, openIndex);
78
+ // Match the shape of what is already in the array: bare identifiers vs
79
+ // quoted strings. Inserting the wrong shape would compile-fail or silently
80
+ // not match on the next run.
81
+ const firstEl = elements[0]?.text ?? '';
82
+ const quoted = firstEl.startsWith("'") || firstEl.startsWith('"');
83
+ const quoteChar = firstEl.startsWith('"') ? '"' : "'";
84
+ // Build all edits against one evolving buffer so multiple tokens accumulate.
85
+ let content = target.content;
86
+ let insertAt = end;
87
+ for (const v of declaredMissing) {
88
+ // Re-locate the closing bracket after each insertion.
89
+ const reHead = new RegExp(head.source, 'g');
90
+ const mm = reHead.exec(content);
91
+ if (!mm) {
92
+ skipped.push({
93
+ ruleId: rule.id,
94
+ token: v.token,
95
+ reason: 'array-not-found',
96
+ detail: `array \`${anchor}\` vanished mid-plan in ${target.path}`,
97
+ });
98
+ continue;
99
+ }
100
+ const open = mm.index + mm[0].length - 1;
101
+ const scan = scanBalanced(content, open);
102
+ insertAt = scan.end;
103
+ const last = scan.elements[scan.elements.length - 1];
104
+ const indent = last ? indentOf(content, last.index) : ' ';
105
+ const multiline = content.slice(open, insertAt).includes('\n');
106
+ const rendered = quoted ? `${quoteChar}${v.token}${quoteChar}` : v.token;
107
+ // Insert after the last non-whitespace character, and KEEP the whitespace
108
+ // run that precedes the closing bracket — trimming it would drag `]` up
109
+ // onto the last element's line and reformat code the user did not ask us
110
+ // to touch.
111
+ const beforeInsert = content.slice(0, insertAt).replace(/\s+$/, '');
112
+ const cut = beforeInsert.length;
113
+ const tail = content.slice(cut, insertAt);
114
+ const needsComma = scan.elements.length > 0 && !beforeInsert.endsWith(',');
115
+ const insert = multiline
116
+ ? `${needsComma ? ',' : ''}\n${indent}${rendered},`
117
+ : `${needsComma ? ', ' : ''}${rendered}`;
118
+ content = content.slice(0, cut) + insert + tail + content.slice(insertAt);
119
+ edits.push({
120
+ ruleId: rule.id,
121
+ token: v.token,
122
+ file: target.path,
123
+ line: lineOf(content, cut + insert.length),
124
+ insert: insert.trim(),
125
+ nextContent: content,
126
+ });
127
+ }
128
+ return { schema: WIRING_FIX_SCHEMA, edits, skipped };
129
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shrkcrft/boundaries",
3
- "version": "0.1.0-alpha.28",
3
+ "version": "0.1.0-alpha.29",
4
4
  "description": "SharkCraft boundary rules: detect when a repository violates its own architecture (forbidden imports across folder/package/layer boundaries).",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
@@ -43,7 +43,7 @@
43
43
  "typecheck": "tsc --noEmit -p tsconfig.json"
44
44
  },
45
45
  "dependencies": {
46
- "@shrkcrft/core": "^0.1.0-alpha.28"
46
+ "@shrkcrft/core": "^0.1.0-alpha.29"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"