@shrkcrft/inspector 0.1.0-alpha.27 → 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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AppError, type Result } from '@shrkcrft/core';
|
|
2
2
|
import { type LoadedConfig } from '@shrkcrft/config';
|
|
3
3
|
/**
|
|
4
|
-
* A {@link LoadedConfig} whose
|
|
4
|
+
* A {@link LoadedConfig} whose data planes have had pack contributions
|
|
5
5
|
* merged in (local-wins), plus the human-readable notes from that merge.
|
|
6
6
|
*/
|
|
7
7
|
export interface IResolvedProjectConfig extends LoadedConfig {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-project-config.d.ts","sourceRoot":"","sources":["../src/resolve-project-config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolve-project-config.d.ts","sourceRoot":"","sources":["../src/resolve-project-config.ts"],"names":[],"mappings":"AAwBA,OAAO,EAGL,KAAK,QAAQ,EAQb,KAAK,MAAM,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAG1B;;;GAGG;AACH,MAAM,WAAW,sBAAuB,SAAQ,YAAY;IAC1D;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9C;AAiID;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC,CAqGnD"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Pack-aware project-config resolution.
|
|
3
3
|
*
|
|
4
|
-
* The
|
|
5
|
-
* `policyRules`, `
|
|
4
|
+
* The "cross-file invariant as DATA" planes — `wiringRules`, `registries`,
|
|
5
|
+
* `registrationGraph`, `policyRules`, `baselines`, `generatedArtifacts`,
|
|
6
|
+
* `reusePrimitives` — can be authored inline in a repo's
|
|
6
7
|
* `sharkcraft.config.ts`. They can ALSO be SHIPPED by a framework pack (e.g. a
|
|
7
8
|
* NestJS pack contributing "every @Injectable must be registered in a module"
|
|
8
9
|
* as a wiring rule) via the new `wiringRuleFiles` / `registryFiles` /
|
|
@@ -22,7 +23,7 @@
|
|
|
22
23
|
import { existsSync } from 'node:fs';
|
|
23
24
|
import * as nodePath from 'node:path';
|
|
24
25
|
import { importModuleViaLoader, ok, } from '@shrkcrft/core';
|
|
25
|
-
import { loadProjectConfig, PolicyRuleSchema, RegistrationIdiomSchema, RegistryDeclarationSchema, ReusePrimitiveSchema, WiringRuleSchema, } from '@shrkcrft/config';
|
|
26
|
+
import { BaselineRuleSchema, GeneratedArtifactRuleSchema, loadProjectConfig, PolicyRuleSchema, RegistrationIdiomSchema, RegistryDeclarationSchema, ReusePrimitiveSchema, WiringRuleSchema, } from '@shrkcrft/config';
|
|
26
27
|
import { discoverPacks } from '@shrkcrft/packs';
|
|
27
28
|
/**
|
|
28
29
|
* Generic per-plane load + validate + merge. Seeds the merged map from the
|
|
@@ -31,7 +32,13 @@ import { discoverPacks } from '@shrkcrft/packs';
|
|
|
31
32
|
* elements, and key collisions all become diagnostics and are skipped — never a
|
|
32
33
|
* throw.
|
|
33
34
|
*/
|
|
34
|
-
async function mergePlane(localArr, packContribs, schema, keyOf, planeLabel, diagnostics
|
|
35
|
+
async function mergePlane(localArr, packContribs, schema, keyOf, planeLabel, diagnostics,
|
|
36
|
+
/**
|
|
37
|
+
* Optional per-item veto applied to PACK elements only. Returns the
|
|
38
|
+
* diagnostic to record when the element must not be adopted (used by the
|
|
39
|
+
* shell-executing planes — see the call sites).
|
|
40
|
+
*/
|
|
41
|
+
packGuard) {
|
|
35
42
|
const merged = new Map();
|
|
36
43
|
const localKeys = new Set();
|
|
37
44
|
for (const item of localArr) {
|
|
@@ -68,6 +75,11 @@ async function mergePlane(localArr, packContribs, schema, keyOf, planeLabel, dia
|
|
|
68
75
|
continue;
|
|
69
76
|
}
|
|
70
77
|
const item = parsed.data;
|
|
78
|
+
const veto = packGuard?.(item, contrib.packageName);
|
|
79
|
+
if (veto !== undefined) {
|
|
80
|
+
diagnostics.push(veto);
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
71
83
|
const key = keyOf(item);
|
|
72
84
|
if (merged.has(key)) {
|
|
73
85
|
diagnostics.push(localKeys.has(key)
|
|
@@ -120,6 +132,19 @@ export async function resolveProjectConfig(cwd) {
|
|
|
120
132
|
const registries = await mergePlane(base.config.registries ?? [], gatherPackContribs(validPacks, 'registryFiles'), RegistryDeclarationSchema, (r) => r.name, 'registry', diagnostics);
|
|
121
133
|
const registrationGraph = await mergePlane(base.config.registrationGraph ?? [], gatherPackContribs(validPacks, 'registrationGraphFiles'), RegistrationIdiomSchema, (r) => r.name, 'registrationIdiom', diagnostics);
|
|
122
134
|
const policyRules = await mergePlane(base.config.policyRules ?? [], gatherPackContribs(validPacks, 'policyRuleFiles'), PolicyRuleSchema, (r) => r.id, 'policyRule', diagnostics);
|
|
135
|
+
// The two SHELL-EXECUTING planes. A pack ships code the repo did not write;
|
|
136
|
+
// letting it also ship a command that `shrk baseline check` would then RUN is
|
|
137
|
+
// the same hazard the "pack-contributed verification commands are NOT
|
|
138
|
+
// auto-run" contract already forbids. So the merge keeps the safe subset —
|
|
139
|
+
// extractor computes and header-only generated rules — and drops the rest
|
|
140
|
+
// with a diagnostic. The guarantee is structural: no downstream caller has to
|
|
141
|
+
// remember to re-check provenance.
|
|
142
|
+
const baselines = await mergePlane(base.config.baselines ?? [], gatherPackContribs(validPacks, 'baselineFiles'), BaselineRuleSchema, (r) => r.id, 'baseline', diagnostics, (item, packName) => item.compute?.kind === 'command'
|
|
143
|
+
? `pack ${packName}: baseline "${item.id}" declares a shell \`compute.run\` — pack-contributed commands are never auto-run — skipped`
|
|
144
|
+
: undefined);
|
|
145
|
+
const generatedArtifacts = await mergePlane(base.config.generatedArtifacts ?? [], gatherPackContribs(validPacks, 'generatedArtifactFiles'), GeneratedArtifactRuleSchema, (r) => r.id, 'generatedArtifact', diagnostics, (item, packName) => item.regen !== undefined
|
|
146
|
+
? `pack ${packName}: generatedArtifact "${item.id}" declares a \`regen\` command — pack-contributed commands are never auto-run — skipped`
|
|
147
|
+
: undefined);
|
|
123
148
|
const reusePrimitives = await mergePlane(base.config.reusePrimitives ?? [], gatherPackContribs(validPacks, 'reusePrimitiveFiles'), ReusePrimitiveSchema, (r) => r.symbol, 'reusePrimitive', diagnostics);
|
|
124
149
|
return ok({
|
|
125
150
|
...base,
|
|
@@ -129,6 +154,8 @@ export async function resolveProjectConfig(cwd) {
|
|
|
129
154
|
registries,
|
|
130
155
|
registrationGraph,
|
|
131
156
|
policyRules,
|
|
157
|
+
baselines,
|
|
158
|
+
generatedArtifacts,
|
|
132
159
|
reusePrimitives,
|
|
133
160
|
},
|
|
134
161
|
planeDiagnostics: diagnostics,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/inspector",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.29",
|
|
4
4
|
"description": "SharkCraft inspector: project overview, doctor checks, AI-agent instructions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
46
|
-
"@shrkcrft/config": "^0.1.0-alpha.
|
|
47
|
-
"@shrkcrft/workspace": "^0.1.0-alpha.
|
|
48
|
-
"@shrkcrft/knowledge": "^0.1.0-alpha.
|
|
49
|
-
"@shrkcrft/rules": "^0.1.0-alpha.
|
|
50
|
-
"@shrkcrft/paths": "^0.1.0-alpha.
|
|
51
|
-
"@shrkcrft/templates": "^0.1.0-alpha.
|
|
52
|
-
"@shrkcrft/context": "^0.1.0-alpha.
|
|
53
|
-
"@shrkcrft/pipelines": "^0.1.0-alpha.
|
|
54
|
-
"@shrkcrft/packs": "^0.1.0-alpha.
|
|
55
|
-
"@shrkcrft/presets": "^0.1.0-alpha.
|
|
56
|
-
"@shrkcrft/boundaries": "^0.1.0-alpha.
|
|
57
|
-
"@shrkcrft/generator": "^0.1.0-alpha.
|
|
58
|
-
"@shrkcrft/importer": "^0.1.0-alpha.
|
|
59
|
-
"@shrkcrft/plugin-api": "^0.1.0-alpha.
|
|
60
|
-
"@shrkcrft/dashboard-api": "^0.1.0-alpha.
|
|
45
|
+
"@shrkcrft/core": "^0.1.0-alpha.29",
|
|
46
|
+
"@shrkcrft/config": "^0.1.0-alpha.29",
|
|
47
|
+
"@shrkcrft/workspace": "^0.1.0-alpha.29",
|
|
48
|
+
"@shrkcrft/knowledge": "^0.1.0-alpha.29",
|
|
49
|
+
"@shrkcrft/rules": "^0.1.0-alpha.29",
|
|
50
|
+
"@shrkcrft/paths": "^0.1.0-alpha.29",
|
|
51
|
+
"@shrkcrft/templates": "^0.1.0-alpha.29",
|
|
52
|
+
"@shrkcrft/context": "^0.1.0-alpha.29",
|
|
53
|
+
"@shrkcrft/pipelines": "^0.1.0-alpha.29",
|
|
54
|
+
"@shrkcrft/packs": "^0.1.0-alpha.29",
|
|
55
|
+
"@shrkcrft/presets": "^0.1.0-alpha.29",
|
|
56
|
+
"@shrkcrft/boundaries": "^0.1.0-alpha.29",
|
|
57
|
+
"@shrkcrft/generator": "^0.1.0-alpha.29",
|
|
58
|
+
"@shrkcrft/importer": "^0.1.0-alpha.29",
|
|
59
|
+
"@shrkcrft/plugin-api": "^0.1.0-alpha.29",
|
|
60
|
+
"@shrkcrft/dashboard-api": "^0.1.0-alpha.29",
|
|
61
61
|
"typescript": "^5.6.0"
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|