@pikku/inspector 0.12.75 → 0.12.81

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 (219) hide show
  1. package/CHANGELOG.md +330 -0
  2. package/dist/add/add-analytics.d.ts +9 -0
  3. package/dist/add/add-analytics.js +178 -0
  4. package/dist/add/add-auth.js +0 -54
  5. package/dist/add/add-feature-flag.d.ts +2 -0
  6. package/dist/add/add-feature-flag.js +162 -0
  7. package/dist/add/add-wire-addon.js +1 -0
  8. package/dist/add/add-wire-remote-addon.js +1 -0
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.js +3 -1
  11. package/dist/inspector.js +4 -0
  12. package/dist/surface/collect-surface.d.ts +58 -0
  13. package/dist/surface/collect-surface.js +613 -0
  14. package/dist/types.d.ts +20 -11
  15. package/dist/utils/filter-inspector-state.js +14 -0
  16. package/dist/utils/post-process.js +15 -0
  17. package/dist/utils/read-module-specifiers.d.ts +8 -0
  18. package/dist/utils/read-module-specifiers.js +23 -0
  19. package/dist/utils/read-tsconfig-out-dir.d.ts +5 -0
  20. package/dist/utils/read-tsconfig-out-dir.js +12 -0
  21. package/dist/utils/resolve-deploy-target.d.ts +7 -0
  22. package/dist/utils/resolve-deploy-target.js +15 -7
  23. package/dist/utils/serialize-inspector-state.d.ts +5 -0
  24. package/dist/utils/serialize-inspector-state.js +8 -0
  25. package/dist/visit.js +4 -0
  26. package/package.json +16 -6
  27. package/run-tests.sh +21 -6
  28. package/src/add/add-addon-bans.ts +0 -85
  29. package/src/add/add-agent-scorer.test.ts +0 -197
  30. package/src/add/add-agent-scorer.ts +0 -83
  31. package/src/add/add-agent.test.ts +0 -87
  32. package/src/add/add-agent.ts +0 -638
  33. package/src/add/add-approval-description.ts +0 -76
  34. package/src/add/add-auth.test.ts +0 -791
  35. package/src/add/add-auth.ts +0 -424
  36. package/src/add/add-channel.ts +0 -778
  37. package/src/add/add-cli-renderers.test.ts +0 -74
  38. package/src/add/add-cli.ts +0 -1006
  39. package/src/add/add-credential.ts +0 -186
  40. package/src/add/add-feature.test.ts +0 -306
  41. package/src/add/add-feature.ts +0 -253
  42. package/src/add/add-file-extends-core-type.ts +0 -66
  43. package/src/add/add-file-with-config.ts +0 -45
  44. package/src/add/add-file-with-factory.test.ts +0 -134
  45. package/src/add/add-file-with-factory.ts +0 -288
  46. package/src/add/add-functions.test.ts +0 -743
  47. package/src/add/add-functions.ts +0 -1548
  48. package/src/add/add-gateway.ts +0 -143
  49. package/src/add/add-http-route-ref.test.ts +0 -149
  50. package/src/add/add-http-route.ts +0 -530
  51. package/src/add/add-http-routes.ts +0 -471
  52. package/src/add/add-keyed-wiring.ts +0 -180
  53. package/src/add/add-mcp-prompt.ts +0 -157
  54. package/src/add/add-mcp-resource.ts +0 -175
  55. package/src/add/add-middleware.test.ts +0 -196
  56. package/src/add/add-middleware.ts +0 -879
  57. package/src/add/add-permission-auth.test.ts +0 -59
  58. package/src/add/add-permission.ts +0 -311
  59. package/src/add/add-personas.test.ts +0 -406
  60. package/src/add/add-personas.ts +0 -287
  61. package/src/add/add-queue-worker.ts +0 -117
  62. package/src/add/add-rpc-invocations.test.ts +0 -287
  63. package/src/add/add-rpc-invocations.ts +0 -221
  64. package/src/add/add-scenario-step.test.ts +0 -509
  65. package/src/add/add-schedule.ts +0 -120
  66. package/src/add/add-scope.test.ts +0 -419
  67. package/src/add/add-scope.ts +0 -221
  68. package/src/add/add-secret.ts +0 -10
  69. package/src/add/add-subject-scenario-steps.test.ts +0 -161
  70. package/src/add/add-system-role.test.ts +0 -297
  71. package/src/add/add-system-role.ts +0 -162
  72. package/src/add/add-trigger.ts +0 -165
  73. package/src/add/add-variable.ts +0 -10
  74. package/src/add/add-wire-addon.test.ts +0 -185
  75. package/src/add/add-wire-addon.ts +0 -146
  76. package/src/add/add-wire-remote-addon.ts +0 -80
  77. package/src/add/add-workflow-edge-cases.test.ts +0 -201
  78. package/src/add/add-workflow-fanout.test.ts +0 -166
  79. package/src/add/add-workflow-graph-foreach.test.ts +0 -174
  80. package/src/add/add-workflow-graph-input.test.ts +0 -94
  81. package/src/add/add-workflow-graph-notes.test.ts +0 -74
  82. package/src/add/add-workflow-graph.ts +0 -644
  83. package/src/add/add-workflow-on-error.test.ts +0 -118
  84. package/src/add/add-workflow-return-switch.test.ts +0 -121
  85. package/src/add/add-workflow-silent-drops.test.ts +0 -261
  86. package/src/add/add-workflow-sleep-expression.test.ts +0 -96
  87. package/src/add/add-workflow.test.ts +0 -155
  88. package/src/add/add-workflow.ts +0 -482
  89. package/src/add/addon-bans.test.ts +0 -121
  90. package/src/add/addon-contracts.test.ts +0 -221
  91. package/src/add/allow-escape-hatches.test.ts +0 -144
  92. package/src/add/audit-meta.test.ts +0 -75
  93. package/src/add/classified-sink-check.test.ts +0 -347
  94. package/src/add/config-value-metadata.test.ts +0 -263
  95. package/src/add/dynamic-import-check.test.ts +0 -119
  96. package/src/add/expect-eventually-scenario-only.test.ts +0 -108
  97. package/src/add/function-body-span.test.ts +0 -96
  98. package/src/add/inline-wiring-function.test.ts +0 -104
  99. package/src/add/pii-check.test.ts +0 -258
  100. package/src/add/rpc-type-cast.test.ts +0 -123
  101. package/src/add/scenario-instrumentation.test.ts +0 -89
  102. package/src/add/scenario-instrumentation.ts +0 -42
  103. package/src/add/scenario-marker.test.ts +0 -89
  104. package/src/add/scenario-not-extractable.test.ts +0 -159
  105. package/src/add/scenario-services.test.ts +0 -103
  106. package/src/add/scenario-skip.test.ts +0 -83
  107. package/src/add/validate-workflow-graph-addons.test.ts +0 -102
  108. package/src/add/wire-name-literal.test.ts +0 -117
  109. package/src/error-codes-emitted.test.ts +0 -76
  110. package/src/error-codes.ts +0 -145
  111. package/src/index.ts +0 -66
  112. package/src/inspector.ts +0 -575
  113. package/src/schema-generator.ts +0 -1
  114. package/src/source-file-cache.ts +0 -73
  115. package/src/tsconfig-paths.test.ts +0 -90
  116. package/src/types-map.ts +0 -141
  117. package/src/types.ts +0 -775
  118. package/src/utils/annotate-http-route-auth.test.ts +0 -161
  119. package/src/utils/annotate-http-route-auth.ts +0 -53
  120. package/src/utils/check-classified-sinks.ts +0 -215
  121. package/src/utils/check-pii-output.ts +0 -120
  122. package/src/utils/compute-diagnostics.test.ts +0 -106
  123. package/src/utils/compute-required-schemas.ts +0 -48
  124. package/src/utils/contract-hashes.test.ts +0 -553
  125. package/src/utils/contract-hashes.ts +0 -387
  126. package/src/utils/custom-types-generator.test.ts +0 -124
  127. package/src/utils/custom-types-generator.ts +0 -150
  128. package/src/utils/detect-schema-vendor.test.ts +0 -123
  129. package/src/utils/detect-schema-vendor.ts +0 -120
  130. package/src/utils/does-type-extend-core-type.ts +0 -53
  131. package/src/utils/ensure-function-metadata.ts +0 -385
  132. package/src/utils/extract-function-name.ts +0 -612
  133. package/src/utils/extract-function-node.ts +0 -70
  134. package/src/utils/extract-node-value.test.ts +0 -117
  135. package/src/utils/extract-node-value.ts +0 -172
  136. package/src/utils/extract-secret-usage.test.ts +0 -81
  137. package/src/utils/extract-secret-usage.ts +0 -73
  138. package/src/utils/extract-services.ts +0 -70
  139. package/src/utils/extract-surface-usage.test.ts +0 -147
  140. package/src/utils/extract-surface-usage.ts +0 -121
  141. package/src/utils/filter-inspector-state.test.ts +0 -2232
  142. package/src/utils/filter-inspector-state.ts +0 -1298
  143. package/src/utils/filter-utils.test.ts +0 -843
  144. package/src/utils/filter-utils.ts +0 -161
  145. package/src/utils/find-root-dir.ts +0 -68
  146. package/src/utils/find-zod-transform.test.ts +0 -70
  147. package/src/utils/find-zod-transform.ts +0 -103
  148. package/src/utils/get-exported-variable-name.ts +0 -48
  149. package/src/utils/get-files-and-methods.ts +0 -157
  150. package/src/utils/get-property-value.test.ts +0 -141
  151. package/src/utils/get-property-value.ts +0 -331
  152. package/src/utils/hash.ts +0 -26
  153. package/src/utils/literal-properties.ts +0 -97
  154. package/src/utils/load-addon-functions-meta.test.ts +0 -157
  155. package/src/utils/load-addon-functions-meta.ts +0 -508
  156. package/src/utils/load-addon-scopes.test.ts +0 -138
  157. package/src/utils/middleware.test.ts +0 -204
  158. package/src/utils/middleware.ts +0 -303
  159. package/src/utils/nested-project-filter.test.ts +0 -53
  160. package/src/utils/nested-project-filter.ts +0 -28
  161. package/src/utils/permissions-shorthand.test.ts +0 -79
  162. package/src/utils/permissions.test.ts +0 -125
  163. package/src/utils/permissions.ts +0 -129
  164. package/src/utils/post-process.test.ts +0 -1094
  165. package/src/utils/post-process.ts +0 -1604
  166. package/src/utils/resolve-addon-package.ts +0 -106
  167. package/src/utils/resolve-core-type.test.ts +0 -142
  168. package/src/utils/resolve-core-type.ts +0 -35
  169. package/src/utils/resolve-deploy-target.test.ts +0 -135
  170. package/src/utils/resolve-deploy-target.ts +0 -65
  171. package/src/utils/resolve-function-meta.ts +0 -25
  172. package/src/utils/resolve-function-types.ts +0 -42
  173. package/src/utils/resolve-identifier.ts +0 -46
  174. package/src/utils/resolve-ref-contract.ts +0 -71
  175. package/src/utils/resolve-versions.test.ts +0 -499
  176. package/src/utils/resolve-versions.ts +0 -228
  177. package/src/utils/schema-cache.test.ts +0 -124
  178. package/src/utils/schema-generator.test.ts +0 -272
  179. package/src/utils/schema-generator.ts +0 -780
  180. package/src/utils/secret-alias-services.test.ts +0 -146
  181. package/src/utils/secret-alias-services.ts +0 -58
  182. package/src/utils/serialize-inspector-state.ts +0 -742
  183. package/src/utils/serialize-mcp-json.ts +0 -150
  184. package/src/utils/serialize-middleware-groups-meta.ts +0 -36
  185. package/src/utils/serialize-openapi-json.ts +0 -277
  186. package/src/utils/serialize-permissions-groups-meta.ts +0 -7
  187. package/src/utils/single-declaration.ts +0 -57
  188. package/src/utils/type-utils.ts +0 -145
  189. package/src/utils/validate-auth-sessionless.ts +0 -30
  190. package/src/utils/validate-exposed-functions-gated.test.ts +0 -230
  191. package/src/utils/validate-exposed-functions-gated.ts +0 -103
  192. package/src/utils/validate-tags-resolve-to-middleware.test.ts +0 -108
  193. package/src/utils/validate-tags-resolve-to-middleware.ts +0 -48
  194. package/src/utils/workflow/derive-workflow-plan.test.ts +0 -178
  195. package/src/utils/workflow/derive-workflow-plan.ts +0 -117
  196. package/src/utils/workflow/dsl/deserialize-dsl-workflow.ts +0 -1465
  197. package/src/utils/workflow/dsl/deserialize-fanout-body.test.ts +0 -71
  198. package/src/utils/workflow/dsl/deserialize-fanout-fidelity.test.ts +0 -99
  199. package/src/utils/workflow/dsl/deserialize-graph-next.test.ts +0 -161
  200. package/src/utils/workflow/dsl/deserialize-roundtrip-bindings.test.ts +0 -121
  201. package/src/utils/workflow/dsl/deserialize-roundtrip-values.test.ts +0 -116
  202. package/src/utils/workflow/dsl/deserialize-roundtrip.test.ts +0 -145
  203. package/src/utils/workflow/dsl/extract-approval-policy.test.ts +0 -71
  204. package/src/utils/workflow/dsl/extract-dsl-workflow.ts +0 -2254
  205. package/src/utils/workflow/dsl/index.ts +0 -11
  206. package/src/utils/workflow/dsl/patterns.ts +0 -440
  207. package/src/utils/workflow/dsl/validation.ts +0 -203
  208. package/src/utils/workflow/graph/convert-dsl-to-graph-skip.test.ts +0 -35
  209. package/src/utils/workflow/graph/convert-dsl-to-graph.ts +0 -543
  210. package/src/utils/workflow/graph/fanout-node-identity.test.ts +0 -105
  211. package/src/utils/workflow/graph/finalize-workflow-wires.ts +0 -310
  212. package/src/utils/workflow/graph/finalize-workflows.test.ts +0 -50
  213. package/src/utils/workflow/graph/finalize-workflows.ts +0 -130
  214. package/src/utils/workflow/graph/index.ts +0 -28
  215. package/src/utils/workflow/graph/serialize-workflow-graph.ts +0 -240
  216. package/src/utils/workflow/graph/workflow-graph.types.ts +0 -281
  217. package/src/visit.ts +0 -181
  218. package/tsconfig.json +0 -19
  219. package/tsconfig.tsbuildinfo +0 -1
