@shrkcrft/inspector 0.1.0-alpha.1 → 0.1.0-alpha.10

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 (148) hide show
  1. package/README.md +1 -1
  2. package/dist/adoption-state.js +1 -1
  3. package/dist/agent-brief.d.ts.map +1 -1
  4. package/dist/agent-brief.js +59 -10
  5. package/dist/agent-task-prep.d.ts.map +1 -1
  6. package/dist/agent-task-prep.js +1 -3
  7. package/dist/ai-readiness.d.ts +84 -9
  8. package/dist/ai-readiness.d.ts.map +1 -1
  9. package/dist/ai-readiness.js +161 -30
  10. package/dist/apply-dispatch-trace.d.ts +1 -2
  11. package/dist/apply-dispatch-trace.d.ts.map +1 -1
  12. package/dist/apply-dispatch-trace.js +0 -9
  13. package/dist/area-explore.d.ts.map +1 -1
  14. package/dist/area-explore.js +1 -5
  15. package/dist/area-map.d.ts +0 -19
  16. package/dist/area-map.d.ts.map +1 -1
  17. package/dist/area-map.js +0 -27
  18. package/dist/ci-permissions-fix.d.ts +1 -1
  19. package/dist/ci-permissions-fix.d.ts.map +1 -1
  20. package/dist/ci-permissions-fix.js +1 -182
  21. package/dist/code-intelligence-doctor.d.ts +21 -0
  22. package/dist/code-intelligence-doctor.d.ts.map +1 -0
  23. package/dist/code-intelligence-doctor.js +965 -0
  24. package/dist/compliance-profiles.js +1 -1
  25. package/dist/construct-adoption-diff.d.ts.map +1 -1
  26. package/dist/construct-adoption-diff.js +2 -1
  27. package/dist/construct-adoption.d.ts.map +1 -1
  28. package/dist/construct-adoption.js +10 -11
  29. package/dist/construct-inference.d.ts.map +1 -1
  30. package/dist/construct-inference.js +2 -1
  31. package/dist/construct-registry.d.ts.map +1 -1
  32. package/dist/construct-registry.js +2 -10
  33. package/dist/contract-template-registry.d.ts.map +1 -1
  34. package/dist/contract-template-registry.js +2 -10
  35. package/dist/convention-registry.d.ts.map +1 -1
  36. package/dist/convention-registry.js +2 -10
  37. package/dist/decision-records.d.ts.map +1 -1
  38. package/dist/decision-records.js +2 -9
  39. package/dist/demo-script.d.ts +0 -1
  40. package/dist/demo-script.d.ts.map +1 -1
  41. package/dist/demo-script.js +0 -43
  42. package/dist/docs-check.js +1 -1
  43. package/dist/drift-baseline.d.ts.map +1 -1
  44. package/dist/drift-baseline.js +5 -2
  45. package/dist/feedback-ingestion.d.ts.map +1 -1
  46. package/dist/feedback-ingestion.js +2 -16
  47. package/dist/git-helpers.d.ts +0 -12
  48. package/dist/git-helpers.d.ts.map +1 -1
  49. package/dist/git-helpers.js +0 -63
  50. package/dist/helper-registry.d.ts +27 -54
  51. package/dist/helper-registry.d.ts.map +1 -1
  52. package/dist/helper-registry.js +16 -517
  53. package/dist/impact-analysis.d.ts.map +1 -1
  54. package/dist/impact-analysis.js +4 -5
  55. package/dist/impact-render.d.ts.map +1 -1
  56. package/dist/impact-render.js +0 -9
  57. package/dist/index.d.ts +2 -3
  58. package/dist/index.d.ts.map +1 -1
  59. package/dist/index.js +2 -3
  60. package/dist/ingest-drafts.js +8 -4
  61. package/dist/migration-profile-registry.d.ts.map +1 -1
  62. package/dist/migration-profile-registry.js +2 -10
  63. package/dist/monorepo-onboarding.js +2 -2
  64. package/dist/onboarding-drafts.d.ts +0 -14
  65. package/dist/onboarding-drafts.d.ts.map +1 -1
  66. package/dist/onboarding-drafts.js +5 -39
  67. package/dist/onboarding-report.d.ts.map +1 -1
  68. package/dist/onboarding-report.js +5 -1
  69. package/dist/onboarding.d.ts +1 -1
  70. package/dist/onboarding.d.ts.map +1 -1
  71. package/dist/onboarding.js +5 -64
  72. package/dist/ownership.js +2 -10
  73. package/dist/pack-contributions-inventory.d.ts +0 -1
  74. package/dist/pack-contributions-inventory.d.ts.map +1 -1
  75. package/dist/pack-contributions-inventory.js +0 -24
  76. package/dist/pack-helper-registry.d.ts.map +1 -1
  77. package/dist/pack-helper-registry.js +2 -10
  78. package/dist/pack-release-check.d.ts.map +1 -1
  79. package/dist/pack-release-check.js +4 -11
  80. package/dist/pack-signature-status.d.ts.map +1 -1
  81. package/dist/pack-signature-status.js +0 -1
  82. package/dist/pack-symbol-compat.d.ts +4 -17
  83. package/dist/pack-symbol-compat.d.ts.map +1 -1
  84. package/dist/pack-symbol-compat.js +7 -155
  85. package/dist/pack-test-runner.js +2 -10
  86. package/dist/plan-simulation.d.ts.map +1 -1
  87. package/dist/plan-simulation.js +3 -20
  88. package/dist/playbook-registry.d.ts.map +1 -1
  89. package/dist/playbook-registry.js +2 -10
  90. package/dist/policy-engine.d.ts.map +1 -1
  91. package/dist/policy-engine.js +3 -11
  92. package/dist/policy-test.js +3 -11
  93. package/dist/product-coherence.js +5 -5
  94. package/dist/profile-registry.d.ts +0 -1
  95. package/dist/profile-registry.d.ts.map +1 -1
  96. package/dist/profile-registry.js +4 -32
  97. package/dist/quality-baseline.d.ts.map +1 -1
  98. package/dist/quality-baseline.js +3 -1
  99. package/dist/ranker-explainability.d.ts.map +1 -1
  100. package/dist/ranker-explainability.js +3 -9
  101. package/dist/registration-hint-registry.d.ts.map +1 -1
  102. package/dist/registration-hint-registry.js +2 -10
  103. package/dist/release-readiness.js +5 -5
  104. package/dist/reposet.js +1 -1
  105. package/dist/repository-knowledge-model.d.ts +1 -1
  106. package/dist/repository-knowledge-model.d.ts.map +1 -1
  107. package/dist/review-packet-v2.d.ts.map +1 -1
  108. package/dist/review-packet-v2.js +3 -13
  109. package/dist/rule-scaffold.d.ts.map +1 -1
  110. package/dist/rule-scaffold.js +12 -4
  111. package/dist/scaffold-patterns.js +2 -10
  112. package/dist/search-tuning-registry.d.ts.map +1 -1
  113. package/dist/search-tuning-registry.js +2 -10
  114. package/dist/self-config-doctor-v2.d.ts +1 -1
  115. package/dist/self-config-doctor-v2.d.ts.map +1 -1
  116. package/dist/self-config-doctor-v2.js +6 -10
  117. package/dist/self-config-doctor.d.ts.map +1 -1
  118. package/dist/self-config-doctor.js +7 -13
  119. package/dist/sharkcraft-inspector.d.ts.map +1 -1
  120. package/dist/sharkcraft-inspector.js +9 -0
  121. package/dist/start-here.d.ts +1 -1
  122. package/dist/start-here.js +1 -1
  123. package/dist/synthesize-from-onboarding.d.ts +68 -0
  124. package/dist/synthesize-from-onboarding.d.ts.map +1 -0
  125. package/dist/synthesize-from-onboarding.js +508 -0
  126. package/dist/task-packet.d.ts +13 -0
  127. package/dist/task-packet.d.ts.map +1 -1
  128. package/dist/task-packet.js +46 -5
  129. package/dist/task-ranker.d.ts.map +1 -1
  130. package/dist/task-ranker.js +1 -31
  131. package/dist/task-routing-hint-registry.d.ts.map +1 -1
  132. package/dist/task-routing-hint-registry.js +2 -10
  133. package/dist/test-runner.d.ts.map +1 -1
  134. package/dist/test-runner.js +12 -17
  135. package/dist/universal-search.d.ts +0 -1
  136. package/dist/universal-search.d.ts.map +1 -1
  137. package/dist/universal-search.js +0 -12
  138. package/dist/upgrade-advisor.js +1 -1
  139. package/package.json +22 -21
  140. package/dist/onboarding-drafts-merge.d.ts +0 -71
  141. package/dist/onboarding-drafts-merge.d.ts.map +0 -1
  142. package/dist/onboarding-drafts-merge.js +0 -174
  143. package/dist/plugin-lifecycle-profile-registry.d.ts +0 -52
  144. package/dist/plugin-lifecycle-profile-registry.d.ts.map +0 -1
  145. package/dist/plugin-lifecycle-profile-registry.js +0 -202
  146. package/dist/plugin-lifecycle.d.ts +0 -132
  147. package/dist/plugin-lifecycle.d.ts.map +0 -1
  148. package/dist/plugin-lifecycle.js +0 -477
