@shrkcrft/packs 0.1.0-alpha.21 → 0.1.0-alpha.23

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,4 +1,11 @@
1
- import type { IPackDiscoveryResult } from '../model/pack-discovery.js';
1
+ import { type ISharkCraftPackContributions } from '@shrkcrft/plugin-api';
2
+ import type { IDiscoveredPack, IPackDiscoveryResult } from '../model/pack-discovery.js';
3
+ /**
4
+ * Count declared contribution files per kind, driven by the canonical
5
+ * `CONTRIBUTION_FILE_KEYS`. Exported so callers (quality scoring, tests) can
6
+ * derive the same honest totals without re-implementing the slot list.
7
+ */
8
+ export declare function countContributions(c: ISharkCraftPackContributions | undefined): IDiscoveredPack['contributionCounts'];
2
9
  export interface DiscoverPacksOptions {
3
10
  /** Project root to look up node_modules in. Must be absolute. */
4
11
  projectRoot: string;
@@ -17,6 +24,13 @@ export interface DiscoverPacksOptions {
17
24
  verifySignatures?: boolean;
18
25
  /** Override the secret used for signature verification. */
19
26
  packSecret?: string;
27
+ /**
28
+ * Opt in to trusting dev signatures (`sig.dev === true`, verified against
29
+ * the well-known public dev secret). Defaults to false, so a dev-signed
30
+ * pack reports `signatureStatus: 'dev-signature'` rather than 'verified'.
31
+ * Surfaced as `--allow-dev-signature` on `shrk packs verify` / `doctor`.
32
+ */
33
+ allowDevSignatures?: boolean;
20
34
  /**
21
35
  * Skip the process-level discovery cache. The cache is keyed by
22
36
  * projectRoot + lockfile mtime, so installs/upgrades invalidate it
@@ -1 +1 @@
1
- {"version":3,"file":"discover-packs.d.ts","sourceRoot":"","sources":["../../src/discovery/discover-packs.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAmB,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAuHxF,MAAM,WAAW,oBAAoB;IACnC,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;I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EAAE,oBAAoB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA0JhG"}
@@ -9,7 +9,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
9
9
  import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
10
10
  import * as nodePath from 'node:path';
11
11
  import { pathToFileURL } from 'node:url';
12
- import { PACK_SECRET_ENV, validatePackManifest, verifyPackManifest, } from '@shrkcrft/plugin-api';
12
+ import { CONTRIBUTION_FILE_KEYS, PACK_SECRET_ENV, validatePackManifest, verifyPackManifest, } from '@shrkcrft/plugin-api';
13
13
  function readPackageJson(pkgPath) {
14
14
  try {
15
15
  return JSON.parse(readFileSync(pkgPath, 'utf8'));
@@ -30,39 +30,28 @@ function resolveManifestPath(packageRoot, manifestField) {
30
30
  return null;
31
31
  }
32
32
  function emptyCounts() {
33
- return {
34
- knowledgeFiles: 0,
35
- ruleFiles: 0,
36
- pathFiles: 0,
37
- templateFiles: 0,
38
- pipelineFiles: 0,
39
- docsFiles: 0,
40
- presetFiles: 0,
41
- scaffoldPatternFiles: 0,
42
- policyCheckFiles: 0,
43
- constructFiles: 0,
44
- constructFacetFiles: 0,
45
- playbookFiles: 0,
46
- delegateRecipeFiles: 0,
47
- };
33
+ // Initialise EVERY canonical contribution key to 0 so an extended-only pack
34
+ // (conventions / helpers / framework extractors / …) still reports its kinds
35
+ // rather than silently dropping them.
36
+ const out = {};
37
+ for (const key of CONTRIBUTION_FILE_KEYS)
38
+ out[key] = 0;
39
+ return out;
48
40
  }
49
- function countContributions(c) {
41
+ /**
42
+ * Count declared contribution files per kind, driven by the canonical
43
+ * `CONTRIBUTION_FILE_KEYS`. Exported so callers (quality scoring, tests) can
44
+ * derive the same honest totals without re-implementing the slot list.
45
+ */
46
+ export function countContributions(c) {
50
47
  const out = emptyCounts();
51
48
  if (!c)
52
49
  return out;
53
- out.knowledgeFiles = c.knowledgeFiles?.length ?? 0;
54
- out.ruleFiles = c.ruleFiles?.length ?? 0;
55
- out.pathFiles = c.pathFiles?.length ?? 0;
56
- out.templateFiles = c.templateFiles?.length ?? 0;
57
- out.pipelineFiles = c.pipelineFiles?.length ?? 0;
58
- out.docsFiles = c.docsFiles?.length ?? 0;
59
- out.presetFiles = c.presetFiles?.length ?? 0;
60
- out.scaffoldPatternFiles = c.scaffoldPatternFiles?.length ?? 0;
61
- out.policyCheckFiles = c.policyCheckFiles?.length ?? 0;
62
- out.constructFiles = c.constructFiles?.length ?? 0;
63
- out.constructFacetFiles = c.constructFacetFiles?.length ?? 0;
64
- out.playbookFiles = c.playbookFiles?.length ?? 0;
65
- out.delegateRecipeFiles = c.delegateRecipeFiles?.length ?? 0;
50
+ const counts = out;
51
+ const contrib = c;
52
+ for (const key of CONTRIBUTION_FILE_KEYS) {
53
+ counts[key] = contrib[key]?.length ?? 0;
54
+ }
66
55
  return out;
67
56
  }
68
57
  /**
@@ -272,11 +261,16 @@ export async function discoverPacks(options) {
272
261
  discovered.validationIssues = v.issues;
273
262
  discovered.valid = v.valid;
274
263
  if (options.verifySignatures) {
275
- const verifyResult = verifyPackManifest(manifest, { secret: options.packSecret });
264
+ const verifyResult = verifyPackManifest(manifest, {
265
+ secret: options.packSecret,
266
+ ...(options.allowDevSignatures ? { allowDev: true } : {}),
267
+ });
276
268
  discovered.signatureStatus = verifyResult.ok ? 'verified' : verifyResult.status;
277
269
  discovered.signatureMessage = verifyResult.ok
278
270
  ? 'Signature verified.'
279
271
  : verifyResult.message;
272
+ if (verifyResult.dev === true)
273
+ discovered.signatureDev = true;
280
274
  if (!verifyResult.ok && verifyResult.status === 'invalid-signature') {
281
275
  // Tampered manifest — strip validity.
282
276
  discovered.valid = false;
@@ -289,6 +283,8 @@ export async function discoverPacks(options) {
289
283
  else if (manifest.signature) {
290
284
  discovered.signatureStatus = 'not-checked';
291
285
  discovered.signatureMessage = `Signed but not verified. Set ${PACK_SECRET_ENV} and run packs verify.`;
286
+ if (manifest.signature.dev === true)
287
+ discovered.signatureDev = true;
292
288
  }
293
289
  }
294
290
  }
@@ -1,4 +1,4 @@
1
- import type { ISharkCraftPackManifest } from '@shrkcrft/plugin-api';
1
+ import type { ContributionFileKey, ISharkCraftPackManifest } from '@shrkcrft/plugin-api';
2
2
  export interface IDiscoveredPack {
3
3
  /** Published package name (from package.json). */
4
4
  packageName: string;
@@ -9,7 +9,16 @@ export interface IDiscoveredPack {
9
9
  packageRoot: string;
10
10
  /** Parsed manifest, if it loaded. */
11
11
  manifest?: ISharkCraftPackManifest;
12
- /** Number of contribution **files** of each kind. Zero if not declared. */
12
+ /**
13
+ * Number of contribution **files** of each kind. Zero if not declared.
14
+ *
15
+ * Populated generically from the canonical `CONTRIBUTION_FILE_KEYS`
16
+ * (`@shrkcrft/plugin-api`) so an "extended"-only pack (conventions / helpers /
17
+ * framework extractors / decisions / …) still reports a non-zero declared
18
+ * total. The originally-tracked kinds stay required for back-compat; the
19
+ * extended kinds are optional so older object literals keep type-checking, but
20
+ * `countContributions` fills in every key.
21
+ */
13
22
  contributionCounts: {
14
23
  knowledgeFiles: number;
15
24
  ruleFiles: number;
@@ -24,7 +33,7 @@ export interface IDiscoveredPack {
24
33
  constructFacetFiles: number;
25
34
  playbookFiles: number;
26
35
  delegateRecipeFiles: number;
27
- };
36
+ } & Partial<Record<ContributionFileKey, number>>;
28
37
  /**
29
38
  * Number of **resolved objects** loaded from this pack's contributions, after
30
39
  * de-duplication against local entries and inside the pack. Populated by the
@@ -52,9 +61,18 @@ export interface IDiscoveredPack {
52
61
  /** True if the manifest loaded and validated cleanly. */
53
62
  valid: boolean;
54
63
  /** Signature verification status, when applicable. */
55
- signatureStatus?: 'verified' | 'invalid-signature' | 'missing-signature' | 'missing-secret' | 'not-checked';
64
+ signatureStatus?: 'verified' | 'invalid-signature' | 'missing-signature' | 'missing-secret' | 'dev-signature' | 'not-checked';
56
65
  /** Free-form message accompanying the signature status. */
57
66
  signatureMessage?: string;
67
+ /**
68
+ * True when this pack's signature carries `dev: true` — produced by
69
+ * `shrk packs sign --dev` and verified only against the well-known public
70
+ * dev secret. Dev signatures are NOT release-trusted; they verify under
71
+ * `--allow-dev-signature` but otherwise report `signatureStatus:
72
+ * 'dev-signature'`. Populated from the verify result (or, when verification
73
+ * did not run, from the manifest's signature block).
74
+ */
75
+ signatureDev?: boolean;
58
76
  }
59
77
  export interface IPackDiscoveryResult {
60
78
  projectRoot: string;
@@ -1 +1 @@
1
- {"version":3,"file":"pack-discovery.d.ts","sourceRoot":"","sources":["../../src/model/pack-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,kDAAkD;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,0DAA0D;IAC1D,YAAY,EAAE,MAAM,CAAC;IACrB,2CAA2C;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,uBAAuB,CAAC;IACnC,2EAA2E;IAC3E,kBAAkB,EAAE;QAClB,cAAc,EAAE,MAAM,CAAC;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,aAAa,EAAE,MAAM,CAAC;QACtB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;QACpB,oBAAoB,EAAE,MAAM,CAAC;QAC7B,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,aAAa,EAAE,MAAM,CAAC;QACtB,mBAAmB,EAAE,MAAM,CAAC;KAC7B,CAAC;IACF;;;;;OAKG;IACH,cAAc,CAAC,EAAE;QACf,gBAAgB,EAAE,MAAM,CAAC;QACzB,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,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AmB,GACnB,mBAAmB,GACnB,gBAAgB,GAChB,eAAe,GACf,aAAa,CAAC;IAClB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,sDAAsD;IACtD,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,uDAAuD;IACvD,mBAAmB,EAAE,MAAM,CAAC;IAC5B,uDAAuD;IACvD,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,2BAA2B;IAC3B,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shrkcrft/packs",
3
- "version": "0.1.0-alpha.21",
3
+ "version": "0.1.0-alpha.23",
4
4
  "description": "SharkCraft pack discovery + loading: scan node_modules for sharkcraft manifests and surface contributions.",
5
5
  "license": "MIT",
6
6
  "author": "SharkCraft contributors",
@@ -42,8 +42,8 @@
42
42
  "typecheck": "tsc --noEmit -p tsconfig.json"
43
43
  },
44
44
  "dependencies": {
45
- "@shrkcrft/core": "^0.1.0-alpha.21",
46
- "@shrkcrft/plugin-api": "^0.1.0-alpha.21"
45
+ "@shrkcrft/core": "^0.1.0-alpha.23",
46
+ "@shrkcrft/plugin-api": "^0.1.0-alpha.23"
47
47
  },
48
48
  "publishConfig": {
49
49
  "access": "public"