norn-cli 2.3.0 → 2.4.0

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 (92) hide show
  1. package/.claude/skills/norn-social-campaign/SKILL.md +70 -0
  2. package/CHANGELOG.md +6 -0
  3. package/demos/nornenv-region-refactor/README.md +64 -0
  4. package/dist/cli.js +360 -1
  5. package/out/apiResponseIntellisenseCache.js +394 -0
  6. package/out/assertionRunner.js +567 -0
  7. package/out/cacheDir.js +136 -0
  8. package/out/chatParticipant.js +763 -0
  9. package/out/cli/colors.js +127 -0
  10. package/out/cli/formatters/assertion.js +102 -0
  11. package/out/cli/formatters/index.js +23 -0
  12. package/out/cli/formatters/response.js +106 -0
  13. package/out/cli/formatters/summary.js +246 -0
  14. package/out/cli/redaction.js +237 -0
  15. package/out/cli/reporters/html.js +689 -0
  16. package/out/cli/reporters/index.js +22 -0
  17. package/out/cli/reporters/junit.js +226 -0
  18. package/out/codeLensProvider.js +351 -0
  19. package/out/compareContentProvider.js +85 -0
  20. package/out/completionProvider.js +3739 -0
  21. package/out/contractAssertionSummary.js +225 -0
  22. package/out/contractDecorationProvider.js +243 -0
  23. package/out/coverageCalculator.js +879 -0
  24. package/out/coveragePanel.js +597 -0
  25. package/out/debug/breakpointResolver.js +84 -0
  26. package/out/debug/breakpoints.js +52 -0
  27. package/out/debug/nornDebugAdapter.js +166 -0
  28. package/out/debug/nornDebugSession.js +613 -0
  29. package/out/debug/sequenceLocationIndex.js +77 -0
  30. package/out/debug/types.js +3 -0
  31. package/out/deepClone.js +21 -0
  32. package/out/diagnosticProvider.js +2554 -0
  33. package/out/environmentParser.js +736 -0
  34. package/out/environmentProvider.js +544 -0
  35. package/out/environmentTemplates.js +146 -0
  36. package/out/errors/formatError.js +113 -0
  37. package/out/errors/nornError.js +29 -0
  38. package/out/formUrlEncoded.js +89 -0
  39. package/out/httpClient.js +348 -0
  40. package/out/httpRuntimeOptions.js +16 -0
  41. package/out/importErrors.js +31 -0
  42. package/out/inlayHintResolver.js +70 -0
  43. package/out/jsonFileReader.js +323 -0
  44. package/out/mcpClient.js +193 -0
  45. package/out/mcpConfig.js +184 -0
  46. package/out/mcpToolIntellisenseCache.js +96 -0
  47. package/out/mcpToolSchema.js +50 -0
  48. package/out/nornConfig.js +132 -0
  49. package/out/nornHoverProvider.js +124 -0
  50. package/out/nornInlayHintsProvider.js +191 -0
  51. package/out/nornPrompt.js +755 -0
  52. package/out/nornSqlParser.js +286 -0
  53. package/out/nornapiHoverProvider.js +135 -0
  54. package/out/nornapiInlayHintsProvider.js +94 -0
  55. package/out/nornapiParser.js +324 -0
  56. package/out/nornenvCodeActionProvider.js +101 -0
  57. package/out/nornenvDecorationProvider.js +239 -0
  58. package/out/nornenvFoldingProvider.js +63 -0
  59. package/out/nornenvHoverProvider.js +114 -0
  60. package/out/nornenvInlayHintsProvider.js +99 -0
  61. package/out/nornenvLanguageModel.js +187 -0
  62. package/out/nornenvRegionRefactor.js +267 -0
  63. package/out/nornsqlHoverProvider.js +95 -0
  64. package/out/nornsqlInlayHintsProvider.js +114 -0
  65. package/out/parser.js +839 -0
  66. package/out/pathAccess.js +28 -0
  67. package/out/postmanImportPanel.js +732 -0
  68. package/out/postmanImportPlanner.js +1155 -0
  69. package/out/postmanImportSidebarView.js +532 -0
  70. package/out/quotedString.js +35 -0
  71. package/out/requestPreparation.js +179 -0
  72. package/out/requestValidation.js +146 -0
  73. package/out/responsePanel.js +7754 -0
  74. package/out/schemaGenerator.js +562 -0
  75. package/out/scriptRunner.js +419 -0
  76. package/out/secrets/cliSecrets.js +415 -0
  77. package/out/secrets/crypto.js +105 -0
  78. package/out/secrets/envFileSecrets.js +177 -0
  79. package/out/secrets/keyStore.js +259 -0
  80. package/out/sequenceDeclaration.js +15 -0
  81. package/out/sequenceRunner.js +3590 -0
  82. package/out/sqlAdapterRunner.js +122 -0
  83. package/out/sqlBuiltInAdapters.js +604 -0
  84. package/out/sqlConfig.js +184 -0
  85. package/out/starterCatalog.js +554 -0
  86. package/out/stringUtils.js +25 -0
  87. package/out/swaggerBodyIntellisenseCache.js +114 -0
  88. package/out/swaggerParser.js +464 -0
  89. package/out/testProvider.js +767 -0
  90. package/out/theoryCaseLoader.js +113 -0
  91. package/out/validationCache.js +211 -0
  92. package/package.json +6 -1