@@ -1,102 +0,0 @@
1
- import { strict as assert } from 'assert'
2
- import { describe, test } from 'node:test'
3
- import { mkdtemp, rm, writeFile } from 'node:fs/promises'
4
- import { tmpdir } from 'node:os'
5
- import { join } from 'node:path'
6
- import { inspect } from '../inspector.js'
7
- import type { InspectorLogger } from '../types.js'
8
- import { ErrorCode } from '../error-codes.js'
9
-
10
- function makeLogger(
11
- criticals: Array<{ code: string; message: string }>
12
- ): InspectorLogger {
13
- return {
14
- debug: () => {},
15
- info: () => {},
16
- warn: () => {},
17
- error: () => {},
18
- diagnostic: () => {},
19
- critical: (code, message) => criticals.push({ code, message }),
20
- hasCriticalErrors: () => criticals.length > 0,
21
- }
22
- }
23
-
24
- describe('validateWorkflowGraphAddons', () => {
25
- test('a graph node referencing graph: without @pikku/addon-graph wired raises PKU642', async () => {
26
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-graph-addon-'))
27
- const stepFile = join(rootDir, 'my.steps.ts')
28
- const graphFile = join(rootDir, 'my.graph.ts')
29
-
30
- await writeFile(
31
- stepFile,
32
- [
33
- "import { pikkuSessionlessFunc } from '@pikku/core'",
34
- 'export const notify = pikkuSessionlessFunc({ func: async () => ({ sent: true }) })',
35
- ].join('\n')
36
- )
37
- await writeFile(
38
- graphFile,
39
- [
40
- "import { pikkuWorkflowGraph } from '@pikku/core/workflow'",
41
- 'export const myGraph = pikkuWorkflowGraph({',
42
- " name: 'my-graph',",
43
- ' nodes: {',
44
- " setFields: 'graph:editFields',",
45
- " notify: 'notify',",
46
- ' },',
47
- " config: { setFields: { next: 'notify' }, notify: {} },",
48
- '})',
49
- ].join('\n')
50
- )
51
-
52
- try {
53
- const criticals: Array<{ code: string; message: string }> = []
54
- await inspect(makeLogger(criticals), [stepFile, graphFile], { rootDir })
55
- const hit = criticals.find(
56
- (c) => c.code === ErrorCode.WORKFLOW_GRAPH_ADDON_NOT_WIRED
57
- )
58
- assert.ok(hit, 'expected a WORKFLOW_GRAPH_ADDON_NOT_WIRED critical')
59
- assert.match(hit!.message, /@pikku\/addon-graph is not wired/)
60
- assert.match(hit!.message, /scaffold/)
61
- } finally {
62
- await rm(rootDir, { recursive: true, force: true })
63
- }
64
- })
65
-
66
- test('a graph with only user RPCs raises no addon-graph critical', async () => {
67
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-graph-addon-ok-'))
68
- const stepFile = join(rootDir, 'my.steps.ts')
69
- const graphFile = join(rootDir, 'my.graph.ts')
70
-
71
- await writeFile(
72
- stepFile,
73
- [
74
- "import { pikkuSessionlessFunc } from '@pikku/core'",
75
- 'export const assess = pikkuSessionlessFunc({ func: async () => ({ ok: true }) })',
76
- 'export const notify = pikkuSessionlessFunc({ func: async () => ({ sent: true }) })',
77
- ].join('\n')
78
- )
79
- await writeFile(
80
- graphFile,
81
- [
82
- "import { pikkuWorkflowGraph } from '@pikku/core/workflow'",
83
- 'export const myGraph = pikkuWorkflowGraph({',
84
- " name: 'my-graph',",
85
- " nodes: { assess: 'assess', notify: 'notify' },",
86
- " config: { assess: { next: 'notify' }, notify: {} },",
87
- '})',
88
- ].join('\n')
89
- )
90
-
91
- try {
92
- const criticals: Array<{ code: string; message: string }> = []
93
- await inspect(makeLogger(criticals), [stepFile, graphFile], { rootDir })
94
- const hit = criticals.find(
95
- (c) => c.code === ErrorCode.WORKFLOW_GRAPH_ADDON_NOT_WIRED
96
- )
97
- assert.equal(hit, undefined, 'no addon-graph critical expected')
98
- } finally {
99
- await rm(rootDir, { recursive: true, force: true })
100
- }
101
- })
102
- })
@@ -1,117 +0,0 @@
1
- import { strict as assert } from 'assert'
2
- import { describe, test } from 'node:test'
3
- import { mkdtemp, rm, writeFile } from 'node:fs/promises'
4
- import { tmpdir } from 'node:os'
5
- import { join } from 'node:path'
6
- import { inspect } from '../inspector.js'
7
- import { ErrorCode } from '../error-codes.js'
8
- import type { InspectorLogger } from '../types.js'
9
-
10
- const makeLogger = (criticals: Array<{ code: ErrorCode; message: string }>) =>
11
- ({
12
- debug: () => {},
13
- info: () => {},
14
- warn: () => {},
15
- error: () => {},
16
- diagnostic: ({ code, message }) => {
17
- criticals.push({ code, message })
18
- },
19
- critical: (code: ErrorCode, message: string) => {
20
- criticals.push({ code, message })
21
- },
22
- hasCriticalErrors: () => criticals.length > 0,
23
- }) satisfies InspectorLogger
24
-
25
- describe('wiring name must be a string literal', () => {
26
- test('logs a critical error when a queue worker name is a const reference', async () => {
27
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-nonliteral-name-'))
28
- const file = join(rootDir, 'queue.ts')
29
-
30
- await writeFile(
31
- file,
32
- [
33
- "import { pikkuSessionlessFunc, wireQueueWorker } from '@pikku/core'",
34
- 'const QUEUE_NAME = "stripe-webhook-event"',
35
- 'export const handler = pikkuSessionlessFunc({',
36
- ' func: async () => ({ ok: true })',
37
- '})',
38
- 'wireQueueWorker({',
39
- ' name: QUEUE_NAME,',
40
- ' func: handler,',
41
- '})',
42
- ].join('\n')
43
- )
44
-
45
- const criticals: Array<{ code: ErrorCode; message: string }> = []
46
- try {
47
- await inspect(makeLogger(criticals), [file], { rootDir })
48
- const hit = criticals.find(
49
- (entry) => entry.code === ErrorCode.NON_LITERAL_WIRE_NAME
50
- )
51
- assert.ok(hit, 'expected NON_LITERAL_WIRE_NAME critical')
52
- assert.match(hit!.message, /QUEUE_NAME/)
53
- } finally {
54
- await rm(rootDir, { recursive: true, force: true })
55
- }
56
- })
57
-
58
- test('logs a critical error when a secret id is a const reference', async () => {
59
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-nonliteral-secret-'))
60
- const file = join(rootDir, 'secret.ts')
61
-
62
- await writeFile(
63
- file,
64
- [
65
- "import { defineSecret } from '@pikku/core'",
66
- 'const SECRET_ID = "STRIPE_SECRET_KEY"',
67
- 'defineSecret({',
68
- ' secretId: SECRET_ID,',
69
- " name: 'Stripe secret key',",
70
- " displayName: 'Stripe secret key',",
71
- '})',
72
- ].join('\n')
73
- )
74
-
75
- const criticals: Array<{ code: ErrorCode; message: string }> = []
76
- try {
77
- await inspect(makeLogger(criticals), [file], { rootDir })
78
- const hit = criticals.find(
79
- (entry) => entry.code === ErrorCode.NON_LITERAL_WIRE_NAME
80
- )
81
- assert.ok(hit, 'expected NON_LITERAL_WIRE_NAME critical')
82
- assert.match(hit!.message, /SECRET_ID/)
83
- } finally {
84
- await rm(rootDir, { recursive: true, force: true })
85
- }
86
- })
87
-
88
- test('does not flag a queue worker whose name is an inline literal', async () => {
89
- const rootDir = await mkdtemp(join(tmpdir(), 'pikku-literal-name-'))
90
- const file = join(rootDir, 'queue.ts')
91
-
92
- await writeFile(
93
- file,
94
- [
95
- "import { pikkuSessionlessFunc, wireQueueWorker } from '@pikku/core'",
96
- 'export const handler = pikkuSessionlessFunc({',
97
- ' func: async () => ({ ok: true })',
98
- '})',
99
- 'wireQueueWorker({',
100
- " name: 'stripe-webhook-event',",
101
- ' func: handler,',
102
- '})',
103
- ].join('\n')
104
- )
105
-
106
- const criticals: Array<{ code: ErrorCode; message: string }> = []
107
- try {
108
- await inspect(makeLogger(criticals), [file], { rootDir })
109
- const hit = criticals.find(
110
- (entry) => entry.code === ErrorCode.NON_LITERAL_WIRE_NAME
111
- )
112
- assert.equal(hit, undefined)
113
- } finally {
114
- await rm(rootDir, { recursive: true, force: true })
115
- }
116
- })
117
- })
@@ -1,76 +0,0 @@
1
- import { test } from 'node:test'
2
- import { strict as assert } from 'node:assert'
3
- import { readFileSync, readdirSync } from 'node:fs'
4
- import { fileURLToPath } from 'node:url'
5
- import { dirname, join } from 'node:path'
6
-
7
- /**
8
- * Guards against dead `ErrorCode` registry entries.
9
- *
10
- * Every value in the `ErrorCode` enum must have at least one emission site in
11
- * the framework source — a `ErrorCode.<NAME>` reference or the raw `PKU###`
12
- * string in a non-test `.ts` file under `packages/*​/src`. A code that is
13
- * defined but never thrown is a dead entry: it can never appear in a user's
14
- * terminal, yet it still demands a docs page and clutters the registry. This
15
- * test fails and names any such entries so they get wired up or removed rather
16
- * than silently accumulating.
17
- */
18
-
19
- const here = dirname(fileURLToPath(import.meta.url))
20
- const packagesDir = join(here, '..', '..')
21
- const errorCodesFile = join(here, 'error-codes.ts')
22
-
23
- const enumMembers = [
24
- ...readFileSync(errorCodesFile, 'utf8').matchAll(
25
- /^\s*([A-Z0-9_]+)\s*=\s*'(PKU\d+)'/gm
26
- ),
27
- ].map((m) => ({ name: m[1], code: m[2] }))
28
-
29
- const collectSource = () => {
30
- const contents: string[] = []
31
- for (const pkg of readdirSync(packagesDir, { withFileTypes: true })) {
32
- if (!pkg.isDirectory()) continue
33
- const srcDir = join(packagesDir, pkg.name, 'src')
34
- let entries
35
- try {
36
- entries = readdirSync(srcDir, { recursive: true, withFileTypes: true })
37
- } catch {
38
- continue
39
- }
40
- for (const entry of entries) {
41
- if (!entry.isFile()) continue
42
- const name = entry.name
43
- if (
44
- !name.endsWith('.ts') ||
45
- name.endsWith('.d.ts') ||
46
- name.endsWith('.test.ts') ||
47
- name === 'error-codes.ts'
48
- ) {
49
- continue
50
- }
51
- contents.push(readFileSync(join(entry.parentPath, name), 'utf8'))
52
- }
53
- }
54
- return contents.join('\n')
55
- }
56
-
57
- test('every ErrorCode value has an emission site in the source', () => {
58
- assert.ok(
59
- enumMembers.length > 0,
60
- 'Failed to parse any ErrorCode members from error-codes.ts'
61
- )
62
-
63
- const source = collectSource()
64
-
65
- const dead = enumMembers.filter(
66
- ({ name, code }) =>
67
- !source.includes(`ErrorCode.${name}`) && !source.includes(code)
68
- )
69
-
70
- assert.deepEqual(
71
- dead.map(({ code, name }) => `${code} ${name}`),
72
- [],
73
- `Dead ErrorCode entries (defined but never emitted). Wire them to a diagnostic or delete them:\n` +
74
- dead.map(({ code, name }) => ` - ${code} ${name}`).join('\n')
75
- )
76
- })
@@ -1,145 +0,0 @@
1
- /**
2
- * Error code system for Pikku CLI and Inspector
3
- *
4
- * Each error has a unique code and links to documentation at pikku.dev
5
- *
6
- * Error codes use random 3-digit numbers to avoid implying a sequential order.
7
- * Each code links to detailed documentation and troubleshooting steps.
8
- */
9
-
10
- export enum ErrorCode {
11
- // Validation errors
12
- MISSING_NAME = 'PKU111',
13
- NON_LITERAL_WIRE_NAME = 'PKU118',
14
- MISSING_DESCRIPTION = 'PKU123',
15
- INVALID_VALUE = 'PKU124',
16
- MISSING_URI = 'PKU220',
17
- MISSING_FUNC = 'PKU236',
18
- INVALID_TAGS_TYPE = 'PKU247',
19
- MISSING_TITLE = 'PKU370',
20
- MISSING_QUEUE_NAME = 'PKU384',
21
- MISSING_CHANNEL_NAME = 'PKU400',
22
- CLI_CLIENTSIDE_RENDERER_HAS_SERVICES = 'PKU672',
23
- SCENARIO_HAS_SERVICES = 'PKU673',
24
- EXPECT_EVENTUALLY_SCENARIO_ONLY = 'PKU675',
25
- SCENARIO_STEP_NEEDS_ACTOR = 'PKU677',
26
- SCENARIO_STEP_TARGET_NOT_STATIC = 'PKU678',
27
- SCENARIO_NOT_EXTRACTABLE = 'PKU679',
28
- SCENARIO_HAS_NO_ASSERTION = 'PKU680',
29
- SCENARIO_STEP_PROSE_NAMES_ACTOR = 'PKU681',
30
- WORKFLOW_ORCHESTRATOR_NOT_CONFIGURED = 'PKU600',
31
- INVALID_DSL_WORKFLOW = 'PKU641',
32
- WORKFLOW_GRAPH_ADDON_NOT_WIRED = 'PKU642',
33
- COMPLEX_WORKFLOW_NOT_ALLOWED = 'PKU643',
34
-
35
- // Remote addon (wireRemoteAddon) validation
36
- REMOTE_ADDON_NOT_DEV_DEPENDENCY = 'PKU338',
37
- REMOTE_ADDON_AUTH_UNRESOLVED = 'PKU339',
38
- ADDON_NOT_INSTALLED = 'PKU340',
39
-
40
- // Database schema codegen warnings
41
- DB_COLUMN_NAME_TYPE_CONTRADICTION = 'PKU480',
42
- DB_JSON_COLUMN_UNTYPED = 'PKU481',
43
- DB_FORMAT_ON_NON_STRING = 'PKU482',
44
- DB_SECRET_COLUMN_STORED_PLAIN = 'PKU483',
45
- DB_FORM_ON_NON_STRING = 'PKU484',
46
- DB_DEFAULT_SCHEMA_NAME_COLLISION = 'PKU485',
47
-
48
- // Configuration errors
49
- SCHEMA_GENERATION_ERROR = 'PKU456',
50
- SCHEMA_REFERENCE_UNRESOLVED = 'PKU463',
51
- INLINE_SCHEMA = 'PKU489',
52
-
53
- // Function errors
54
- FUNCTION_METADATA_NOT_FOUND = 'PKU559',
55
-
56
- // Auth errors
57
- DUPLICATE_AUTH_DEFINITION = 'PKU581',
58
- AUTH_NOT_EXPORTED = 'PKU582',
59
-
60
- // Single-declaration constructs — one call site per codebase.
61
- // PKU583 (defineScope) and PKU584 (defineSystemRole) are retired, not free:
62
- // scopes and roles held this rule until the generated `admin` tree made it
63
- // unsatisfiable, and get it back once `admin` is a default scope nobody
64
- // declares. Do not reuse those two numbers for anything else.
65
- DUPLICATE_PERSONAS_DEFINITION = 'PKU585',
66
-
67
- // HTTP Route errors
68
- ROUTE_PARAM_MISMATCH = 'PKU571',
69
- ROUTE_QUERY_MISMATCH = 'PKU572',
70
- AUTH_DISABLED_REQUIRES_SESSIONLESS = 'PKU573',
71
- EXPOSED_FUNCTION_HAS_NO_GATE = 'PKU574',
72
- TAG_RESOLVES_TO_NO_MIDDLEWARE = 'PKU575',
73
- PERMISSIONS_IN_BODY_NOT_ALLOWED = 'PKU576',
74
-
75
- // Versioning errors
76
- DUPLICATE_FUNCTION_VERSION = 'PKU850',
77
- DUPLICATE_FUNCTION_NAME = 'PKU851',
78
-
79
- // Contract versioning errors
80
- MANIFEST_MISSING = 'PKU860',
81
- FUNCTION_VERSION_MODIFIED = 'PKU861',
82
- CONTRACT_CHANGED_REQUIRES_BUMP = 'PKU862',
83
- VERSION_REGRESSION_OR_CONFLICT = 'PKU863',
84
- VERSION_GAP_NOT_ALLOWED = 'PKU864',
85
- MANIFEST_INTEGRITY_ERROR = 'PKU865',
86
-
87
- // Model configuration errors
88
- MISSING_MODEL = 'PKU145',
89
- INVALID_MODEL = 'PKU146',
90
-
91
- // Agent tool reference errors
92
- AGENT_TOOL_UNKNOWN_NAMESPACE = 'PKU152',
93
- AGENT_TOOL_NOT_FOUND = 'PKU153',
94
- AGENT_TOOL_MISSING_DESCRIPTION = 'PKU154',
95
-
96
- // Agent scorer reference errors
97
- AGENT_SCORER_NOT_FOUND = 'PKU155',
98
-
99
- // File structure errors
100
- SCHEMA_AND_WIRING_COLOCATED = 'PKU490',
101
-
102
- // Schema authoring errors
103
- SCHEMA_TRANSFORM_NOT_SUPPORTED = 'PKU491',
104
-
105
- // Optimization diagnostics
106
- SERVICES_NOT_DESTRUCTURED = 'PKU410',
107
- WIRES_NOT_DESTRUCTURED = 'PKU411',
108
- FUNCTION_DYNAMIC_IMPORT = 'PKU498',
109
-
110
- // Dependency integrity errors
111
- DUPLICATE_CORE_VERSION = 'PKU717',
112
- CORE_VERSION_SKEW = 'PKU718',
113
- SPLIT_TYPE_IDENTITY = 'PKU719',
114
- SINGLETON_SERVICES_TYPE_UNRESOLVED = 'PKU724',
115
-
116
- // Data classification errors
117
- PII_IN_OUTPUT = 'PKU910',
118
-
119
- // Addon authoring errors
120
- ADDON_WIRING_NOT_ALLOWED = 'PKU920',
121
- ADDON_CONTRACT_HANDLERS_NOT_ALLOWED = 'PKU921',
122
-
123
- RPC_INVOCATION_TYPE_CAST = 'PKU940',
124
-
125
- // Secret boundary errors
126
- SECRET_SERVICE_ALIASED = 'PKU950',
127
- SECRET_NOT_DECLARED = 'PKU951',
128
- SECRET_KEY_NOT_STATIC = 'PKU952',
129
- SECRET_REVEALED_INTO_SINK = 'PKU953',
130
- PII_INTO_SINK = 'PKU954',
131
- }
132
-
133
- /**
134
- * Severity of a tracked, coded diagnostic. `critical` always blocks the build;
135
- * `error`/`warn` only block when the CLI is told to via `--fail-on-error` /
136
- * `--fail-on-warn` (default: critical only). All severities are still printed.
137
- */
138
- export type DiagnosticSeverity = 'warn' | 'error' | 'critical'
139
-
140
- /** A coded diagnostic emitted via `logger.diagnostic(...)`. */
141
- export interface CodedDiagnostic {
142
- severity: DiagnosticSeverity
143
- code: ErrorCode
144
- message: string
145
- }
package/src/index.ts DELETED
@@ -1,66 +0,0 @@
1
- export { inspect, getInitialInspectorState } from './inspector.js'
2
- export type { TypesMap } from './types-map.js'
3
- export type {
4
- AddonConfig,
5
- AuthDefinition,
6
- InspectorDiagnostic,
7
- InspectorFilters,
8
- InspectorHTTPState,
9
- InspectorLogger,
10
- InspectorMiddlewareState,
11
- InspectorOptions,
12
- InspectorPermissionState,
13
- InspectorState,
14
- MetaInputTypes,
15
- MiddlewareGroupMeta,
16
- MiddlewareRegistration,
17
- SchemaRef,
18
- } from './types.js'
19
- export type { FilesAndMethodsErrors } from './utils/get-files-and-methods.js'
20
- export { ErrorCode } from './error-codes.js'
21
- export type { DiagnosticSeverity, CodedDiagnostic } from './error-codes.js'
22
- export { AUTH_HANDLER_FUNC_ID } from './add/add-auth.js'
23
- export {
24
- SCENARIO_INSTRUMENTATION_FUNCTIONS,
25
- isScenarioInstrumentationFunction,
26
- } from './add/scenario-instrumentation.js'
27
- export type { ScenarioInstrumentationFunction } from './add/scenario-instrumentation.js'
28
- export {
29
- serializeInspectorState,
30
- deserializeInspectorState,
31
- } from './utils/serialize-inspector-state.js'
32
- export type { SerializableInspectorState } from './utils/serialize-inspector-state.js'
33
- export { filterInspectorState } from './utils/filter-inspector-state.js'
34
- export { resolveDeployTarget } from './utils/resolve-deploy-target.js'
35
- export {
36
- generateCustomTypes,
37
- sanitizeTypeName,
38
- } from './utils/custom-types-generator.js'
39
- export { unresolvedSchemaReferences } from './utils/post-process.js'
40
- export type { SurfaceUsageCounts } from './utils/extract-surface-usage.js'
41
- export {
42
- createEmptyManifest,
43
- serializeManifest,
44
- } from './utils/contract-hashes.js'
45
- export type {
46
- ContractEntry,
47
- VersionHashEntry,
48
- VersionValidateError,
49
- VersionManifest,
50
- VersionManifestEntry,
51
- } from './utils/contract-hashes.js'
52
- export type { InspectorFeature, InspectorFeatureEntry } from './types.js'
53
- export { serializeMCPJson } from './utils/serialize-mcp-json.js'
54
- export type { OpenAPISpecInfo } from './utils/serialize-openapi-json.js'
55
- export {
56
- deserializeDslWorkflow,
57
- deserializeGraphWorkflow,
58
- deserializeAllDslWorkflows,
59
- } from './utils/workflow/dsl/index.js'
60
- export { getFilesAndMethods } from './utils/get-files-and-methods.js'
61
- export { resolveFunctionMeta } from './utils/resolve-function-meta.js'
62
- export type {
63
- SerializedWorkflowGraph,
64
- SerializedWorkflowGraphs,
65
- } from './utils/workflow/graph/index.js'
66
- export { resolveCoreType } from './utils/resolve-core-type.js'