@promptbook/cli 0.113.0-6 → 0.113.0-7

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 (78) hide show
  1. package/apps/agents-server/src/app/admin/update/AdvancedOriginRepositoryPanel.tsx +76 -0
  2. package/apps/agents-server/src/app/admin/update/CurrentDeploymentCard.tsx +160 -0
  3. package/apps/agents-server/src/app/admin/update/PendingCommitsCard.tsx +86 -0
  4. package/apps/agents-server/src/app/admin/update/TargetEnvironmentCard.tsx +331 -0
  5. package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +20 -873
  6. package/apps/agents-server/src/app/admin/update/UpdateJobCard.tsx +329 -0
  7. package/apps/agents-server/src/app/admin/update/UpdateOverview.ts +74 -0
  8. package/apps/agents-server/src/app/admin/update/buildDeploymentTimeBehindLabel.ts +29 -0
  9. package/apps/agents-server/src/app/admin/update/formatHumanReadableTimestamp.ts +18 -0
  10. package/apps/agents-server/src/app/admin/update/getUpdateJobFailureMessage.ts +13 -0
  11. package/apps/agents-server/src/app/admin/update/getUpdateJobSuccessMessage.ts +13 -0
  12. package/apps/agents-server/src/app/admin/update/useUpdateClientState.ts +441 -0
  13. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageClient.tsx +14 -559
  14. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageHeader.tsx +84 -0
  15. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/AgentCodePageSection.tsx +52 -0
  16. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedCodePreview.tsx +138 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/GeneratedHarnessSection.tsx +98 -0
  18. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/SourceBookSection.tsx +66 -0
  19. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeErrorBanner.tsx +30 -0
  20. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/TranspiledCodeExportWarningBanner.tsx +62 -0
  21. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/Transpiler.ts +9 -0
  22. package/apps/agents-server/src/app/agents/[agentName]/export-as-transpiled-code/useAgentCodeExportState.ts +478 -0
  23. package/apps/agents-server/src/app/system/utilities/mocked-chats/cloneMockedChatPreset.ts +17 -0
  24. package/apps/agents-server/src/app/system/utilities/mocked-chats/confirmDeleteMockedChat.ts +16 -0
  25. package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedMessage.ts +81 -0
  26. package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedParticipant.ts +146 -0
  27. package/apps/agents-server/src/app/system/utilities/mocked-chats/createDraftWithUpdatedSettings.ts +19 -0
  28. package/apps/agents-server/src/app/system/utilities/mocked-chats/createDuplicatedDraft.ts +66 -0
  29. package/apps/agents-server/src/app/system/utilities/mocked-chats/findMockedChatById.ts +51 -0
  30. package/apps/agents-server/src/app/system/utilities/mocked-chats/persistMockedChats.ts +51 -0
  31. package/apps/agents-server/src/app/system/utilities/mocked-chats/useMockedChatsEditorState.ts +16 -426
  32. package/apps/agents-server/src/components/Homepage/buildFreeGraphBoxLayout.ts +446 -0
  33. package/apps/agents-server/src/components/Homepage/buildGraphLayoutNodes.ts +415 -157
  34. package/apps/agents-server/src/components/Homepage/useAgentsGraphCanvasState.ts +2 -1
  35. package/apps/agents-server/src/database/sqlite/$provideLocalSqliteSupabase.ts +3 -1541
  36. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteQueryBuilder.ts +623 -0
  37. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/LocalSqliteSupabaseClient.ts +64 -0
  38. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/ensureTable.ts +93 -0
  39. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteFilters.ts +202 -0
  40. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteMutationPayload.ts +131 -0
  41. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteRowOperations.ts +102 -0
  42. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteSql.ts +59 -0
  43. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTableSchema.ts +329 -0
  44. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteTypes.ts +84 -0
  45. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/localSqliteValueCodec.ts +63 -0
  46. package/apps/agents-server/src/database/sqlite/localSqliteSupabase/normalizeSqliteError.ts +22 -0
  47. package/apps/agents-server/src/tools/send_email.ts +1 -2
  48. package/apps/agents-server/src/utils/messages/sendMessage.ts +5 -3
  49. package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition/SpeechToTextFailoverRecognitionProviderRuntime.ts +0 -1
  50. package/apps/agents-server/src/utils/speech-to-text/SpeechToTextFailoverRecognition.ts +34 -2
  51. package/esm/index.es.js +73 -22
  52. package/esm/index.es.js.map +1 -1
  53. package/esm/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
  54. package/esm/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
  55. package/esm/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
  56. package/esm/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
  57. package/esm/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
  58. package/esm/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
  59. package/esm/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
  60. package/package.json +1 -1
  61. package/src/book-components/Chat/Chat/insertDictationChunk.ts +3 -3
  62. package/src/book-components/Chat/Chat/learnDictationDictionary.ts +1 -1
  63. package/src/book-components/Chat/Chat/useChatInputAreaDictation.ts +133 -26
  64. package/src/cli/cli-commands/coder/find-refactor-candidates.ts +9 -2
  65. package/src/cli/cli-commands/coder/run.ts +6 -23
  66. package/src/cli/cli-commands/common/createPositiveIntegerOptionParser.ts +31 -0
  67. package/src/other/templates/getTemplatesPipelineCollection.ts +636 -869
  68. package/src/version.ts +1 -1
  69. package/src/versions.txt +1 -1
  70. package/umd/index.umd.js +73 -22
  71. package/umd/index.umd.js.map +1 -1
  72. package/umd/scripts/find-refactor-candidates/find-refactor-candidates.d.ts +7 -0
  73. package/umd/scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.d.ts +12 -0
  74. package/umd/src/book-components/Chat/Chat/insertDictationChunk.d.ts +1 -1
  75. package/umd/src/book-components/Chat/Chat/insertDictationChunk.test.d.ts +1 -0
  76. package/umd/src/book-components/Chat/Chat/learnDictationDictionary.test.d.ts +1 -0
  77. package/umd/src/book-components/Chat/Chat/refineFinalDictationChunk.test.d.ts +1 -0
  78. package/umd/src/cli/cli-commands/common/createPositiveIntegerOptionParser.d.ts +10 -0