@@ -0,0 +1,613 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.NornDebugSession = void 0;
37
+ const fs = __importStar(require("fs/promises"));
38
+ const path = __importStar(require("path"));
39
+ const parser_1 = require("../parser");
40
+ const sequenceRunner_1 = require("../sequenceRunner");
41
+ const responsePanel_1 = require("../responsePanel");
42
+ const environmentProvider_1 = require("../environmentProvider");
43
+ const formatError_1 = require("../errors/formatError");
44
+ const importErrors_1 = require("../importErrors");
45
+ const breakpointResolver_1 = require("./breakpointResolver");
46
+ const sequenceLocationIndex_1 = require("./sequenceLocationIndex");
47
+ const THREAD_ID = 1;
48
+ function isObjectLike(value) {
49
+ return typeof value === 'object' && value !== null;
50
+ }
51
+ function formatVariableValue(value) {
52
+ if (value === null) {
53
+ return 'null';
54
+ }
55
+ if (value === undefined) {
56
+ return 'undefined';
57
+ }
58
+ if (typeof value === 'string') {
59
+ return value;
60
+ }
61
+ if (typeof value === 'number' || typeof value === 'boolean') {
62
+ return String(value);
63
+ }
64
+ if (Array.isArray(value)) {
65
+ return `Array(${value.length})`;
66
+ }
67
+ return 'Object';
68
+ }
69
+ class NornDebugSession {
70
+ send;
71
+ extensionUri;
72
+ outgoingSeq = 1;
73
+ launchConfig;
74
+ configurationDone = false;
75
+ launchStarted = false;
76
+ terminated = false;
77
+ breakpointsByFile = new Map();
78
+ continueMode = 'continue';
79
+ stepDepthTarget = 0;
80
+ pauseRequested = false;
81
+ waitForResume;
82
+ resumeResolver;
83
+ stopOnEntryConsumed = false;
84
+ frames = [];
85
+ nextFrameId = 1;
86
+ pausedState;
87
+ lastStepEvent;
88
+ failurePauseHandled = false;
89
+ runtimeVariables = {};
90
+ responses = [];
91
+ variableHandles = new Map();
92
+ nextVariableHandle = 1;
93
+ constructor(extensionUri, send) {
94
+ this.extensionUri = extensionUri;
95
+ this.send = send;
96
+ }
97
+ async handleRequest(request) {
98
+ try {
99
+ switch (request.command) {
100
+ case 'initialize':
101
+ this.handleInitialize(request);
102
+ return;
103
+ case 'launch':
104
+ this.handleLaunch(request);
105
+ return;
106
+ case 'setBreakpoints':
107
+ await this.handleSetBreakpoints(request);
108
+ return;
109
+ case 'configurationDone':
110
+ this.handleConfigurationDone(request);
111
+ return;
112
+ case 'threads':
113
+ this.handleThreads(request);
114
+ return;
115
+ case 'stackTrace':
116
+ this.handleStackTrace(request);
117
+ return;
118
+ case 'scopes':
119
+ this.handleScopes(request);
120
+ return;
121
+ case 'variables':
122
+ this.handleVariables(request);
123
+ return;
124
+ case 'continue':
125
+ this.handleContinue(request);
126
+ return;
127
+ case 'next':
128
+ this.handleNext(request);
129
+ return;
130
+ case 'stepIn':
131
+ this.handleStepIn(request);
132
+ return;
133
+ case 'stepOut':
134
+ this.handleStepOut(request);
135
+ return;
136
+ case 'pause':
137
+ this.handlePause(request);
138
+ return;
139
+ case 'disconnect':
140
+ case 'terminate':
141
+ this.handleDisconnect(request);
142
+ return;
143
+ default:
144
+ this.sendErrorResponse(request, `Unsupported command: ${request.command}`);
145
+ }
146
+ }
147
+ catch (error) {
148
+ const message = error instanceof Error ? error.message : String(error);
149
+ this.sendErrorResponse(request, message);
150
+ }
151
+ }
152
+ handleInitialize(request) {
153
+ this.sendResponse(request, {
154
+ supportsConfigurationDoneRequest: true,
155
+ supportsTerminateRequest: true,
156
+ supportsConditionalBreakpoints: false,
157
+ supportsHitConditionalBreakpoints: false,
158
+ supportsLogPoints: false
159
+ });
160
+ this.sendEvent('initialized');
161
+ }
162
+ handleLaunch(request) {
163
+ const config = request.arguments;
164
+ if (!config || !config.file || !config.sequence) {
165
+ this.sendErrorResponse(request, 'Launch requires file and sequence');
166
+ return;
167
+ }
168
+ this.launchConfig = {
169
+ ...config,
170
+ file: path.resolve(config.file),
171
+ stopOnEntry: config.stopOnEntry ?? true
172
+ };
173
+ this.sendResponse(request);
174
+ if (this.configurationDone && !this.launchStarted) {
175
+ this.startLaunch();
176
+ }
177
+ }
178
+ async handleSetBreakpoints(request) {
179
+ const args = request.arguments || {};
180
+ const sourcePath = typeof args?.source?.path === 'string' ? path.resolve(args.source.path) : undefined;
181
+ if (!sourcePath) {
182
+ this.sendResponse(request, { breakpoints: [] });
183
+ return;
184
+ }
185
+ const requestedLines = Array.isArray(args.lines)
186
+ ? args.lines
187
+ : Array.isArray(args.breakpoints)
188
+ ? args.breakpoints.map((bp) => bp?.line).filter((line) => typeof line === 'number')
189
+ : [];
190
+ const resolved = await (0, breakpointResolver_1.resolveBreakpointsForFile)(sourcePath, requestedLines);
191
+ const verified = new Set();
192
+ for (const item of resolved) {
193
+ if (item.verified) {
194
+ verified.add(item.line);
195
+ }
196
+ }
197
+ this.breakpointsByFile.set(sourcePath, verified);
198
+ this.sendResponse(request, {
199
+ breakpoints: resolved.map(item => ({
200
+ verified: item.verified,
201
+ line: item.line,
202
+ message: item.message
203
+ }))
204
+ });
205
+ }
206
+ handleConfigurationDone(request) {
207
+ this.configurationDone = true;
208
+ this.sendResponse(request);
209
+ if (this.launchConfig && !this.launchStarted) {
210
+ this.startLaunch();
211
+ }
212
+ }
213
+ handleThreads(request) {
214
+ this.sendResponse(request, {
215
+ threads: [{ id: THREAD_ID, name: 'Norn' }]
216
+ });
217
+ }
218
+ handleStackTrace(request) {
219
+ const ordered = [...this.frames].sort((a, b) => b.nestingDepth - a.nestingDepth);
220
+ const stackFrames = ordered.map(frame => {
221
+ const lineZero = frame.currentLine ?? frame.declarationLine ?? 0;
222
+ const sourcePath = frame.filePath;
223
+ return {
224
+ id: frame.id,
225
+ name: frame.sequenceName,
226
+ source: sourcePath
227
+ ? { name: path.basename(sourcePath), path: sourcePath }
228
+ : undefined,
229
+ line: lineZero + 1,
230
+ column: 1
231
+ };
232
+ });
233
+ this.sendResponse(request, {
234
+ stackFrames,
235
+ totalFrames: stackFrames.length
236
+ });
237
+ }
238
+ handleScopes(request) {
239
+ const runtimeRef = this.createVariableReference(this.runtimeVariables);
240
+ const responsesObject = {};
241
+ this.responses.forEach((resp, idx) => {
242
+ responsesObject[`$${idx + 1}`] = resp;
243
+ });
244
+ const responsesRef = this.createVariableReference(responsesObject);
245
+ this.sendResponse(request, {
246
+ scopes: [
247
+ {
248
+ name: 'Runtime Variables',
249
+ variablesReference: runtimeRef,
250
+ expensive: false
251
+ },
252
+ {
253
+ name: 'Responses',
254
+ variablesReference: responsesRef,
255
+ expensive: false
256
+ }
257
+ ]
258
+ });
259
+ }
260
+ handleVariables(request) {
261
+ const args = request.arguments || {};
262
+ const handle = typeof args.variablesReference === 'number' ? args.variablesReference : 0;
263
+ const value = this.variableHandles.get(handle);
264
+ if (value === undefined) {
265
+ this.sendResponse(request, { variables: [] });
266
+ return;
267
+ }
268
+ const variables = [];
269
+ if (Array.isArray(value)) {
270
+ value.forEach((item, idx) => {
271
+ variables.push({
272
+ name: String(idx),
273
+ value: formatVariableValue(item),
274
+ variablesReference: this.createVariableReference(item),
275
+ type: Array.isArray(item) ? 'array' : typeof item
276
+ });
277
+ });
278
+ }
279
+ else if (isObjectLike(value)) {
280
+ for (const [key, item] of Object.entries(value)) {
281
+ variables.push({
282
+ name: key,
283
+ value: formatVariableValue(item),
284
+ variablesReference: this.createVariableReference(item),
285
+ type: Array.isArray(item) ? 'array' : typeof item
286
+ });
287
+ }
288
+ }
289
+ this.sendResponse(request, { variables });
290
+ }
291
+ handleContinue(request) {
292
+ this.continueMode = 'continue';
293
+ this.resumeExecution();
294
+ this.sendResponse(request, { allThreadsContinued: true });
295
+ }
296
+ handleNext(request) {
297
+ this.continueMode = 'next';
298
+ this.stepDepthTarget = Math.max(1, this.frames.length);
299
+ this.resumeExecution();
300
+ this.sendResponse(request);
301
+ }
302
+ handleStepIn(request) {
303
+ this.continueMode = 'stepIn';
304
+ this.resumeExecution();
305
+ this.sendResponse(request);
306
+ }
307
+ handleStepOut(request) {
308
+ this.continueMode = 'stepOut';
309
+ this.stepDepthTarget = Math.max(0, this.frames.length - 1);
310
+ this.resumeExecution();
311
+ this.sendResponse(request);
312
+ }
313
+ handlePause(request) {
314
+ this.pauseRequested = true;
315
+ this.sendResponse(request);
316
+ }
317
+ handleDisconnect(request) {
318
+ this.terminated = true;
319
+ this.resumeExecution();
320
+ this.sendResponse(request);
321
+ this.sendEvent('terminated');
322
+ }
323
+ createVariableReference(value) {
324
+ if (!isObjectLike(value) && !Array.isArray(value)) {
325
+ return 0;
326
+ }
327
+ const handle = this.nextVariableHandle++;
328
+ this.variableHandles.set(handle, value);
329
+ return handle;
330
+ }
331
+ resetVariableHandles() {
332
+ this.variableHandles.clear();
333
+ this.nextVariableHandle = 1;
334
+ }
335
+ startLaunch() {
336
+ if (this.launchStarted) {
337
+ return;
338
+ }
339
+ this.launchStarted = true;
340
+ void this.runLaunch();
341
+ }
342
+ async runLaunch() {
343
+ if (!this.launchConfig) {
344
+ return;
345
+ }
346
+ this.sendEvent('thread', { reason: 'started', threadId: THREAD_ID });
347
+ const config = this.launchConfig;
348
+ const previousEnv = (0, environmentProvider_1.getActiveEnvironment)(config.file);
349
+ try {
350
+ await this.validateEnvironmentSelection(config.file, config.env);
351
+ if (config.env) {
352
+ (0, environmentProvider_1.setActiveEnvironment)(config.env, config.file);
353
+ }
354
+ await this.ensureEnvironmentReady(config.file);
355
+ const fileContent = await fs.readFile(config.file, 'utf-8');
356
+ const importResult = await (0, parser_1.resolveImports)(fileContent, path.dirname(config.file), async (importPath) => fs.readFile(importPath, 'utf-8'), undefined, undefined, config.file);
357
+ const duplicateErrors = (0, importErrors_1.getBlockingImportErrors)(importResult.errors);
358
+ if (duplicateErrors.length > 0) {
359
+ throw new Error(`Cannot debug sequence due to blocking import errors: ${duplicateErrors[0].error}`);
360
+ }
361
+ const fullTextWithImports = importResult.importedContent
362
+ ? `${importResult.importedContent}\n\n${fileContent}`
363
+ : fileContent;
364
+ const sequence = (0, sequenceRunner_1.extractSequences)(fullTextWithImports).find(seq => seq.name === config.sequence);
365
+ if (!sequence) {
366
+ throw new Error(`Sequence '${config.sequence}' not found`);
367
+ }
368
+ const locationIndex = await (0, sequenceLocationIndex_1.buildSequenceLocationIndex)(config.file, importResult.sequenceSources);
369
+ const location = locationIndex.get(sequence.name.toLowerCase());
370
+ const envVars = (0, environmentProvider_1.getEnvironmentVariables)(config.file);
371
+ const fileVariables = (0, parser_1.extractFileLevelVariables)(fileContent);
372
+ const allVariables = (0, parser_1.attachEnvironmentScope)({ ...envVars, ...fileVariables }, envVars);
373
+ const defaultArgs = {};
374
+ if (sequence.parameters) {
375
+ for (const param of sequence.parameters) {
376
+ if (param.defaultValue !== undefined) {
377
+ defaultArgs[param.name] = param.defaultValue;
378
+ }
379
+ }
380
+ }
381
+ const runArgs = { ...defaultArgs, ...(config.args || {}) };
382
+ const apiDefinitions = (importResult.headerGroups?.length || 0) > 0 || (importResult.endpoints?.length || 0) > 0
383
+ ? { headerGroups: importResult.headerGroups || [], endpoints: importResult.endpoints || [] }
384
+ : undefined;
385
+ const envValidationContext = this.getEnvironmentValidationContext(config.file);
386
+ const executionContext = {
387
+ filePath: location?.filePath ?? config.file,
388
+ sequenceName: sequence.name,
389
+ environment: envValidationContext,
390
+ sequenceStartLine: location?.startLine ?? sequence.startLine,
391
+ sequenceLocationIndex: locationIndex
392
+ };
393
+ this.frames = [];
394
+ this.pauseRequested = false;
395
+ this.stopOnEntryConsumed = false;
396
+ this.failurePauseHandled = false;
397
+ this.runtimeVariables = allVariables;
398
+ this.responses = [];
399
+ responsePanel_1.ResponsePanel.startSequenceRun(this.extensionUri, sequence.name, (0, sequenceRunner_1.countSequenceSteps)(sequence.content), config.file);
400
+ const debugHooks = {
401
+ onSequenceEnter: (info) => this.onSequenceEnter(info),
402
+ onSequenceExit: (info) => this.onSequenceExit(info),
403
+ beforeStep: (event) => this.onBeforeStep(event),
404
+ onFailure: async (failure) => {
405
+ const event = this.lastStepEvent;
406
+ if (!event) {
407
+ return;
408
+ }
409
+ this.failurePauseHandled = true;
410
+ await this.pauseExecution('exception', event, failure.message);
411
+ }
412
+ };
413
+ const result = await (0, sequenceRunner_1.runSequence)(sequence.content, allVariables, path.dirname(config.file), fullTextWithImports, (progress) => this.onProgress(progress), undefined, runArgs, apiDefinitions, undefined, importResult.sequenceSources, importResult.sqlOperationsBySource, executionContext, debugHooks);
414
+ result.name = sequence.name;
415
+ responsePanel_1.ResponsePanel.finalizeSequence(result);
416
+ if (!result.success && this.lastStepEvent && !this.pausedState && !this.failurePauseHandled) {
417
+ await this.pauseExecution('exception', this.lastStepEvent, result.errors[0] || 'Sequence failed');
418
+ }
419
+ }
420
+ catch (error) {
421
+ const message = (0, formatError_1.formatUserFacingError)(error, {
422
+ source: 'extension',
423
+ filePath: this.launchConfig.file,
424
+ sequenceName: this.launchConfig.sequence,
425
+ environment: this.getEnvironmentValidationContext(this.launchConfig.file)
426
+ });
427
+ this.sendEvent('output', {
428
+ category: 'stderr',
429
+ output: `Norn debug error: ${message}\n`
430
+ });
431
+ responsePanel_1.ResponsePanel.finalizeSequence({
432
+ name: this.launchConfig.sequence,
433
+ success: false,
434
+ responses: [],
435
+ scriptResults: [],
436
+ assertionResults: [],
437
+ steps: [],
438
+ errors: [message],
439
+ duration: 0
440
+ });
441
+ }
442
+ finally {
443
+ if (config.env) {
444
+ (0, environmentProvider_1.setActiveEnvironment)(previousEnv, config.file);
445
+ }
446
+ this.sendEvent('thread', { reason: 'exited', threadId: THREAD_ID });
447
+ this.sendEvent('terminated');
448
+ }
449
+ }
450
+ getEnvironmentValidationContext(filePath) {
451
+ return {
452
+ hasEnvFile: (0, environmentProvider_1.getAvailableEnvironments)(filePath).length > 0,
453
+ activeEnvironment: (0, environmentProvider_1.getActiveEnvironment)(filePath),
454
+ availableEnvironments: (0, environmentProvider_1.getAvailableEnvironments)(filePath)
455
+ };
456
+ }
457
+ async validateEnvironmentSelection(filePath, env) {
458
+ if (!env) {
459
+ return;
460
+ }
461
+ const available = (0, environmentProvider_1.getAvailableEnvironments)(filePath);
462
+ if (!available.includes(env)) {
463
+ throw new Error(`Environment '${env}' not found. Available: ${available.join(', ') || 'none'}`);
464
+ }
465
+ }
466
+ async ensureEnvironmentReady(filePath) {
467
+ const envErrors = (0, environmentProvider_1.getEnvironmentImportErrorDetails)(filePath);
468
+ if (envErrors.length > 0) {
469
+ throw new Error(`.nornenv has errors: ${envErrors[0].message}`);
470
+ }
471
+ const unlocked = await (0, environmentProvider_1.promptForMissingEnvironmentSecretKeys)(filePath);
472
+ if (!unlocked) {
473
+ throw new Error('Secrets are locked. Enter shared key to continue.');
474
+ }
475
+ const secretErrors = (0, environmentProvider_1.getEnvironmentSecretErrorDetails)(filePath);
476
+ if (secretErrors.length > 0) {
477
+ throw new Error(`.nornenv secret error: ${secretErrors[0].message}`);
478
+ }
479
+ }
480
+ onProgress(progress) {
481
+ const prefix = progress.nestingDepth && progress.nestingDepth > 0 ? `${' '.repeat(progress.nestingDepth)}` : '';
482
+ this.sendEvent('output', {
483
+ category: 'console',
484
+ output: `${prefix}[${progress.currentStep}/${progress.totalSteps}] ${progress.stepDescription}\n`
485
+ });
486
+ if (progress.stepType === 'sequenceStart' || progress.stepType === 'sequenceEnd') {
487
+ responsePanel_1.ResponsePanel.addSequenceStep(undefined, progress);
488
+ }
489
+ else if (progress.stepResult) {
490
+ responsePanel_1.ResponsePanel.addSequenceStep(progress.stepResult, progress);
491
+ }
492
+ }
493
+ async onSequenceEnter(info) {
494
+ const frame = {
495
+ id: this.nextFrameId++,
496
+ sequenceName: info.sequenceName || 'sequence',
497
+ filePath: info.filePath,
498
+ declarationLine: info.declarationLine,
499
+ currentLine: info.declarationLine,
500
+ nestingDepth: info.nestingDepth
501
+ };
502
+ this.frames.push(frame);
503
+ }
504
+ async onSequenceExit(info) {
505
+ while (this.frames.length > info.nestingDepth) {
506
+ this.frames.pop();
507
+ }
508
+ }
509
+ async onBeforeStep(event) {
510
+ if (this.terminated) {
511
+ throw new Error('Debug session terminated');
512
+ }
513
+ this.lastStepEvent = event;
514
+ this.runtimeVariables = event.runtimeVariables;
515
+ this.responses = event.responses;
516
+ const currentFrame = this.frames[this.frames.length - 1];
517
+ if (currentFrame && event.location.absoluteLine !== undefined) {
518
+ currentFrame.currentLine = event.location.absoluteLine;
519
+ }
520
+ const currentDepth = Math.max(1, this.frames.length);
521
+ let reason;
522
+ if (!this.stopOnEntryConsumed && (this.launchConfig?.stopOnEntry ?? true)) {
523
+ reason = 'entry';
524
+ this.stopOnEntryConsumed = true;
525
+ }
526
+ else if (this.pauseRequested) {
527
+ reason = 'pause';
528
+ this.pauseRequested = false;
529
+ }
530
+ else if (this.continueMode === 'stepIn') {
531
+ reason = 'step';
532
+ }
533
+ else if (this.continueMode === 'next' && currentDepth <= this.stepDepthTarget) {
534
+ reason = 'step';
535
+ }
536
+ else if (this.continueMode === 'stepOut' && currentDepth <= this.stepDepthTarget) {
537
+ reason = 'step';
538
+ }
539
+ else if (event.location.filePath && event.location.absoluteLine !== undefined) {
540
+ const filePath = path.resolve(event.location.filePath);
541
+ const lineOneBased = event.location.absoluteLine + 1;
542
+ const fileBreakpoints = this.breakpointsByFile.get(filePath);
543
+ if (fileBreakpoints && fileBreakpoints.has(lineOneBased)) {
544
+ reason = 'breakpoint';
545
+ }
546
+ }
547
+ if (!reason) {
548
+ return;
549
+ }
550
+ await this.pauseExecution(reason, event);
551
+ }
552
+ async pauseExecution(reason, event, message) {
553
+ if (this.terminated) {
554
+ throw new Error('Debug session terminated');
555
+ }
556
+ this.pausedState = { reason, event, message };
557
+ this.resetVariableHandles();
558
+ this.sendEvent('stopped', {
559
+ reason,
560
+ threadId: THREAD_ID,
561
+ description: message,
562
+ allThreadsStopped: true
563
+ });
564
+ this.waitForResume = new Promise((resolve) => {
565
+ this.resumeResolver = resolve;
566
+ });
567
+ await this.waitForResume;
568
+ this.waitForResume = undefined;
569
+ this.resumeResolver = undefined;
570
+ this.pausedState = undefined;
571
+ if (this.terminated) {
572
+ throw new Error('Debug session terminated');
573
+ }
574
+ }
575
+ resumeExecution() {
576
+ if (this.resumeResolver) {
577
+ this.resumeResolver();
578
+ }
579
+ }
580
+ sendResponse(request, body) {
581
+ const response = {
582
+ seq: this.outgoingSeq++,
583
+ type: 'response',
584
+ request_seq: request.seq,
585
+ command: request.command,
586
+ success: true,
587
+ body
588
+ };
589
+ this.send(response);
590
+ }
591
+ sendErrorResponse(request, message) {
592
+ const response = {
593
+ seq: this.outgoingSeq++,
594
+ type: 'response',
595
+ request_seq: request.seq,
596
+ command: request.command,
597
+ success: false,
598
+ message
599
+ };
600
+ this.send(response);
601
+ }
602
+ sendEvent(event, body) {
603
+ const output = {
604
+ seq: this.outgoingSeq++,
605
+ type: 'event',
606
+ event,
607
+ body
608
+ };
609
+ this.send(output);
610
+ }
611
+ }
612
+ exports.NornDebugSession = NornDebugSession;
613
+ //# sourceMappingURL=nornDebugSession.js.map
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.buildSequenceLocationIndex = buildSequenceLocationIndex;
37
+ const fs = __importStar(require("fs/promises"));
38
+ const sequenceRunner_1 = require("../sequenceRunner");
39
+ const sequenceDeclaration_1 = require("../sequenceDeclaration");
40
+ async function indexFile(filePath, index, readFile, visited) {
41
+ if (visited.has(filePath)) {
42
+ return;
43
+ }
44
+ visited.add(filePath);
45
+ const content = await readFile(filePath);
46
+ const lines = content.split('\n');
47
+ const sequences = (0, sequenceRunner_1.extractSequences)(content);
48
+ for (const seq of sequences) {
49
+ const key = seq.name.toLowerCase();
50
+ if (index.has(key)) {
51
+ continue;
52
+ }
53
+ const declarationLine = (0, sequenceDeclaration_1.findSequenceDeclarationLine)(lines, seq.startLine, seq.endLine);
54
+ const entry = {
55
+ filePath,
56
+ sequenceName: seq.name,
57
+ declarationLine,
58
+ startLine: declarationLine,
59
+ endLine: seq.endLine
60
+ };
61
+ index.set(key, entry);
62
+ }
63
+ }
64
+ /**
65
+ * Builds a sequence location index for root file and imported sequence sources.
66
+ */
67
+ async function buildSequenceLocationIndex(rootFilePath, importedSequenceSources, readFile = (p) => fs.readFile(p, 'utf-8')) {
68
+ const index = new Map();
69
+ const visited = new Set();
70
+ await indexFile(rootFilePath, index, readFile, visited);
71
+ const importedFiles = new Set(Array.from(importedSequenceSources.values()));
72
+ for (const filePath of importedFiles) {
73
+ await indexFile(filePath, index, readFile, visited);
74
+ }
75
+ return index;
76
+ }
77
+ //# sourceMappingURL=sequenceLocationIndex.js.map
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map