@@ -1,174 +0,0 @@
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,52 +0,0 @@
1
- import { type IPluginLifecycleProfile } from '@shrkcrft/plugin-api';
2
- import type { ISharkcraftInspection } from './sharkcraft-inspector.js';
3
- export declare const PLUGIN_LIFECYCLE_PROFILE_REGISTRY_SCHEMA = "sharkcraft.plugin-lifecycle-profile-registry/v1";
4
- export declare enum PluginLifecycleProfileSource {
5
- Local = "local",
6
- Pack = "pack",
7
- Fixture = "fixture"
8
- }
9
- export interface IPluginLifecycleProfileEntry {
10
- readonly profile: IPluginLifecycleProfile;
11
- readonly source: PluginLifecycleProfileSource;
12
- readonly packageName?: string;
13
- readonly sourceFile: string;
14
- }
15
- export declare enum ProfileDoctorSeverity {
16
- Info = "info",
17
- Warning = "warning",
18
- Error = "error"
19
- }
20
- export interface IPluginLifecycleProfileDoctorIssue {
21
- readonly severity: ProfileDoctorSeverity;
22
- readonly code: string;
23
- readonly message: string;
24
- readonly profileId?: string;
25
- readonly source?: string;
26
- }
27
- export declare function loadPluginLifecycleProfiles(inspection: ISharkcraftInspection): Promise<{
28
- entries: readonly IPluginLifecycleProfileEntry[];
29
- issues: readonly IPluginLifecycleProfileDoctorIssue[];
30
- }>;
31
- export declare function listPluginLifecycleProfiles(inspection: ISharkcraftInspection): Promise<readonly IPluginLifecycleProfileEntry[]>;
32
- export declare function findPluginLifecycleProfile(inspection: ISharkcraftInspection, id: string): Promise<IPluginLifecycleProfileEntry | null>;
33
- export declare function listPluginLifecycleProfileIssues(inspection: ISharkcraftInspection): Promise<readonly IPluginLifecycleProfileDoctorIssue[]>;
34
- export declare function clearPluginLifecycleProfileCache(projectRoot?: string): void;
35
- export interface IResolveProfileOptions {
36
- /** Explicit profile id (e.g. from --profile). */
37
- readonly profileId?: string;
38
- /** If true and there is exactly one profile, return it implicitly. */
39
- readonly allowSingleDefault?: boolean;
40
- }
41
- export interface IResolveProfileResult {
42
- readonly entry?: IPluginLifecycleProfileEntry;
43
- readonly error?: string;
44
- readonly availableIds: readonly string[];
45
- }
46
- /**
47
- * Pick a profile from the registry. If `profileId` is supplied, look it up.
48
- * If not and exactly one profile is registered and `allowSingleDefault` is
49
- * true, return it. Otherwise emit an explanatory error string and list ids.
50
- */
51
- export declare function resolvePluginLifecycleProfile(inspection: ISharkcraftInspection, options?: IResolveProfileOptions): Promise<IResolveProfileResult>;
52
- //# sourceMappingURL=plugin-lifecycle-profile-registry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-lifecycle-profile-registry.d.ts","sourceRoot":"","sources":["../src/plugin-lifecycle-profile-registry.ts"],"names":[],"mappings":"AAUA,OAAO,EAEL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAEvE,eAAO,MAAM,wCAAwC,oDACF,CAAC;AAEpD,oBAAY,4BAA4B;IACtC,KAAK,UAAU;IACf,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,OAAO,EAAE,uBAAuB,CAAC;IAC1C,QAAQ,CAAC,MAAM,EAAE,4BAA4B,CAAC;IAC9C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED,oBAAY,qBAAqB;IAC/B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;CAChB;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CA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"}
@@ -1,202 +0,0 @@
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
- };
9
- /**
10
- * Plugin lifecycle profile registry.
11
- *
12
- * Loads pack-contributed and locally configured `IPluginLifecycleProfile`
13
- * entries. Duplicate ids and invalid profiles surface as doctor issues.
14
- * Source attribution lets the CLI tell the user where a profile came from.
15
- */
16
- import { existsSync } from 'node:fs';
17
- import * as nodePath from 'node:path';
18
- import { pathToFileURL } from 'node:url';
19
- import { validatePluginLifecycleProfile, } from '@shrkcrft/plugin-api';
20
- export const PLUGIN_LIFECYCLE_PROFILE_REGISTRY_SCHEMA = 'sharkcraft.plugin-lifecycle-profile-registry/v1';
21
- export var PluginLifecycleProfileSource;
22
- (function (PluginLifecycleProfileSource) {
23
- PluginLifecycleProfileSource["Local"] = "local";
24
- PluginLifecycleProfileSource["Pack"] = "pack";
25
- PluginLifecycleProfileSource["Fixture"] = "fixture";
26
- })(PluginLifecycleProfileSource || (PluginLifecycleProfileSource = {}));
27
- export var ProfileDoctorSeverity;
28
- (function (ProfileDoctorSeverity) {
29
- ProfileDoctorSeverity["Info"] = "info";
30
- ProfileDoctorSeverity["Warning"] = "warning";
31
- ProfileDoctorSeverity["Error"] = "error";
32
- })(ProfileDoctorSeverity || (ProfileDoctorSeverity = {}));
33
- const CACHE = new Map();
34
- async function importDefaultProfiles(file) {
35
- const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(file).href)));
36
- if (Array.isArray(mod.default))
37
- return mod.default;
38
- if (mod.default && typeof mod.default === 'object')
39
- return [mod.default];
40
- if (Array.isArray(mod.pluginLifecycleProfiles))
41
- return mod.pluginLifecycleProfiles;
42
- return [];
43
- }
44
- function localProfileFiles(inspection) {
45
- const out = [];
46
- const dir = inspection.sharkcraftDir;
47
- if (!dir)
48
- return [];
49
- for (const name of ['plugin-lifecycle-profiles.ts', 'plugin-lifecycle-profiles/index.ts']) {
50
- const full = nodePath.join(dir, name);
51
- if (existsSync(full))
52
- out.push(full);
53
- }
54
- const cfg = inspection.config;
55
- for (const rel of cfg?.pluginLifecycleProfileFiles ?? []) {
56
- out.push(nodePath.isAbsolute(rel) ? rel : nodePath.join(dir, rel));
57
- }
58
- return out;
59
- }
60
- export async function loadPluginLifecycleProfiles(inspection) {
61
- const cacheKey = `${inspection.projectRoot}:${(inspection.packs.validPacks ?? [])
62
- .map((p) => p.packageName + '@' + p.packageVersion)
63
- .join(',')}`;
64
- const cached = CACHE.get(inspection.projectRoot);
65
- if (cached && cached.cacheKey === cacheKey) {
66
- return { entries: cached.entries, issues: cached.issues };
67
- }
68
- const seen = new Map();
69
- const entries = [];
70
- const issues = [];
71
- const ingest = (profile, source, packageName, sourceFile) => {
72
- const validation = validatePluginLifecycleProfile(profile);
73
- if (!validation.valid) {
74
- for (const issue of validation.issues) {
75
- issues.push({
76
- severity: ProfileDoctorSeverity.Error,
77
- code: 'invalid-profile',
78
- message: `${issue.field}: ${issue.message}`,
79
- profileId: typeof profile.id === 'string' ? profile.id : undefined,
80
- source: sourceFile,
81
- });
82
- }
83
- return;
84
- }
85
- const existing = seen.get(profile.id);
86
- if (existing) {
87
- issues.push({
88
- severity: ProfileDoctorSeverity.Error,
89
- code: 'duplicate-id',
90
- message: `Profile id "${profile.id}" already loaded from ${existing.sourceFile} (source=${existing.source}); skipping duplicate from ${sourceFile} (source=${source}).`,
91
- profileId: profile.id,
92
- source: sourceFile,
93
- });
94
- return;
95
- }
96
- const entry = {
97
- profile,
98
- source,
99
- ...(packageName ? { packageName } : {}),
100
- sourceFile,
101
- };
102
- seen.set(profile.id, entry);
103
- entries.push(entry);
104
- };
105
- for (const file of localProfileFiles(inspection)) {
106
- try {
107
- const list = await importDefaultProfiles(file);
108
- const rel = nodePath.relative(inspection.projectRoot, file) || file;
109
- for (const raw of list) {
110
- ingest(raw, PluginLifecycleProfileSource.Local, undefined, rel);
111
- }
112
- }
113
- catch (e) {
114
- issues.push({
115
- severity: ProfileDoctorSeverity.Warning,
116
- code: 'load-failed',
117
- message: `Failed to load ${file}: ${e.message}`,
118
- source: file,
119
- });
120
- }
121
- }
122
- for (const pack of inspection.packs.validPacks ?? []) {
123
- const contributions = (pack.manifest?.contributions ?? {});
124
- for (const rel of contributions.pluginLifecycleProfileFiles ?? []) {
125
- const file = nodePath.resolve(pack.packageRoot, rel);
126
- if (!existsSync(file)) {
127
- issues.push({
128
- severity: ProfileDoctorSeverity.Warning,
129
- code: 'missing-file',
130
- message: `Pack ${pack.packageName} declares profile file ${rel} but it is missing.`,
131
- source: file,
132
- });
133
- continue;
134
- }
135
- try {
136
- const list = await importDefaultProfiles(file);
137
- for (const raw of list) {
138
- ingest(raw, PluginLifecycleProfileSource.Pack, pack.packageName, rel);
139
- }
140
- }
141
- catch (e) {
142
- issues.push({
143
- severity: ProfileDoctorSeverity.Warning,
144
- code: 'load-failed',
145
- message: `Pack ${pack.packageName} (${rel}): ${e.message}`,
146
- source: file,
147
- });
148
- }
149
- }
150
- }
151
- CACHE.set(inspection.projectRoot, { cacheKey, entries, issues });
152
- return { entries, issues };
153
- }
154
- export async function listPluginLifecycleProfiles(inspection) {
155
- const { entries } = await loadPluginLifecycleProfiles(inspection);
156
- return entries;
157
- }
158
- export async function findPluginLifecycleProfile(inspection, id) {
159
- const entries = await listPluginLifecycleProfiles(inspection);
160
- return entries.find((e) => e.profile.id === id) ?? null;
161
- }
162
- export async function listPluginLifecycleProfileIssues(inspection) {
163
- const { issues } = await loadPluginLifecycleProfiles(inspection);
164
- return issues;
165
- }
166
- export function clearPluginLifecycleProfileCache(projectRoot) {
167
- if (projectRoot)
168
- CACHE.delete(projectRoot);
169
- else
170
- CACHE.clear();
171
- }
172
- /**
173
- * Pick a profile from the registry. If `profileId` is supplied, look it up.
174
- * If not and exactly one profile is registered and `allowSingleDefault` is
175
- * true, return it. Otherwise emit an explanatory error string and list ids.
176
- */
177
- export async function resolvePluginLifecycleProfile(inspection, options = {}) {
178
- const entries = await listPluginLifecycleProfiles(inspection);
179
- const availableIds = entries.map((e) => e.profile.id);
180
- if (options.profileId) {
181
- const found = entries.find((e) => e.profile.id === options.profileId);
182
- if (found)
183
- return { entry: found, availableIds };
184
- return {
185
- error: `Unknown plugin lifecycle profile "${options.profileId}". Available: ${availableIds.length === 0 ? '(none registered)' : availableIds.join(', ')}. Contribute one via a pack manifest "pluginLifecycleProfileFiles" entry or sharkcraft/plugin-lifecycle-profiles.ts.`,
186
- availableIds,
187
- };
188
- }
189
- if (entries.length === 0) {
190
- return {
191
- error: 'No plugin lifecycle profiles registered. Contribute one via a pack manifest "pluginLifecycleProfileFiles" entry or sharkcraft/plugin-lifecycle-profiles.ts.',
192
- availableIds,
193
- };
194
- }
195
- if (entries.length === 1 && options.allowSingleDefault) {
196
- return { entry: entries[0], availableIds };
197
- }
198
- return {
199
- error: `--profile required. Available: ${availableIds.join(', ')}.`,
200
- availableIds,
201
- };
202
- }
@@ -1,132 +0,0 @@
1
- /**
2
- * Plan-only plugin lifecycle helpers driven by a resolved profile.
3
- *
4
- * Lifecycle helpers never write source directly. They emit a structured plan
5
- * containing:
6
- * - replaceOps: safe `replace` plan operations against the profile's
7
- * key-table file, barrels, and other registry files.
8
- * - manualSteps: things the planned-operation model cannot do today
9
- * (rename a folder, delete a folder) when folder ops are
10
- * not requested or not safe.
11
- * - conflicts: anchors that could not be found — surfaced as advisory
12
- * hints (no failure).
13
- * - destructive: `true` for remove; `true` for rename when files need to
14
- * be renamed on disk.
15
- *
16
- * The engine has no project-specific knowledge: every path / key style / barrel
17
- * comes from the supplied `IPluginLifecycleProfile`. A pack contributes the
18
- * profile via `pluginLifecycleProfileFiles` on the manifest.
19
- */
20
- import { type IPluginLifecycleProfile } from '@shrkcrft/plugin-api';
21
- export declare enum PluginLifecycleAction {
22
- Rename = "rename",
23
- Remove = "remove"
24
- }
25
- export interface IPluginLifecycleManualStep {
26
- kind: 'delete-file' | 'delete-folder' | 'rename-file' | 'rename-folder';
27
- targetPath: string;
28
- newPath?: string;
29
- reason: string;
30
- }
31
- export interface IPluginLifecycleReplaceOp {
32
- targetPath: string;
33
- operation: {
34
- kind: 'replace';
35
- find: string;
36
- replaceWith: string;
37
- description: string;
38
- };
39
- }
40
- export interface IPluginLifecycleFolderOp {
41
- kind: 'rename-folder' | 'delete-folder';
42
- targetPath: string;
43
- newPath?: string;
44
- safety: 'safe' | 'unsafe';
45
- safetyReason?: string;
46
- reason: string;
47
- }
48
- export interface IPluginLifecyclePlan {
49
- schema: 'sharkcraft.plugin-lifecycle/v1';
50
- action: PluginLifecycleAction;
51
- /** Profile id (e.g. "my-monorepo"). Engine does not constrain this to a literal. */
52
- profile: string;
53
- oldName: string;
54
- newName?: string;
55
- destructive: boolean;
56
- humanApprovalRequired: boolean;
57
- replaceOps: ReadonlyArray<IPluginLifecycleReplaceOp>;
58
- manualSteps: ReadonlyArray<IPluginLifecycleManualStep>;
59
- /** Structured folder operations when --emit-folder-ops is requested. */
60
- folderOps?: ReadonlyArray<IPluginLifecycleFolderOp>;
61
- conflicts: ReadonlyArray<string>;
62
- validationCommands: ReadonlyArray<string>;
63
- }
64
- export interface IBuildPluginRenameInput {
65
- projectRoot: string;
66
- profile: IPluginLifecycleProfile;
67
- oldName: string;
68
- newName: string;
69
- /** When true, also emit structured folder rename ops in `folderOps[]`. */
70
- emitFolderOps?: boolean;
71
- }
72
- export declare function buildPluginRenamePlan(input: IBuildPluginRenameInput): IPluginLifecyclePlan;
73
- export interface IBuildPluginRemoveInput {
74
- projectRoot: string;
75
- profile: IPluginLifecycleProfile;
76
- oldName: string;
77
- /** When true, also emit structured folder delete ops in `folderOps[]`. */
78
- emitFolderOps?: boolean;
79
- }
80
- export declare function buildPluginRemovePlan(input: IBuildPluginRemoveInput): IPluginLifecyclePlan;
81
- /**
82
- * Convert a plugin-lifecycle plan into a saved plan (synthetic
83
- * templateId) so it can flow through `shrk apply`. ReplaceOps become
84
- * `expectedChanges` carrying their operation intent; folderOps[] is copied
85
- * through. The plan is unsigned by this helper; call `signPlan` separately.
86
- */
87
- export declare const PLUGIN_LIFECYCLE_SYNTHETIC_TEMPLATE = "__plugin-lifecycle__";
88
- export declare function pluginLifecyclePlanToSavedPlan(plan: IPluginLifecyclePlan, projectRoot: string): {
89
- schema: 'sharkcraft.plan/v2';
90
- templateId: string;
91
- name?: string;
92
- variables: Record<string, string>;
93
- projectRoot: string;
94
- createdAt: string;
95
- expectedChanges: {
96
- type: string;
97
- relativePath: string;
98
- sizeBytes: number;
99
- operation: IPluginLifecycleReplaceOp['operation'];
100
- }[];
101
- folderOps?: {
102
- kind: 'rename-folder' | 'delete-folder';
103
- targetPath: string;
104
- newPath?: string;
105
- reason?: string;
106
- }[];
107
- note?: string;
108
- };
109
- export declare function renderPluginLifecyclePlanText(plan: IPluginLifecyclePlan): string;
110
- export interface IPluginLifecycleListingInput {
111
- projectRoot: string;
112
- profile: IPluginLifecycleProfile;
113
- }
114
- export declare function buildPluginLifecycleListing(input: IPluginLifecycleListingInput): {
115
- pluginsByLayer: Readonly<Record<string, ReadonlyArray<string>>>;
116
- pluginKeys: ReadonlyArray<{
117
- key: string;
118
- value: string;
119
- }>;
120
- };
121
- /**
122
- * Doctor check: a profile is valid if every declared file exists and the
123
- * key-table file (if any) parses. This stays read-only; no fs mutations.
124
- */
125
- export interface IPluginLifecycleProfileDoctorEntry {
126
- readonly id: 'missing-key-table' | 'missing-barrel' | 'missing-plugin-root' | 'ok';
127
- readonly severity: 'info' | 'warning' | 'error';
128
- readonly path?: string;
129
- readonly message: string;
130
- }
131
- export declare function checkPluginLifecycleProfileHealth(projectRoot: string, profile: IPluginLifecycleProfile): readonly IPluginLifecycleProfileDoctorEntry[];
132
- //# sourceMappingURL=plugin-lifecycle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin-lifecycle.d.ts","sourceRoot":"","sources":["../src/plugin-lifecycle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,sBAAsB,CAAC;AAE9B,oBAAY,qBAAqB;IAC/B,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,EAAE,aAAa,GAAG,eAAe,GAAG,aAAa,GAAG,eAAe,CAAC;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,yBAAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE;QACT,IAAI,EAAE,SAAS,CAAC;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,eAAe,GAAG,eAAe,CAAC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,gCAAgC,CAAC;IACzC,MAAM,EAAE,qBAAqB,CAAC;IAC9B,oFAAoF;IACpF,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;IACrB,qBAAqB,EAAE,OAAO,CAAC;IAC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