package/esm/index.es.js CHANGED
@@ -59,7 +59,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
59
59
  * @generated
60
60
  * @see https://github.com/webgptorg/promptbook
61
61
  */
62
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-6';
62
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-7';
63
63
  /**
64
64
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
65
65
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -40286,6 +40286,30 @@ function createLineCountLimits(maxLineCount) {
40286
40286
  }
40287
40287
  // Note: [🟡] Code for repository script [RefactorCandidateLevel](scripts/find-refactor-candidates/RefactorCandidateLevel.ts) should never be published outside of `@promptbook/cli`
40288
40288
 
40289
+ /**
40290
+ * Creates a Commander argument parser that accepts only positive integers.
40291
+ *
40292
+ * The returned parser is meant to be passed as the coercion callback of `command.option(...)`.
40293
+ * It throws a branded `NotAllowed` error with a clear message referencing the given option name
40294
+ * when the provided value is not a positive integer.
40295
+ *
40296
+ * @private internal utility of `promptbookCli`
40297
+ */
40298
+ function createPositiveIntegerOptionParser(optionName) {
40299
+ return (value) => {
40300
+ const parsedValue = Number(value);
40301
+ if (!Number.isInteger(parsedValue) || parsedValue <= 0) {
40302
+ throw new NotAllowed(spaceTrim$1(`
40303
+ Invalid value for \`${optionName}\`: \`${value}\`.
40304
+
40305
+ Use a positive integer.
40306
+ `));
40307
+ }
40308
+ return parsedValue;
40309
+ };
40310
+ }
40311
+ // Note: [🟡] Code for CLI option parser [createPositiveIntegerOptionParser](src/cli/cli-commands/common/createPositiveIntegerOptionParser.ts) should never be published outside of `@promptbook/cli`
40312
+
40289
40313
  /**
40290
40314
  * Initializes `coder find-refactor-candidates` command for Promptbook CLI utilities
40291
40315
  *
@@ -40306,12 +40330,13 @@ function $initializeCoderFindRefactorCandidatesCommand(program) {
40306
40330
  command.addOption(new Option('--level <level>', `Set scan aggressiveness (${REFACTOR_CANDIDATE_LEVEL_VALUES.join(', ')})`)
40307
40331
  .choices([...REFACTOR_CANDIDATE_LEVEL_VALUES])
40308
40332
  .default(DEFAULT_REFACTOR_CANDIDATE_LEVEL));
40333
+ command.option('--limit <candidate-count>', 'Create at most this many refactor prompts, keeping the most important candidates', createPositiveIntegerOptionParser('--limit'));
40309
40334
  command.action(handleActionErrors(async (cliOptions) => {
40310
- const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL } = cliOptions;
40335
+ const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL, limit } = cliOptions;
40311
40336
  // Note: Import the function dynamically to avoid loading heavy dependencies until needed
40312
40337
  const { findRefactorCandidates } = await Promise.resolve().then(function () { return findRefactorCandidates$1; });
40313
40338
  try {
40314
- await findRefactorCandidates({ level });
40339
+ await findRefactorCandidates({ level, limit });
40315
40340
  }
40316
40341
  catch (error) {
40317
40342
  assertsError(error);
@@ -41460,7 +41485,7 @@ function $initializeCoderRunCommand(program) {
41460
41485
  command.option('--preserve-logs', 'Keep generated temp prompt/log artifacts after successful rounds for debugging and analytics', false);
41461
41486
  addPromptRunnerExecutionOptions(command);
41462
41487
  command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption$1, 0);
41463
- command.option('--limit <run-count>', 'Stop after processing this many prompt runs', parsePositiveIntegerOption);
41488
+ command.option('--limit <run-count>', 'Stop after processing this many prompt runs', createPositiveIntegerOptionParser('--limit'));
41464
41489
  command.option('--wait-after-prompt <duration>', spaceTrim$1(`
41465
41490
  Wait this long after each prompt has been implemented, verified and committed before starting the next prompt.
41466
41491
  Accepts durations like 1h, 30m, 5s. Defaults to 0 (no wait).
@@ -41547,22 +41572,6 @@ function parseIntOption$1(value) {
41547
41572
  }
41548
41573
  return parsed;
41549
41574
  }
41550
- /**
41551
- * Parses a positive integer option value.
41552
- *
41553
- * @private internal utility of `coder run` command
41554
- */
41555
- function parsePositiveIntegerOption(value) {
41556
- const parsed = Number(value);
41557
- if (!Number.isInteger(parsed) || parsed <= 0) {
41558
- throw new NotAllowed(spaceTrim$1(`
41559
- Invalid value for \`--limit\`: \`${value}\`.
41560
-
41561
- Use a positive integer.
41562
- `));
41563
- }
41564
- return parsed;
41565
- }
41566
41575
  /**
41567
41576
  * Joins one Commander option that may be parsed either as a single string or a variadic token array.
41568
41577
  *
@@ -69835,23 +69844,28 @@ async function analyzeSourceFileForRefactorCandidate(options) {
69835
69844
  const extension = extname(filePath).toLowerCase();
69836
69845
  const relativePath = normalizeRefactorCandidatePath(relative(rootDir, filePath));
69837
69846
  const reasons = [];
69847
+ let severityScore = 0;
69838
69848
  if (!lineCountExemptPaths.has(normalizedAbsolutePath)) {
69839
69849
  const lineCount = countLines(content);
69840
69850
  const maxLines = getMaxLinesForExtension(extension, heuristics);
69841
69851
  if (lineCount > maxLines) {
69842
69852
  reasons.push(`lines ${lineCount}/${maxLines}`);
69853
+ severityScore += lineCount / maxLines;
69843
69854
  }
69844
69855
  }
69845
69856
  if (STRUCTURAL_ANALYSIS_EXTENSIONS.includes(extension)) {
69846
69857
  const structureSummary = summarizeSourceFileStructure(content, extension, filePath);
69847
69858
  if (structureSummary.entityCount > heuristics.maxEntityCountPerFile) {
69848
69859
  reasons.push(`entities ${structureSummary.entityCount}/${heuristics.maxEntityCountPerFile}`);
69860
+ severityScore += structureSummary.entityCount / heuristics.maxEntityCountPerFile;
69849
69861
  }
69850
69862
  if (structureSummary.functionCount > heuristics.maxFunctionCountPerFile) {
69851
69863
  reasons.push(`functions ${structureSummary.functionCount}/${heuristics.maxFunctionCountPerFile}`);
69864
+ severityScore += structureSummary.functionCount / heuristics.maxFunctionCountPerFile;
69852
69865
  }
69853
69866
  if (structureSummary.maxFunctionComplexity > heuristics.maxFunctionComplexity) {
69854
69867
  reasons.push(buildComplexityReason(structureSummary, heuristics.maxFunctionComplexity));
69868
+ severityScore += structureSummary.maxFunctionComplexity / heuristics.maxFunctionComplexity;
69855
69869
  }
69856
69870
  }
69857
69871
  if (reasons.length === 0) {
@@ -69861,6 +69875,7 @@ async function analyzeSourceFileForRefactorCandidate(options) {
69861
69875
  absolutePath: filePath,
69862
69876
  relativePath,
69863
69877
  reasons,
69878
+ severityScore,
69864
69879
  };
69865
69880
  }
69866
69881
  /**
@@ -70320,6 +70335,37 @@ async function isExistingFile(filePath) {
70320
70335
  }
70321
70336
  // Note: [🟡] Code for repository script [resolveRefactorCandidateProject](scripts/find-refactor-candidates/resolveRefactorCandidateProject.ts) should never be published outside of `@promptbook/cli`
70322
70337
 
70338
+ /**
70339
+ * Keeps at most `limit` refactor candidates, preferring the most important ones.
70340
+ *
70341
+ * When there are more candidates than `limit`, only the highest-severity candidates are kept
70342
+ * (ties broken by relative path for determinism). When `limit` is `undefined` or there are fewer
70343
+ * candidates than the limit, every candidate is returned. The original input order is preserved
70344
+ * among the kept candidates, so `limit` acts purely as a filter and never reorders prompts.
70345
+ *
70346
+ * @private function of findRefactorCandidates
70347
+ */
70348
+ function selectMostImportantRefactorCandidates(candidates, limit) {
70349
+ if (limit === undefined || candidates.length <= limit) {
70350
+ return candidates;
70351
+ }
70352
+ const candidatesRankedByImportance = [...candidates].sort(compareRefactorCandidatesByImportance);
70353
+ const keptRelativePaths = new Set(candidatesRankedByImportance.slice(0, limit).map((candidate) => candidate.relativePath));
70354
+ return candidates.filter((candidate) => keptRelativePaths.has(candidate.relativePath));
70355
+ }
70356
+ /**
70357
+ * Orders refactor candidates from most to least important.
70358
+ *
70359
+ * @private function of selectMostImportantRefactorCandidates
70360
+ */
70361
+ function compareRefactorCandidatesByImportance(candidateA, candidateB) {
70362
+ if (candidateB.severityScore !== candidateA.severityScore) {
70363
+ return candidateB.severityScore - candidateA.severityScore;
70364
+ }
70365
+ return candidateA.relativePath.localeCompare(candidateB.relativePath);
70366
+ }
70367
+ // Note: [🟡] Code for repository script [selectMostImportantRefactorCandidates](scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.ts) should never be published outside of `@promptbook/cli`
70368
+
70323
70369
  /**
70324
70370
  * Calculates the next available prompt numbering sequence for a month.
70325
70371
  */
