@pikku/inspector 0.12.85 → 0.12.86

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/CHANGELOG.md CHANGED
@@ -1,3 +1,50 @@
1
+ ## 0.12.86
2
+
3
+ ### Patch Changes
4
+
5
+ - f05fb4e: A scenario that belongs to no feature is now reported.
6
+
7
+ Features are what the guide is written against: prose cites a feature, and the compiler fills that citation with the evidence from the scenarios the feature owns. A scenario nobody listed is therefore invisible — it runs, it captures screenshots and recordings, and none of it ever reaches a page. That failure is silent today, and it is the single reason two real projects have hundreds of captures bound to nothing.
8
+
9
+ The inspector now walks every feature's scenario list, and any scenario not claimed by one is reported as `PKU682`. It is an error rather than a critical, so `pikku all` keeps passing by default and the list is there to work through; `--fail-on-error` makes it a wall once a project has caught up.
10
+
11
+ Membership reads the scenario each entry names, not the entry itself. A `data` the AST cannot evaluate — `'a'.repeat(64)`, a call, anything computed — leaves the entry partial for the console but says nothing about who owns the scenario, and the check no longer treats the two as the same thing.
12
+
13
+ An entry that names no scenario at all — a spread, a `.map()` — does leave membership unknown. That only matters once something is already unowned, so the check reports it then, as a warn naming both the unowned scenarios and the features that could be hiding them, rather than accusing a scenario that may well be in one of those arrays.
14
+
15
+ - b4a895e: `pikku scenario guide` writes the user guide a scenario suite already contains. A feature reads as a page and a scenario as a section, and a run leaves screenshots behind with the captions their author took them under — the command joins that to the editorial prose a project checks in under `docs/` and writes markdown. It renders no HTML, ships no components, resolves no asset URLs and calls no model: an image is an ordinary relative `![caption](path)`, and whoever consumes the markdown rewrites the paths.
16
+
17
+ A page cites a feature by leaving the marker pair where the block belongs:
18
+
19
+ ```markdown
20
+ ---
21
+ title: Deployments
22
+ ---
23
+
24
+ A deployment is one tracked shipment of your app.
25
+
26
+ <!-- pikku:guide feature=deploymentsFeature -->
27
+ <!-- /pikku:guide -->
28
+
29
+ ## Does my app go down during a deploy?
30
+ ```
31
+
32
+ That one line does both halves of the job. It says _where_ the block goes, which a frontmatter list cannot express, and it is what the coverage gate counts to decide _whether_ a feature is documented at all. The mapping stays many-to-many and falls out of the union of every marker in the tree. A rebuild rewrites exactly the regions between the markers, so every sentence a human wrote around them survives.
33
+
34
+ **The steps are evidence, not content.** A generated block is the scenario's title, the description its author wrote, and the shots it filed — never a numbered Given/When/Then ladder, which is a test report and not something anybody arrives at a documentation page wanting. The sentences are still what the guide is kept honest against: `docs/.guide.lock` records a hash of each feature's step sentences and artifact ids, deliberately not of the image bytes. Restyling a UI changes every screenshot and no sentence; inserting or renaming a step changes what the prose was describing, and the page is reported stale. The lock is generated and checked in, so no hash is ever typed or merged by hand — and a tree whose lock is untracked reports every page as current forever.
35
+
36
+ Every registered feature has to be cited by some page, and a feature that is pure plumbing says so rather than being written about — `pikkuFeature({ document: false })`, threaded through the inspector and `FeatureMeta`. An uncited feature fails the command by name; `--allow-undocumented` downgrades that one failure to a report. A page citing a feature id that is not registered stays an error either way.
37
+
38
+ A guide is only written out of a run that can stand behind it. A run that failed or was killed halfway is refused, because a page is a claim that the product does what it says. So is a narrowed one: `pikku scenario run --flows`/`--features`/`--tags` leaves out scenarios the suite has, and a guide built from it would describe those flows as though they do not exist. `ScenarioRunRecord.selection` records the filters a run was selected with, since nothing in the results afterwards can tell a suite of forty from forty that were asked for.
39
+
40
+ Results are joined to features by `featureId`, falling back to the display name only for records written before that field existed — a title is rewritten freely and two features may share one.
41
+
42
+ Emission is deterministic — identical inputs give byte-identical output, and no timestamp goes in that did not come from the run record. Frontmatter the compiler does not own (`slug`, `draft`, `sidebar_position`, anything else a docs site reads) passes through untouched, and a source written with CRLF line endings is read as having frontmatter.
43
+
44
+ - Updated dependencies [b4a895e]
45
+ - Updated dependencies [b4a895e]
46
+ - @pikku/core@0.12.118
47
+
1
48
  ## 0.12.85
