@shrkcrft/inspector 0.1.0-alpha.7 → 0.1.0-alpha.9
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/README.md +1 -1
- package/dist/adoption-state.js +1 -1
- package/dist/area-map.d.ts +14 -0
- package/dist/area-map.d.ts.map +1 -1
- package/dist/area-map.js +17 -0
- package/dist/ci-permissions-fix.d.ts +1 -1
- package/dist/ci-permissions-fix.d.ts.map +1 -1
- package/dist/ci-permissions-fix.js +182 -1
- package/dist/construct-adoption-diff.d.ts.map +1 -1
- package/dist/construct-adoption-diff.js +1 -2
- package/dist/construct-adoption.d.ts.map +1 -1
- package/dist/construct-adoption.js +10 -2
- package/dist/construct-inference.d.ts.map +1 -1
- package/dist/construct-inference.js +1 -2
- package/dist/construct-registry.d.ts.map +1 -1
- package/dist/construct-registry.js +10 -2
- package/dist/contract-template-registry.d.ts.map +1 -1
- package/dist/contract-template-registry.js +10 -2
- package/dist/convention-registry.d.ts.map +1 -1
- package/dist/convention-registry.js +10 -2
- package/dist/decision-records.d.ts.map +1 -1
- package/dist/decision-records.js +9 -2
- package/dist/feedback-ingestion.js +10 -2
- package/dist/git-helpers.d.ts +12 -0
- package/dist/git-helpers.d.ts.map +1 -1
- package/dist/git-helpers.js +63 -0
- package/dist/impact-render.d.ts.map +1 -1
- package/dist/impact-render.js +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/ingest-drafts.js +4 -8
- package/dist/migration-profile-registry.d.ts.map +1 -1
- package/dist/migration-profile-registry.js +10 -2
- package/dist/onboarding-drafts-merge.d.ts +71 -0
- package/dist/onboarding-drafts-merge.d.ts.map +1 -0
- package/dist/onboarding-drafts-merge.js +174 -0
- package/dist/onboarding-drafts.d.ts +14 -0
- package/dist/onboarding-drafts.d.ts.map +1 -1
- package/dist/onboarding-drafts.js +39 -5
- package/dist/ownership.js +10 -2
- package/dist/pack-helper-registry.d.ts.map +1 -1
- package/dist/pack-helper-registry.js +10 -2
- package/dist/pack-release-check.d.ts.map +1 -1
- package/dist/pack-release-check.js +10 -3
- package/dist/pack-symbol-compat.d.ts +17 -4
- package/dist/pack-symbol-compat.d.ts.map +1 -1
- package/dist/pack-symbol-compat.js +155 -7
- package/dist/pack-test-runner.js +10 -2
- package/dist/playbook-registry.d.ts.map +1 -1
- package/dist/playbook-registry.js +10 -2
- package/dist/plugin-lifecycle-profile-registry.d.ts.map +1 -1
- package/dist/plugin-lifecycle-profile-registry.js +10 -2
- package/dist/policy-engine.d.ts.map +1 -1
- package/dist/policy-engine.js +11 -3
- package/dist/policy-test.js +11 -3
- package/dist/product-coherence.js +5 -5
- package/dist/registration-hint-registry.d.ts.map +1 -1
- package/dist/registration-hint-registry.js +10 -2
- package/dist/release-readiness.js +2 -2
- package/dist/review-packet-v2.d.ts.map +1 -1
- package/dist/review-packet-v2.js +13 -3
- package/dist/rule-scaffold.d.ts.map +1 -1
- package/dist/rule-scaffold.js +4 -12
- package/dist/scaffold-patterns.js +10 -2
- package/dist/search-tuning-registry.d.ts.map +1 -1
- package/dist/search-tuning-registry.js +10 -2
- package/dist/sharkcraft-inspector.d.ts.map +1 -1
- package/dist/sharkcraft-inspector.js +0 -1
- package/dist/task-routing-hint-registry.d.ts.map +1 -1
- package/dist/task-routing-hint-registry.js +10 -2
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +11 -3
- package/dist/upgrade-advisor.js +1 -1
- package/package.json +21 -22
package/dist/git-helpers.js
CHANGED
|
@@ -29,6 +29,69 @@ export function getGitBranch(cwd) {
|
|
|
29
29
|
const out = r.stdout.trim();
|
|
30
30
|
return out.length > 0 ? out : null;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Verify that `ref` resolves to a commit. Returns `{ valid: true }` on
|
|
34
|
+
* success, otherwise `{ valid: false, suggestions }` listing nearby
|
|
35
|
+
* branch / tag names so the caller can offer a did-you-mean.
|
|
36
|
+
*
|
|
37
|
+
* Cheap (`git rev-parse --verify` + `git for-each-ref`) — only run when
|
|
38
|
+
* the user passes an explicit ref.
|
|
39
|
+
*/
|
|
40
|
+
export function verifyGitRef(cwd, ref) {
|
|
41
|
+
if (!isGitRepo(cwd))
|
|
42
|
+
return { valid: false, suggestions: [] };
|
|
43
|
+
const r = runGit(cwd, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
|
|
44
|
+
if (r.ok)
|
|
45
|
+
return { valid: true };
|
|
46
|
+
// Collect candidate names from local + remote refs, then rank by Levenshtein.
|
|
47
|
+
const candidates = listRefNames(cwd);
|
|
48
|
+
const suggestions = nearestRefs(ref, candidates, 3);
|
|
49
|
+
return { valid: false, suggestions };
|
|
50
|
+
}
|
|
51
|
+
function listRefNames(cwd) {
|
|
52
|
+
const out = new Set();
|
|
53
|
+
const local = runGit(cwd, ['for-each-ref', '--format=%(refname:short)', 'refs/heads']);
|
|
54
|
+
if (local.ok)
|
|
55
|
+
for (const line of parseLines(local.stdout))
|
|
56
|
+
out.add(line);
|
|
57
|
+
const remote = runGit(cwd, ['for-each-ref', '--format=%(refname:short)', 'refs/remotes']);
|
|
58
|
+
if (remote.ok)
|
|
59
|
+
for (const line of parseLines(remote.stdout))
|
|
60
|
+
out.add(line);
|
|
61
|
+
const tags = runGit(cwd, ['for-each-ref', '--format=%(refname:short)', 'refs/tags']);
|
|
62
|
+
if (tags.ok)
|
|
63
|
+
for (const line of parseLines(tags.stdout))
|
|
64
|
+
out.add(line);
|
|
65
|
+
return [...out];
|
|
66
|
+
}
|
|
67
|
+
function nearestRefs(query, refs, k) {
|
|
68
|
+
const scored = refs.map((r) => ({ r, d: levenshtein(query, r) }));
|
|
69
|
+
scored.sort((a, b) => a.d - b.d);
|
|
70
|
+
return scored.slice(0, k).map((s) => s.r);
|
|
71
|
+
}
|
|
72
|
+
function levenshtein(a, b) {
|
|
73
|
+
if (a === b)
|
|
74
|
+
return 0;
|
|
75
|
+
const al = a.length;
|
|
76
|
+
const bl = b.length;
|
|
77
|
+
if (al === 0)
|
|
78
|
+
return bl;
|
|
79
|
+
if (bl === 0)
|
|
80
|
+
return al;
|
|
81
|
+
let prev = new Array(bl + 1);
|
|
82
|
+
let curr = new Array(bl + 1);
|
|
83
|
+
for (let j = 0; j <= bl; j += 1)
|
|
84
|
+
prev[j] = j;
|
|
85
|
+
for (let i = 1; i <= al; i += 1) {
|
|
86
|
+
curr[0] = i;
|
|
87
|
+
for (let j = 1; j <= bl; j += 1) {
|
|
88
|
+
const cost = a.charCodeAt(i - 1) === b.charCodeAt(j - 1) ? 0 : 1;
|
|
89
|
+
curr[j] = Math.min((prev[j] ?? 0) + 1, (curr[j - 1] ?? 0) + 1, (prev[j - 1] ?? 0) + cost);
|
|
90
|
+
}
|
|
91
|
+
[prev, curr] = [curr, prev];
|
|
92
|
+
}
|
|
93
|
+
return prev[bl] ?? Math.max(al, bl);
|
|
94
|
+
}
|
|
32
95
|
export function getChangedFiles(cwd, opts = {}) {
|
|
33
96
|
if (!isGitRepo(cwd))
|
|
34
97
|
return [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"impact-render.d.ts","sourceRoot":"","sources":["../src/impact-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA6BD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"impact-render.d.ts","sourceRoot":"","sources":["../src/impact-render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA6BD,UAAU,SAAS;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,SAAS,EAAE,CAAC;CACvB;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAC7B,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5C,SAAS,EAAE,CAiDb;AAiCD,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE,oBAAyB,GAC9B,MAAM,CAgER;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE,oBAAyB,GAC9B,MAAM,CAyGR;AAED,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,eAAe,EACvB,IAAI,GAAE,oBAAyB,GAC9B,MAAM,CAiIR"}
|
package/dist/impact-render.js
CHANGED
|
@@ -36,6 +36,11 @@ export function buildImpactTree(impact, opts = {}) {
|
|
|
36
36
|
for (let i = 0; i < chain.length - 1; i += 1) {
|
|
37
37
|
const importer = chain[i];
|
|
38
38
|
const target = chain[i + 1];
|
|
39
|
+
// Skip self-references — a file cannot import itself in the
|
|
40
|
+
// dependency tree we render. (Cycles do exist in import graphs,
|
|
41
|
+
// but the renderer's job is reviewer clarity, not topology.)
|
|
42
|
+
if (importer === target)
|
|
43
|
+
continue;
|
|
39
44
|
const set = importers.get(target) ?? new Set();
|
|
40
45
|
set.add(importer);
|
|
41
46
|
importers.set(target, set);
|
|
@@ -45,6 +50,10 @@ export function buildImpactTree(impact, opts = {}) {
|
|
|
45
50
|
for (const target of impact.normalizedTargets) {
|
|
46
51
|
const set = importers.get(target) ?? new Set();
|
|
47
52
|
for (const dep of impact.directDependents) {
|
|
53
|
+
// Skip self — a target appearing in its own directDependents list
|
|
54
|
+
// is a graph artifact, not a real edge to render.
|
|
55
|
+
if (dep === target)
|
|
56
|
+
continue;
|
|
48
57
|
// Heuristic: every direct dependent is a candidate importer of every
|
|
49
58
|
// target (the real graph is captured in dependencyPathExamples).
|
|
50
59
|
// We only add direct dependents if they don't already appear as
|
package/dist/index.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from './plan-review.js';
|
|
|
23
23
|
export * from './onboarding.js';
|
|
24
24
|
export * from './onboarding-report.js';
|
|
25
25
|
export * from './onboarding-drafts.js';
|
|
26
|
+
export * from './onboarding-drafts-merge.js';
|
|
26
27
|
export * from './onboarding-diff.js';
|
|
27
28
|
export * from './onboarding-adoption.js';
|
|
28
29
|
export * from './adoption-state.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,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B,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AAErC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,wCAAwC,CAAC;AAEvD,cAAc,gCAAgC,CAAC;AAE/C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export * from "./plan-review.js";
|
|
|
23
23
|
export * from "./onboarding.js";
|
|
24
24
|
export * from "./onboarding-report.js";
|
|
25
25
|
export * from "./onboarding-drafts.js";
|
|
26
|
+
export * from "./onboarding-drafts-merge.js";
|
|
26
27
|
export * from "./onboarding-diff.js";
|
|
27
28
|
export * from "./onboarding-adoption.js";
|
|
28
29
|
export * from "./adoption-state.js";
|
package/dist/ingest-drafts.js
CHANGED
|
@@ -341,8 +341,7 @@ function renderRulesDraft(model) {
|
|
|
341
341
|
})`);
|
|
342
342
|
}
|
|
343
343
|
return `${header('Rules inferred from repository ingestion.')}
|
|
344
|
-
|
|
345
|
-
function defineRule<T>(rule: T): T { return rule; }
|
|
344
|
+
import { defineRule } from '@shrkcrft/rules';
|
|
346
345
|
|
|
347
346
|
export const ingestedRules = [
|
|
348
347
|
${entries.join(',\n')}
|
|
@@ -359,8 +358,7 @@ function renderPathsDraft(model) {
|
|
|
359
358
|
patterns: ${JSON.stringify(p.patterns)},
|
|
360
359
|
})`);
|
|
361
360
|
return `${header('Path conventions inferred from repository ingestion.')}
|
|
362
|
-
|
|
363
|
-
function definePath<T>(path: T): T { return path; }
|
|
361
|
+
import { definePath } from '@shrkcrft/paths';
|
|
364
362
|
|
|
365
363
|
export const ingestedPaths = [
|
|
366
364
|
${entries.join(',\n')}
|
|
@@ -380,8 +378,7 @@ function renderBoundariesDraft(model) {
|
|
|
380
378
|
suggestedFix: ${JSON.stringify(b.suggestedFix)},
|
|
381
379
|
})`);
|
|
382
380
|
return `${header('Dependency-boundary rules inferred from repository ingestion.')}
|
|
383
|
-
|
|
384
|
-
function defineBoundary<T>(rule: T): T { return rule; }
|
|
381
|
+
import { defineBoundary } from '@shrkcrft/boundaries';
|
|
385
382
|
|
|
386
383
|
export const ingestedBoundaries = [
|
|
387
384
|
${entries.join(',\n')}
|
|
@@ -398,8 +395,7 @@ function renderConstructsDraft(model) {
|
|
|
398
395
|
files: ${JSON.stringify(c.paths)},
|
|
399
396
|
})`);
|
|
400
397
|
return `${header('Constructs inferred from repository ingestion.')}
|
|
401
|
-
|
|
402
|
-
function defineConstruct<T>(construct: T): T { return construct; }
|
|
398
|
+
import { defineConstruct } from '@shrkcrft/plugin-api';
|
|
403
399
|
|
|
404
400
|
export const ingestedConstructs = [
|
|
405
401
|
${entries.join(',\n')}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migration-profile-registry.d.ts","sourceRoot":"","sources":["../src/migration-profile-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"migration-profile-registry.d.ts","sourceRoot":"","sources":["../src/migration-profile-registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,iCAAiC,6CAA6C,CAAC;AAE5F,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,IAAI,SAAS;CACd;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,8BAA8B;IAC7C,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAkCD,wBAAsB,qBAAqB,CACzC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC;IACT,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAC;IAC3C,MAAM,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACnD,CAAC,CAkFD;AAED,wBAAsB,8BAA8B,CAClD,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAGvC"}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Migration profile registry. Loads pack-contributed migration profiles
|
|
3
11
|
* via `migrationProfileFiles` on pack manifests. Engine ships zero built-ins.
|
|
4
12
|
*/
|
|
5
13
|
import { existsSync } from 'node:fs';
|
|
6
14
|
import * as nodePath from 'node:path';
|
|
7
|
-
import {
|
|
15
|
+
import { pathToFileURL } from 'node:url';
|
|
8
16
|
export const MIGRATION_PROFILE_REGISTRY_SCHEMA = 'sharkcraft.migration-profile-registry/v1';
|
|
9
17
|
export var MigrationProfileSource;
|
|
10
18
|
(function (MigrationProfileSource) {
|
|
@@ -12,7 +20,7 @@ export var MigrationProfileSource;
|
|
|
12
20
|
MigrationProfileSource["Pack"] = "pack";
|
|
13
21
|
})(MigrationProfileSource || (MigrationProfileSource = {}));
|
|
14
22
|
async function importDefault(file) {
|
|
15
|
-
const mod = (await
|
|
23
|
+
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(file).href)));
|
|
16
24
|
if (Array.isArray(mod.default))
|
|
17
25
|
return mod.default;
|
|
18
26
|
if (mod.default && typeof mod.default === 'object')
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three-way merge for onboarding drafts.
|
|
3
|
+
*
|
|
4
|
+
* When `shrk onboard --write-drafts` re-runs against a project that has
|
|
5
|
+
* hand-edited drafts, the safe behaviour is to merge the new proposal
|
|
6
|
+
* against the user's current file and the snapshot we wrote last time:
|
|
7
|
+
*
|
|
8
|
+
* - base : `.sharkcraft/onboarding-drafts-snapshots/<file>` (what we
|
|
9
|
+
* wrote last). When absent, the merge degrades to a strict
|
|
10
|
+
* "matches proposal → no-op, otherwise conflict" rule.
|
|
11
|
+
* - ours : the current `sharkcraft/onboarding/<file>` content.
|
|
12
|
+
* - theirs : the freshly rendered proposal we are about to write.
|
|
13
|
+
*
|
|
14
|
+
* The merge always returns an intended `body`. The caller decides whether
|
|
15
|
+
* to write it (e.g. `abortOnConflict` keeps the file unchanged).
|
|
16
|
+
*/
|
|
17
|
+
export declare enum DraftMergeStatus {
|
|
18
|
+
/** File did not exist; the proposal was written verbatim. */
|
|
19
|
+
Created = "created",
|
|
20
|
+
/** Current file already matches the proposal — nothing to do. */
|
|
21
|
+
Unchanged = "unchanged",
|
|
22
|
+
/** Current file matches the snapshot; the proposal was applied. */
|
|
23
|
+
CleanUpdate = "clean-update",
|
|
24
|
+
/** Proposal matches the snapshot; the user's edits were kept. */
|
|
25
|
+
UserKept = "user-kept",
|
|
26
|
+
/** Disjoint single-region edits on both sides; auto-merged. */
|
|
27
|
+
AutoMerged = "auto-merged",
|
|
28
|
+
/** Both sides changed the same region — conflict markers emitted. */
|
|
29
|
+
Conflict = "conflict",
|
|
30
|
+
/** Both sides changed but `abortOnConflict` was set — file untouched. */
|
|
31
|
+
Aborted = "aborted"
|
|
32
|
+
}
|
|
33
|
+
export interface IDraftMergeOptions {
|
|
34
|
+
/** When true, return status=Aborted and leave the file unchanged on conflict. */
|
|
35
|
+
abortOnConflict?: boolean;
|
|
36
|
+
/** Header line in the `<<<<<<< ours` marker. Default 'ours'. */
|
|
37
|
+
oursLabel?: string;
|
|
38
|
+
/** Header line in the `>>>>>>> theirs` marker. Default 'incoming proposal'. */
|
|
39
|
+
theirsLabel?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface IDraftMergeResult {
|
|
42
|
+
status: DraftMergeStatus;
|
|
43
|
+
/** What should be written. For Aborted, this is the unchanged `ours`. */
|
|
44
|
+
body: string;
|
|
45
|
+
/** Number of conflict regions in `body` (0 unless status=Conflict). */
|
|
46
|
+
conflictRegions: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the snapshot path for a given draft file.
|
|
50
|
+
*
|
|
51
|
+
* @param projectRoot Absolute repo root.
|
|
52
|
+
* @param draftPath Absolute path of the draft file.
|
|
53
|
+
*/
|
|
54
|
+
export declare function snapshotPathFor(projectRoot: string, draftPath: string): string;
|
|
55
|
+
export declare function readSnapshot(snapshotPath: string): string | null;
|
|
56
|
+
export declare function writeSnapshot(snapshotPath: string, body: string): void;
|
|
57
|
+
/**
|
|
58
|
+
* Three-way merge a single draft file.
|
|
59
|
+
*
|
|
60
|
+
* Truth table:
|
|
61
|
+
* - !exists(ours) → Created (body = theirs)
|
|
62
|
+
* - ours === theirs → Unchanged
|
|
63
|
+
* - base === null:
|
|
64
|
+
* - ours === theirs → Unchanged
|
|
65
|
+
* - otherwise → Conflict (or Aborted)
|
|
66
|
+
* - ours === base → CleanUpdate (body = theirs)
|
|
67
|
+
* - theirs === base → UserKept (body = ours)
|
|
68
|
+
* - otherwise → diff3Lines → AutoMerged | Conflict | Aborted
|
|
69
|
+
*/
|
|
70
|
+
export declare function threeWayMergeDraft(base: string | null, ours: string | null, theirs: string, options?: IDraftMergeOptions): IDraftMergeResult;
|
|
71
|
+
//# sourceMappingURL=onboarding-drafts-merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onboarding-drafts-merge.d.ts","sourceRoot":"","sources":["../src/onboarding-drafts-merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAKH,oBAAY,gBAAgB;IAC1B,6DAA6D;IAC7D,OAAO,YAAY;IACnB,iEAAiE;IACjE,SAAS,cAAc;IACvB,mEAAmE;IACnE,WAAW,iBAAiB;IAC5B,iEAAiE;IACjE,QAAQ,cAAc;IACtB,+DAA+D;IAC/D,UAAU,gBAAgB;IAC1B,qEAAqE;IACrE,QAAQ,aAAa;IACrB,yEAAyE;IACzE,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,iFAAiF;IACjF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,gBAAgB,CAAC;IACzB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAG9E;AAED,wBAAgB,YAAY,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOhE;AAED,wBAAgB,aAAa,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAGtE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,IAAI,EAAE,MAAM,GAAG,IAAI,EACnB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAiBnB"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three-way merge for onboarding drafts.
|
|
3
|
+
*
|
|
4
|
+
* When `shrk onboard --write-drafts` re-runs against a project that has
|
|
5
|
+
* hand-edited drafts, the safe behaviour is to merge the new proposal
|
|
6
|
+
* against the user's current file and the snapshot we wrote last time:
|
|
7
|
+
*
|
|
8
|
+
* - base : `.sharkcraft/onboarding-drafts-snapshots/<file>` (what we
|
|
9
|
+
* wrote last). When absent, the merge degrades to a strict
|
|
10
|
+
* "matches proposal → no-op, otherwise conflict" rule.
|
|
11
|
+
* - ours : the current `sharkcraft/onboarding/<file>` content.
|
|
12
|
+
* - theirs : the freshly rendered proposal we are about to write.
|
|
13
|
+
*
|
|
14
|
+
* The merge always returns an intended `body`. The caller decides whether
|
|
15
|
+
* to write it (e.g. `abortOnConflict` keeps the file unchanged).
|
|
16
|
+
*/
|
|
17
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
18
|
+
import * as nodePath from 'node:path';
|
|
19
|
+
export var DraftMergeStatus;
|
|
20
|
+
(function (DraftMergeStatus) {
|
|
21
|
+
/** File did not exist; the proposal was written verbatim. */
|
|
22
|
+
DraftMergeStatus["Created"] = "created";
|
|
23
|
+
/** Current file already matches the proposal — nothing to do. */
|
|
24
|
+
DraftMergeStatus["Unchanged"] = "unchanged";
|
|
25
|
+
/** Current file matches the snapshot; the proposal was applied. */
|
|
26
|
+
DraftMergeStatus["CleanUpdate"] = "clean-update";
|
|
27
|
+
/** Proposal matches the snapshot; the user's edits were kept. */
|
|
28
|
+
DraftMergeStatus["UserKept"] = "user-kept";
|
|
29
|
+
/** Disjoint single-region edits on both sides; auto-merged. */
|
|
30
|
+
DraftMergeStatus["AutoMerged"] = "auto-merged";
|
|
31
|
+
/** Both sides changed the same region — conflict markers emitted. */
|
|
32
|
+
DraftMergeStatus["Conflict"] = "conflict";
|
|
33
|
+
/** Both sides changed but `abortOnConflict` was set — file untouched. */
|
|
34
|
+
DraftMergeStatus["Aborted"] = "aborted";
|
|
35
|
+
})(DraftMergeStatus || (DraftMergeStatus = {}));
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the snapshot path for a given draft file.
|
|
38
|
+
*
|
|
39
|
+
* @param projectRoot Absolute repo root.
|
|
40
|
+
* @param draftPath Absolute path of the draft file.
|
|
41
|
+
*/
|
|
42
|
+
export function snapshotPathFor(projectRoot, draftPath) {
|
|
43
|
+
const rel = nodePath.relative(nodePath.join(projectRoot, 'sharkcraft', 'onboarding'), draftPath);
|
|
44
|
+
return nodePath.join(projectRoot, '.sharkcraft', 'onboarding-drafts-snapshots', rel);
|
|
45
|
+
}
|
|
46
|
+
export function readSnapshot(snapshotPath) {
|
|
47
|
+
if (!existsSync(snapshotPath))
|
|
48
|
+
return null;
|
|
49
|
+
try {
|
|
50
|
+
return readFileSync(snapshotPath, 'utf8');
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export function writeSnapshot(snapshotPath, body) {
|
|
57
|
+
mkdirSync(nodePath.dirname(snapshotPath), { recursive: true });
|
|
58
|
+
writeFileSync(snapshotPath, body, 'utf8');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Three-way merge a single draft file.
|
|
62
|
+
*
|
|
63
|
+
* Truth table:
|
|
64
|
+
* - !exists(ours) → Created (body = theirs)
|
|
65
|
+
* - ours === theirs → Unchanged
|
|
66
|
+
* - base === null:
|
|
67
|
+
* - ours === theirs → Unchanged
|
|
68
|
+
* - otherwise → Conflict (or Aborted)
|
|
69
|
+
* - ours === base → CleanUpdate (body = theirs)
|
|
70
|
+
* - theirs === base → UserKept (body = ours)
|
|
71
|
+
* - otherwise → diff3Lines → AutoMerged | Conflict | Aborted
|
|
72
|
+
*/
|
|
73
|
+
export function threeWayMergeDraft(base, ours, theirs, options = {}) {
|
|
74
|
+
if (ours === null) {
|
|
75
|
+
return { status: DraftMergeStatus.Created, body: theirs, conflictRegions: 0 };
|
|
76
|
+
}
|
|
77
|
+
if (ours === theirs) {
|
|
78
|
+
return { status: DraftMergeStatus.Unchanged, body: ours, conflictRegions: 0 };
|
|
79
|
+
}
|
|
80
|
+
if (base === null) {
|
|
81
|
+
return wholeFileConflict(ours, theirs, options);
|
|
82
|
+
}
|
|
83
|
+
if (ours === base) {
|
|
84
|
+
return { status: DraftMergeStatus.CleanUpdate, body: theirs, conflictRegions: 0 };
|
|
85
|
+
}
|
|
86
|
+
if (theirs === base) {
|
|
87
|
+
return { status: DraftMergeStatus.UserKept, body: ours, conflictRegions: 0 };
|
|
88
|
+
}
|
|
89
|
+
return diff3Lines(base, ours, theirs, options);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Coarse-grained line-level three-way merge.
|
|
93
|
+
*
|
|
94
|
+
* Strips the common prefix and suffix lines, then inspects the centre:
|
|
95
|
+
* - centre(ours) === centre(base) → take theirs
|
|
96
|
+
* - centre(theirs) === centre(base) → take ours
|
|
97
|
+
* - centre(ours) === centre(theirs) → take either
|
|
98
|
+
* - otherwise → emit conflict markers around the centre
|
|
99
|
+
*
|
|
100
|
+
* Multiple disjoint edit regions fall through to conflict; that's a
|
|
101
|
+
* deliberate trade-off — anything subtler than a single contiguous edit
|
|
102
|
+
* is exactly the case a human should review.
|
|
103
|
+
*/
|
|
104
|
+
function diff3Lines(base, ours, theirs, options) {
|
|
105
|
+
const baseLines = base.split('\n');
|
|
106
|
+
const oursLines = ours.split('\n');
|
|
107
|
+
const theirsLines = theirs.split('\n');
|
|
108
|
+
let prefix = 0;
|
|
109
|
+
const maxPrefix = Math.min(baseLines.length, oursLines.length, theirsLines.length);
|
|
110
|
+
while (prefix < maxPrefix &&
|
|
111
|
+
baseLines[prefix] === oursLines[prefix] &&
|
|
112
|
+
baseLines[prefix] === theirsLines[prefix]) {
|
|
113
|
+
prefix += 1;
|
|
114
|
+
}
|
|
115
|
+
let suffix = 0;
|
|
116
|
+
const maxSuffix = Math.min(baseLines.length, oursLines.length, theirsLines.length) - prefix;
|
|
117
|
+
while (suffix < maxSuffix &&
|
|
118
|
+
baseLines[baseLines.length - 1 - suffix] === oursLines[oursLines.length - 1 - suffix] &&
|
|
119
|
+
baseLines[baseLines.length - 1 - suffix] === theirsLines[theirsLines.length - 1 - suffix]) {
|
|
120
|
+
suffix += 1;
|
|
121
|
+
}
|
|
122
|
+
const baseCentre = baseLines.slice(prefix, baseLines.length - suffix).join('\n');
|
|
123
|
+
const oursCentre = oursLines.slice(prefix, oursLines.length - suffix).join('\n');
|
|
124
|
+
const theirsCentre = theirsLines.slice(prefix, theirsLines.length - suffix).join('\n');
|
|
125
|
+
const headLines = oursLines.slice(0, prefix);
|
|
126
|
+
const tailLines = oursLines.slice(oursLines.length - suffix);
|
|
127
|
+
if (oursCentre === baseCentre) {
|
|
128
|
+
// Only theirs diverged.
|
|
129
|
+
const merged = [...headLines, ...theirsLines.slice(prefix, theirsLines.length - suffix), ...tailLines].join('\n');
|
|
130
|
+
return { status: DraftMergeStatus.AutoMerged, body: merged, conflictRegions: 0 };
|
|
131
|
+
}
|
|
132
|
+
if (theirsCentre === baseCentre) {
|
|
133
|
+
// Only ours diverged.
|
|
134
|
+
return { status: DraftMergeStatus.UserKept, body: ours, conflictRegions: 0 };
|
|
135
|
+
}
|
|
136
|
+
if (oursCentre === theirsCentre) {
|
|
137
|
+
// Both sides made identical changes.
|
|
138
|
+
const merged = [...headLines, ...oursLines.slice(prefix, oursLines.length - suffix), ...tailLines].join('\n');
|
|
139
|
+
return { status: DraftMergeStatus.AutoMerged, body: merged, conflictRegions: 0 };
|
|
140
|
+
}
|
|
141
|
+
if (options.abortOnConflict) {
|
|
142
|
+
return { status: DraftMergeStatus.Aborted, body: ours, conflictRegions: 1 };
|
|
143
|
+
}
|
|
144
|
+
const oursLabel = options.oursLabel ?? 'ours';
|
|
145
|
+
const theirsLabel = options.theirsLabel ?? 'incoming proposal';
|
|
146
|
+
const markerOpen = `<<<<<<< ${oursLabel}`;
|
|
147
|
+
const markerMid = '=======';
|
|
148
|
+
const markerClose = `>>>>>>> ${theirsLabel}`;
|
|
149
|
+
const conflictBlock = [
|
|
150
|
+
markerOpen,
|
|
151
|
+
oursCentre,
|
|
152
|
+
markerMid,
|
|
153
|
+
theirsCentre,
|
|
154
|
+
markerClose,
|
|
155
|
+
];
|
|
156
|
+
const body = [...headLines, ...conflictBlock, ...tailLines].join('\n');
|
|
157
|
+
return { status: DraftMergeStatus.Conflict, body, conflictRegions: 1 };
|
|
158
|
+
}
|
|
159
|
+
function wholeFileConflict(ours, theirs, options) {
|
|
160
|
+
if (options.abortOnConflict) {
|
|
161
|
+
return { status: DraftMergeStatus.Aborted, body: ours, conflictRegions: 1 };
|
|
162
|
+
}
|
|
163
|
+
const oursLabel = options.oursLabel ?? 'ours';
|
|
164
|
+
const theirsLabel = options.theirsLabel ?? 'incoming proposal';
|
|
165
|
+
const body = [
|
|
166
|
+
`<<<<<<< ${oursLabel}`,
|
|
167
|
+
ours.replace(/\n$/, ''),
|
|
168
|
+
'=======',
|
|
169
|
+
theirs.replace(/\n$/, ''),
|
|
170
|
+
`>>>>>>> ${theirsLabel}`,
|
|
171
|
+
'',
|
|
172
|
+
].join('\n');
|
|
173
|
+
return { status: DraftMergeStatus.Conflict, body, conflictRegions: 1 };
|
|
174
|
+
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { IOnboardingPlan } from './onboarding.js';
|
|
2
2
|
import type { IImportedAgentRulesBundle } from './onboarding-agent-import.js';
|
|
3
|
+
import { DraftMergeStatus } from './onboarding-drafts-merge.js';
|
|
3
4
|
export interface IWrittenDraft {
|
|
4
5
|
path: string;
|
|
5
6
|
bytes: number;
|
|
7
|
+
/** Three-way merge status for this draft. */
|
|
8
|
+
mergeStatus: DraftMergeStatus;
|
|
9
|
+
/** Number of conflict regions emitted into `path` (0 unless status=Conflict). */
|
|
10
|
+
conflictRegions: number;
|
|
6
11
|
}
|
|
7
12
|
export interface IWriteOnboardingDraftsOptions {
|
|
8
13
|
projectRoot: string;
|
|
@@ -14,10 +19,19 @@ export interface IWriteOnboardingDraftsOptions {
|
|
|
14
19
|
* The file is still under the onboarding/ subdir — never written to rules.ts.
|
|
15
20
|
*/
|
|
16
21
|
importedAgentRules?: IImportedAgentRulesBundle;
|
|
22
|
+
/**
|
|
23
|
+
* When true, conflicts leave the existing file unchanged and report status
|
|
24
|
+
* via the result. Useful for CI gates.
|
|
25
|
+
*/
|
|
26
|
+
abortOnConflict?: boolean;
|
|
17
27
|
}
|
|
18
28
|
export interface IWriteOnboardingDraftsResult {
|
|
19
29
|
outDir: string;
|
|
20
30
|
files: IWrittenDraft[];
|
|
31
|
+
/** Total number of draft files that ended in a Conflict status. */
|
|
32
|
+
conflicts: number;
|
|
33
|
+
/** Total number of draft files left untouched because abortOnConflict was set. */
|
|
34
|
+
aborted: number;
|
|
21
35
|
}
|
|
22
36
|
/**
|
|
23
37
|
* Write onboarding drafts under sharkcraft/onboarding/. This function NEVER
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"onboarding-drafts.d.ts","sourceRoot":"","sources":["../src/onboarding-drafts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"onboarding-drafts.d.ts","sourceRoot":"","sources":["../src/onboarding-drafts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAA8B,MAAM,iBAAiB,CAAC;AAEnF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EACL,gBAAgB,EAMjB,MAAM,8BAA8B,CAAC;AAEtC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,6CAA6C;IAC7C,WAAW,EAAE,gBAAgB,CAAC;IAC9B,iFAAiF;IACjF,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,mEAAmE;IACnE,SAAS,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,6BAA6B,GACrC,4BAA4B,CA+C9B"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import * as nodePath from 'node:path';
|
|
3
3
|
import { renderOnboardingReport } from "./onboarding-report.js";
|
|
4
|
+
import { DraftMergeStatus, readSnapshot, snapshotPathFor, threeWayMergeDraft, writeSnapshot, } from "./onboarding-drafts-merge.js";
|
|
4
5
|
/**
|
|
5
6
|
* Write onboarding drafts under sharkcraft/onboarding/. This function NEVER
|
|
6
7
|
* writes outside that subdirectory (the caller can override the location, but
|
|
@@ -11,14 +12,24 @@ export function writeOnboardingDrafts(plan, options) {
|
|
|
11
12
|
nodePath.join(options.projectRoot, 'sharkcraft', 'onboarding'));
|
|
12
13
|
ensureDir(outDir);
|
|
13
14
|
const files = [];
|
|
14
|
-
const write = (name,
|
|
15
|
+
const write = (name, proposal) => {
|
|
15
16
|
const full = nodePath.join(outDir, name);
|
|
16
17
|
// Belt-and-braces: refuse anything that escapes outDir.
|
|
17
18
|
if (!full.startsWith(outDir + nodePath.sep)) {
|
|
18
19
|
throw new Error(`draft path escapes outDir: ${name}`);
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const merge = mergeDraft(options.projectRoot, full, proposal, options);
|
|
22
|
+
if (merge.status !== DraftMergeStatus.Aborted) {
|
|
23
|
+
writeFileSync(full, merge.body, 'utf8');
|
|
24
|
+
// Snapshot what we just wrote so the next run has a fresh `base`.
|
|
25
|
+
writeSnapshot(snapshotPathFor(options.projectRoot, full), merge.body);
|
|
26
|
+
}
|
|
27
|
+
files.push({
|
|
28
|
+
path: full,
|
|
29
|
+
bytes: Buffer.byteLength(merge.body, 'utf8'),
|
|
30
|
+
mergeStatus: merge.status,
|
|
31
|
+
conflictRegions: merge.conflictRegions,
|
|
32
|
+
});
|
|
22
33
|
};
|
|
23
34
|
write('onboarding-report.md', renderOnboardingReport(plan));
|
|
24
35
|
write('inferred-rules.draft.ts', renderInferredRulesDraft(plan));
|
|
@@ -29,7 +40,30 @@ export function writeOnboardingDrafts(plan, options) {
|
|
|
29
40
|
if (options.importedAgentRules && options.importedAgentRules.entries.length > 0) {
|
|
30
41
|
write('imported-agent-rules.draft.ts', renderImportedAgentRulesDraft(options.importedAgentRules));
|
|
31
42
|
}
|
|
32
|
-
|
|
43
|
+
let conflicts = 0;
|
|
44
|
+
let aborted = 0;
|
|
45
|
+
for (const f of files) {
|
|
46
|
+
if (f.mergeStatus === DraftMergeStatus.Conflict)
|
|
47
|
+
conflicts += 1;
|
|
48
|
+
else if (f.mergeStatus === DraftMergeStatus.Aborted)
|
|
49
|
+
aborted += 1;
|
|
50
|
+
}
|
|
51
|
+
return { outDir, files, conflicts, aborted };
|
|
52
|
+
}
|
|
53
|
+
function mergeDraft(projectRoot, draftPath, proposal, options) {
|
|
54
|
+
const ours = existsSync(draftPath) ? safeRead(draftPath) : null;
|
|
55
|
+
const base = readSnapshot(snapshotPathFor(projectRoot, draftPath));
|
|
56
|
+
return threeWayMergeDraft(base, ours, proposal, {
|
|
57
|
+
abortOnConflict: options.abortOnConflict ?? false,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function safeRead(path) {
|
|
61
|
+
try {
|
|
62
|
+
return readFileSync(path, 'utf8');
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
33
67
|
}
|
|
34
68
|
// ─── Renderers ───────────────────────────────────────────────────────────────
|
|
35
69
|
function renderInferredRulesDraft(plan) {
|
package/dist/ownership.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
import { existsSync, readFileSync } from 'node:fs';
|
|
2
10
|
import * as nodePath from 'node:path';
|
|
3
|
-
import {
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
4
12
|
export const OWNERSHIP_SCHEMA = 'sharkcraft.ownership-rule/v1';
|
|
5
13
|
const DEFAULT_PATHS = ['sharkcraft/ownership.ts', 'CODEOWNERS', '.github/CODEOWNERS'];
|
|
6
14
|
export async function loadOwnershipRules(cwd, configured) {
|
|
@@ -16,7 +24,7 @@ export async function loadOwnershipRules(cwd, configured) {
|
|
|
16
24
|
if (full.endsWith('.ts') || full.endsWith('.js') || full.endsWith('.mjs') || full.endsWith('.cjs')) {
|
|
17
25
|
try {
|
|
18
26
|
// pathToFileURL mirrors the resolver pattern in TypeScriptKnowledgeLoader.
|
|
19
|
-
const mod = (await
|
|
27
|
+
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(full).href)));
|
|
20
28
|
const list = mod.default ?? mod.ownershipRules ?? [];
|
|
21
29
|
for (const r of list)
|
|
22
30
|
rules.push(normalize(r));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pack-helper-registry.d.ts","sourceRoot":"","sources":["../src/pack-helper-registry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"pack-helper-registry.d.ts","sourceRoot":"","sources":["../src/pack-helper-registry.ts"],"names":[],"mappings":"AAQA,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,2BAA2B,uCAAuC,CAAC;AAEhF,oBAAY,gBAAgB;IAC1B,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAClC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AA4BD,wBAAsB,eAAe,CACnC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC;IAAE,OAAO,EAAE,SAAS,gBAAgB,EAAE,CAAC;IAAC,MAAM,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAAE,CAAC,CAoF9F;AAED,wBAAsB,eAAe,CACnC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,SAAS,gBAAgB,EAAE,CAAC,CAGtC;AAED,wBAAsB,cAAc,CAClC,UAAU,EAAE,qBAAqB,EACjC,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAGlC;AAED,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,qBAAqB,GAChC,OAAO,CAAC,SAAS,sBAAsB,EAAE,CAAC,CAG5C"}
|
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
1
9
|
/**
|
|
2
10
|
* Pack helper registry. Loads pack-contributed and locally-configured
|
|
3
11
|
* helpers via `helperFiles[]`. Engine still ships its profile-driven generic
|
|
@@ -5,8 +13,8 @@
|
|
|
5
13
|
*/
|
|
6
14
|
import { existsSync } from 'node:fs';
|
|
7
15
|
import * as nodePath from 'node:path';
|
|
16
|
+
import { pathToFileURL } from 'node:url';
|
|
8
17
|
import { validatePackHelper } from '@shrkcrft/plugin-api';
|
|
9
|
-
import { importModuleViaLoader } from '@shrkcrft/core';
|
|
10
18
|
export const PACK_HELPER_REGISTRY_SCHEMA = 'sharkcraft.pack-helper-registry/v1';
|
|
11
19
|
export var PackHelperSource;
|
|
12
20
|
(function (PackHelperSource) {
|
|
@@ -15,7 +23,7 @@ export var PackHelperSource;
|
|
|
15
23
|
PackHelperSource["Fixture"] = "fixture";
|
|
16
24
|
})(PackHelperSource || (PackHelperSource = {}));
|
|
17
25
|
async function importDefault(file) {
|
|
18
|
-
const mod = (await
|
|
26
|
+
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(file).href)));
|
|
19
27
|
if (Array.isArray(mod.default))
|
|
20
28
|
return mod.default;
|
|
21
29
|
if (mod.default && typeof mod.default === 'object')
|