@@ -70643,7 +70689,7 @@ function initializeFindRefactorCandidatesRun() {
70643
70689
  * @public exported from `@promptbook/cli`
70644
70690
  */
70645
70691
  async function findRefactorCandidates(options = {}) {
70646
- const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL } = options;
70692
+ const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL, limit } = options;
70647
70693
  const heuristics = getRefactorCandidateLevelConfiguration(level);
70648
70694
  initializeFindRefactorCandidatesRun();
70649
70695
  console.info(colors.cyan('⚡🏭 Find refactor candidates'));
@@ -70667,8 +70713,10 @@ async function findRefactorCandidates(options = {}) {
70667
70713
  console.info(colors.green('All candidates already have prompts.'));
70668
70714
  return;
70669
70715
  }
70716
+ const selectedCandidatesToWrite = selectMostImportantRefactorCandidates(candidatesToWrite, limit);
70717
+ const skippedByLimit = candidatesToWrite.length - selectedCandidatesToWrite.length;
70670
70718
  const createdPrompts = await writeRefactorCandidatePrompts({
70671
- candidates: candidatesToWrite,
70719
+ candidates: selectedCandidatesToWrite,
70672
70720
  rootDir,
70673
70721
  promptsDir,
70674
70722
  });
@@ -70676,6 +70724,9 @@ async function findRefactorCandidates(options = {}) {
70676
70724
  if (alreadyTracked > 0) {
70677
70725
  console.info(colors.gray(`Skipped ${alreadyTracked} candidate(s) with existing prompts.`));
70678
70726
  }
70727
+ if (skippedByLimit > 0) {
70728
+ console.info(colors.gray(`Skipped ${skippedByLimit} lower-priority candidate(s) because of \`--limit ${limit}\`.`));
70729
+ }
70679
70730
  }
70680
70731
  /**
70681
70732
  * Prints discovered refactor candidates with their reasons.