2
49
 
3
50
  ### Patch Changes
@@ -96,6 +96,16 @@ const stringProperty = (config, name) => {
96
96
  const value = getProperty(config, name);
97
97
  return value && ts.isStringLiteralLike(value) ? value.text : undefined;
98
98
  };
99
+ const booleanProperty = (config, name) => {
100
+ const value = getProperty(config, name);
101
+ if (!value) {
102
+ return undefined;
103
+ }
104
+ if (value.kind === ts.SyntaxKind.TrueKeyword) {
105
+ return true;
106
+ }
107
+ return value.kind === ts.SyntaxKind.FalseKeyword ? false : undefined;
108
+ };
99
109
  const stringArrayProperty = (config, name) => {
100
110
  const value = getProperty(config, name);
101
111
  if (!value || !ts.isArrayLiteralExpression(value)) {
@@ -106,6 +116,16 @@ const stringArrayProperty = (config, name) => {
106
116
  .map((e) => e.text);
107
117
  return values.length === value.elements.length ? values : undefined;
108
118
  };
119
+ const mentionedScenario = (element, checker) => {
120
+ if (ts.isIdentifier(element)) {
121
+ return scenarioName(element, checker);
122
+ }
123
+ if (ts.isObjectLiteralExpression(element)) {
124
+ const reference = getProperty(element, 'scenario');
125
+ return reference ? scenarioName(reference, checker) : undefined;
126
+ }
127
+ return undefined;
128
+ };
109
129
  const readEntry = (element, checker) => {
110
130
  if (ts.isIdentifier(element)) {
111
131
  const scenario = scenarioName(element, checker);
@@ -164,6 +184,8 @@ export const addFeature = (logger, node, checker, state) => {
164
184
  exportedName,
165
185
  entries: [],
166
186
  unresolvedEntries: 0,
187
+ mentions: [],
188
+ unnamedEntries: 0,
167
189
  hasBefore: false,
168
190
  hasAfter: false,
169
191
  };
@@ -172,6 +194,10 @@ export const addFeature = (logger, node, checker, state) => {
172
194
  const name = stringProperty(config, 'name');
173
195
  const description = stringProperty(config, 'description');
174
196
  const tags = stringArrayProperty(config, 'tags');
197
+ const document = booleanProperty(config, 'document');
198
+ if (document !== undefined) {
199
+ feature.document = document;
200
+ }
175
201
  if (name !== undefined) {
176
202
  feature.name = name;
177
203
  }
@@ -186,6 +212,13 @@ export const addFeature = (logger, node, checker, state) => {
186
212
  const scenarios = getProperty(config, 'scenarios');
187
213
  if (scenarios && ts.isArrayLiteralExpression(scenarios)) {
188
214
  for (const element of scenarios.elements) {
215
+ const mention = mentionedScenario(element, checker);
216
+ if (mention) {
217
+ feature.mentions.push(mention);
218
+ }
219
+ else {
220
+ feature.unnamedEntries += 1;
221
+ }
189
222
  const entry = readEntry(element, checker);
190
223
  if (entry) {
191
224
  feature.entries.push(entry);
@@ -25,6 +25,7 @@ export declare enum ErrorCode {
25
25
  SCENARIO_NOT_EXTRACTABLE = "PKU679",
26
26
  SCENARIO_HAS_NO_ASSERTION = "PKU680",
27
27
  SCENARIO_STEP_PROSE_NAMES_ACTOR = "PKU681",
28
+ SCENARIO_HAS_NO_FEATURE = "PKU682",
28
29
  WORKFLOW_ORCHESTRATOR_NOT_CONFIGURED = "PKU600",
29
30
  INVALID_DSL_WORKFLOW = "PKU641",
30
31
  WORKFLOW_GRAPH_ADDON_NOT_WIRED = "PKU642",
@@ -27,6 +27,7 @@ export var ErrorCode;
27
27
  ErrorCode["SCENARIO_NOT_EXTRACTABLE"] = "PKU679";
28
28
  ErrorCode["SCENARIO_HAS_NO_ASSERTION"] = "PKU680";
29
29
  ErrorCode["SCENARIO_STEP_PROSE_NAMES_ACTOR"] = "PKU681";
30
+ ErrorCode["SCENARIO_HAS_NO_FEATURE"] = "PKU682";
30
31
  ErrorCode["WORKFLOW_ORCHESTRATOR_NOT_CONFIGURED"] = "PKU600";
31
32
  ErrorCode["INVALID_DSL_WORKFLOW"] = "PKU641";
32
33
  ErrorCode["WORKFLOW_GRAPH_ADDON_NOT_WIRED"] = "PKU642";
package/dist/inspector.js CHANGED
@@ -7,7 +7,7 @@ import { getFilesAndMethods } from './utils/get-files-and-methods.js';
7
7
  import { findCommonAncestor } from './utils/find-root-dir.js';
8
8
  import { createSourceFileCacheHost } from './source-file-cache.js';
9
9
  import { createNestedProjectFilter } from './utils/nested-project-filter.js';
10
- import { aggregateRequiredServices, stampAuthHandlerServices, validateAgentModels, validateAgentToolReferences, validateAgentScorerReferences, validateSecretOverrides, validateVariableOverrides, validateCredentialOverrides, validateRemoteAddonDependencies, validateRemoteAddonAuth, validateScopeReferences, validateSystemRoleScopes, validatePersonaRoles, computeResolvedIOTypes, computeMiddlewareGroupsMeta, computePermissionsGroupsMeta, computeRequiredSchemas, validateNoSecretAliasServices, registerDerivedOAuth2AppSecrets, validateSecretUsage, computeDiagnostics, validateSchemaReferences, validateSchemaWiringSeparation, validateScenarioServices, validateScenarioSteps, validateWorkflowGraphAddons, } from './utils/post-process.js';
10
+ import { aggregateRequiredServices, stampAuthHandlerServices, validateAgentModels, validateAgentToolReferences, validateAgentScorerReferences, validateSecretOverrides, validateVariableOverrides, validateCredentialOverrides, validateRemoteAddonDependencies, validateRemoteAddonAuth, validateScopeReferences, validateSystemRoleScopes, validatePersonaRoles, computeResolvedIOTypes, computeMiddlewareGroupsMeta, computePermissionsGroupsMeta, computeRequiredSchemas, validateNoSecretAliasServices, registerDerivedOAuth2AppSecrets, validateSecretUsage, computeDiagnostics, validateSchemaReferences, validateSchemaWiringSeparation, validateScenarioServices, validateScenarioSteps, validateScenarioFeatures, validateWorkflowGraphAddons, } from './utils/post-process.js';
11
11
  import { validateExposedFunctionsGated } from './utils/validate-exposed-functions-gated.js';
12
12
  import { validateTagsResolveToMiddleware } from './utils/validate-tags-resolve-to-middleware.js';
13
13
  import { annotateHttpRouteAuth } from './utils/annotate-http-route-auth.js';
@@ -405,6 +405,7 @@ export const inspect = async (logger, routeFiles, options = {}) => {
405
405
  validateWorkflowGraphAddons(logger, state);
406
406
  validateScenarioServices(logger, state);
407
407
  validateScenarioSteps(logger, state);
408
+ validateScenarioFeatures(logger, state);
408
409
  // Needs every route, every function and every wireAddon declaration
409
410
  // together, so it can only run once the whole program is inspected.
410
411
  annotateHttpRouteAuth(state);
package/dist/types.d.ts CHANGED
@@ -455,6 +455,8 @@ export interface InspectorFeature {
455
455
  name?: string;
456
456
  description?: string;
457
457
  tags?: string[];
458
+ /** `document: false` on the config, and only that — an absent flag documents. */
459
+ document?: boolean;
458
460
  entries: InspectorFeatureEntry[];
459
461
  /**
460
462
  * Entries that are not literal — a spread, a `.map()`, a call. Counted rather
@@ -462,6 +464,17 @@ export interface InspectorFeature {
462
464
  * quietly showing a short feature.
463
465
  */
464
466
  unresolvedEntries: number;
467
+ /**
468
+ * Every scenario the array names, including entries whose `data` could not be
469
+ * read. Membership is knowable there even when the entry is not — which is
470
+ * what the check for a scenario belonging to no feature compares against.
471
+ */
472
+ mentions: string[];
473
+ /**
474
+ * Entries that name no scenario at all — a spread, a `.map()`. Only these
475
+ * leave membership genuinely unknown.
476
+ */
477
+ unnamedEntries: number;
465
478
  /**
466
479
  * Feature hooks run once around the whole group, never per scenario, and are
467
480
  * runtime-only — so only their presence is recorded.
@@ -129,6 +129,31 @@ export declare const proseOpensWithActor: (prose: string, actor: string) => bool
129
129
  * singletons the step actually needs.
130
130
  */
131
131
  export declare function validateScenarioSteps(logger: InspectorLogger, state: InspectorState | Omit<InspectorState, 'typesLookup'>): void;
132
+ /**
133
+ * Reports scenarios that no `pikkuFeature` lists.
134
+ *
135
+ * A feature is what a run stamps onto each result, and the only handle anything
136
+ * downstream has on a scenario: the console groups by it and the guide cites it.
137
+ * A scenario in no feature still runs and still passes — it simply files its
138
+ * results, and any screenshot or recording it took, where nothing can reach
139
+ * them. That is not a style violation, it is work being thrown away, and it is
140
+ * invisible precisely because the suite is green.
141
+ *
142
+ * It is an `error` rather than a `critical` because every suite written before
143
+ * the rule has some, and a hard failure on a CLI bump would strand them with no
144
+ * way to defer. `--fail-on-error` is how a project opts in once it has bound
145
+ * what it has.
146
+ *
147
+ * Membership reads the scenario each entry names, not the entry itself: a
148
+ * `data` the AST cannot evaluate leaves the entry partial for the console but
149
+ * says nothing about who owns the scenario.
150
+ *
151
+ * An entry that names no scenario at all (a spread, a `.map()`) does leave
152
+ * membership unknown. That only matters when something is already unowned, so
153
+ * the check reports it then and downgrades to a warn naming both sides, rather
154
+ * than accusing a scenario that may well be in that array.
155
+ */
156
+ export declare function validateScenarioFeatures(logger: InspectorLogger, state: InspectorState | Omit<InspectorState, 'typesLookup'>): void;
132
157
  /**
133
158
  * A `pikkuWorkflowGraph` node that references the `graph:` namespace (e.g.
134
159
  * `graph:editFields`) needs @pikku/addon-graph wired — otherwise the RPC never
@@ -943,6 +943,79 @@ export function validateScenarioSteps(logger, state) {
943
943
  }
944
944
  }
945
945
  }
946
+ /**
947
+ * Reports scenarios that no `pikkuFeature` lists.
948
+ *
949
+ * A feature is what a run stamps onto each result, and the only handle anything
950
+ * downstream has on a scenario: the console groups by it and the guide cites it.
951
+ * A scenario in no feature still runs and still passes — it simply files its
952
+ * results, and any screenshot or recording it took, where nothing can reach
953
+ * them. That is not a style violation, it is work being thrown away, and it is
954
+ * invisible precisely because the suite is green.
955
+ *
956
+ * It is an `error` rather than a `critical` because every suite written before
957
+ * the rule has some, and a hard failure on a CLI bump would strand them with no
958
+ * way to defer. `--fail-on-error` is how a project opts in once it has bound
959
+ * what it has.
960
+ *
961
+ * Membership reads the scenario each entry names, not the entry itself: a
962
+ * `data` the AST cannot evaluate leaves the entry partial for the console but
963
+ * says nothing about who owns the scenario.
964
+ *
965
+ * An entry that names no scenario at all (a spread, a `.map()`) does leave
966
+ * membership unknown. That only matters when something is already unowned, so
967
+ * the check reports it then and downgrades to a warn naming both sides, rather
968
+ * than accusing a scenario that may well be in that array.
969
+ */
970
+ export function validateScenarioFeatures(logger, state) {
971
+ const features = state.workflows.featureFiles;
972
+ if (!features) {
973
+ return;
974
+ }
975
+ const owned = new Set();
976
+ for (const feature of features.values()) {
977
+ for (const mention of feature.mentions) {
978
+ owned.add(mention);
979
+ }
980
+ }
981
+ const files = state.workflows.files;
982
+ const unowned = [];
983
+ for (const [workflowName, meta] of Object.entries(state.workflows.meta)) {
984
+ if (!meta.scenario) {
985
+ continue;
986
+ }
987
+ const exported = files?.get(workflowName)?.exportedName;
988
+ if (owned.has(workflowName) || (exported && owned.has(exported))) {
989
+ continue;
990
+ }
991
+ unowned.push(workflowName);
992
+ }
993
+ if (unowned.length === 0) {
994
+ return;
995
+ }
996
+ const unreadable = [...features.values()]
997
+ .filter((feature) => feature.unnamedEntries > 0)
998
+ .map((feature) => feature.exportedName);
999
+ if (unreadable.length > 0) {
1000
+ logger.diagnostic({
1001
+ severity: 'warn',
1002
+ code: ErrorCode.SCENARIO_HAS_NO_FEATURE,
1003
+ message: `${unowned.map((name) => `'${name}'`).join(', ')} appear in no feature's \`scenarios\` array, ` +
1004
+ `but ${unreadable.map((name) => `'${name}'`).join(', ')} build theirs with a spread or a call, so one of them may still be listed there. ` +
1005
+ `List those scenarios literally and this becomes a definite answer either way.`,
1006
+ });
1007
+ return;
1008
+ }
1009
+ for (const name of unowned) {
1010
+ logger.diagnostic({
1011
+ severity: 'error',
1012
+ code: ErrorCode.SCENARIO_HAS_NO_FEATURE,
1013
+ message: `Scenario '${name}' is listed by no pikkuFeature, so nothing downstream can reach it — ` +
1014
+ `a run stamps no feature onto its results, the console groups it under none, and a guide cannot cite it. ` +
1015
+ `Add it to a feature's \`scenarios\` array.`,
1016
+ });
1017
+ }
1018
+ }
946
1019
  /**
947
1020
  * A `pikkuWorkflowGraph` node that references the `graph:` namespace (e.g.
948
1021
  * `graph:editFields`) needs @pikku/addon-graph wired — otherwise the RPC never
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pikku/inspector",
3
- "version": "0.12.85",
3
+ "version": "0.12.86",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/pikkujs/pikku.git",
@@ -55,10 +55,10 @@
55
55
  "zod-to-ts": "^2.1.0"
56
56
  },
57
57
  "peerDependencies": {
58
- "@pikku/core": "^0.12.116"
58
+ "@pikku/core": "^0.12.118"
59
59
  },
60
60
  "devDependencies": {
61
- "@pikku/core": "^0.12.116",
61
+ "@pikku/core": "^0.12.118",
62
62
  "@types/node": "^24.13.3"
63
63
  },
64
64
  "engines": {