@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/src/version.ts CHANGED
@@ -16,7 +16,7 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.113.0-6';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.113.0-7';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
package/src/versions.txt CHANGED
@@ -1171,4 +1171,4 @@
1171
1171
  0.113.0-3
1172
1172
  0.113.0-4
1173
1173
  0.113.0-5
1174
- 0.113.0-6
1174
+ 0.113.0-7
package/umd/index.umd.js CHANGED
@@ -63,7 +63,7 @@
63
63
  * @generated
64
64
  * @see https://github.com/webgptorg/promptbook
65
65
  */
66
- const PROMPTBOOK_ENGINE_VERSION = '0.113.0-6';
66
+ const PROMPTBOOK_ENGINE_VERSION = '0.113.0-7';
67
67
  /**
68
68
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
69
69
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -40290,6 +40290,30 @@
40290
40290
  }
40291
40291
  // Note: [🟡] Code for repository script [RefactorCandidateLevel](scripts/find-refactor-candidates/RefactorCandidateLevel.ts) should never be published outside of `@promptbook/cli`
40292
40292
 
40293
+ /**
40294
+ * Creates a Commander argument parser that accepts only positive integers.
40295
+ *
40296
+ * The returned parser is meant to be passed as the coercion callback of `command.option(...)`.
40297
+ * It throws a branded `NotAllowed` error with a clear message referencing the given option name
40298
+ * when the provided value is not a positive integer.
40299
+ *
40300
+ * @private internal utility of `promptbookCli`
40301
+ */
40302
+ function createPositiveIntegerOptionParser(optionName) {
40303
+ return (value) => {
40304
+ const parsedValue = Number(value);
40305
+ if (!Number.isInteger(parsedValue) || parsedValue <= 0) {
40306
+ throw new NotAllowed(_spaceTrim.spaceTrim(`
40307
+ Invalid value for \`${optionName}\`: \`${value}\`.
40308
+
40309
+ Use a positive integer.
40310
+ `));
40311
+ }
40312
+ return parsedValue;
40313
+ };
40314
+ }
40315
+ // Note: [🟡] Code for CLI option parser [createPositiveIntegerOptionParser](src/cli/cli-commands/common/createPositiveIntegerOptionParser.ts) should never be published outside of `@promptbook/cli`
40316
+
40293
40317
  /**
40294
40318
  * Initializes `coder find-refactor-candidates` command for Promptbook CLI utilities
40295
40319
  *
@@ -40310,12 +40334,13 @@
40310
40334
  command.addOption(new commander.Option('--level <level>', `Set scan aggressiveness (${REFACTOR_CANDIDATE_LEVEL_VALUES.join(', ')})`)
40311
40335
  .choices([...REFACTOR_CANDIDATE_LEVEL_VALUES])
40312
40336
  .default(DEFAULT_REFACTOR_CANDIDATE_LEVEL));
40337
+ command.option('--limit <candidate-count>', 'Create at most this many refactor prompts, keeping the most important candidates', createPositiveIntegerOptionParser('--limit'));
40313
40338
  command.action(handleActionErrors(async (cliOptions) => {
40314
- const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL } = cliOptions;
40339
+ const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL, limit } = cliOptions;
40315
40340
  // Note: Import the function dynamically to avoid loading heavy dependencies until needed
40316
40341
  const { findRefactorCandidates } = await Promise.resolve().then(function () { return findRefactorCandidates$1; });
40317
40342
  try {
40318
- await findRefactorCandidates({ level });
40343
+ await findRefactorCandidates({ level, limit });
40319
40344
  }
40320
40345
  catch (error) {
40321
40346
  assertsError(error);
@@ -41464,7 +41489,7 @@
41464
41489
  command.option('--preserve-logs', 'Keep generated temp prompt/log artifacts after successful rounds for debugging and analytics', false);
41465
41490
  addPromptRunnerExecutionOptions(command);
41466
41491
  command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption$1, 0);
41467
- command.option('--limit <run-count>', 'Stop after processing this many prompt runs', parsePositiveIntegerOption);
41492
+ command.option('--limit <run-count>', 'Stop after processing this many prompt runs', createPositiveIntegerOptionParser('--limit'));
41468
41493
  command.option('--wait-after-prompt <duration>', _spaceTrim.spaceTrim(`
41469
41494
  Wait this long after each prompt has been implemented, verified and committed before starting the next prompt.
41470
41495
  Accepts durations like 1h, 30m, 5s. Defaults to 0 (no wait).
@@ -41551,22 +41576,6 @@
41551
41576
  }
41552
41577
  return parsed;
41553
41578
  }
41554
- /**
41555
- * Parses a positive integer option value.
41556
- *
41557
- * @private internal utility of `coder run` command
41558
- */
41559
- function parsePositiveIntegerOption(value) {
41560
- const parsed = Number(value);
41561
- if (!Number.isInteger(parsed) || parsed <= 0) {
41562
- throw new NotAllowed(_spaceTrim.spaceTrim(`
41563
- Invalid value for \`--limit\`: \`${value}\`.
41564
-
41565
- Use a positive integer.
41566
- `));
41567
- }
41568
- return parsed;
41569
- }
41570
41579
  /**
41571
41580
  * Joins one Commander option that may be parsed either as a single string or a variadic token array.
41572
41581
  *
@@ -69839,23 +69848,28 @@
69839
69848
  const extension = path.extname(filePath).toLowerCase();
69840
69849
  const relativePath = normalizeRefactorCandidatePath(path.relative(rootDir, filePath));
69841
69850
  const reasons = [];
69851
+ let severityScore = 0;
69842
69852
  if (!lineCountExemptPaths.has(normalizedAbsolutePath)) {
69843
69853
  const lineCount = countLines(content);
69844
69854
  const maxLines = getMaxLinesForExtension(extension, heuristics);
69845
69855
  if (lineCount > maxLines) {
69846
69856
  reasons.push(`lines ${lineCount}/${maxLines}`);
69857
+ severityScore += lineCount / maxLines;
69847
69858
  }
69848
69859
  }
69849
69860
  if (STRUCTURAL_ANALYSIS_EXTENSIONS.includes(extension)) {
69850
69861
  const structureSummary = summarizeSourceFileStructure(content, extension, filePath);
69851
69862
  if (structureSummary.entityCount > heuristics.maxEntityCountPerFile) {
69852
69863
  reasons.push(`entities ${structureSummary.entityCount}/${heuristics.maxEntityCountPerFile}`);
69864
+ severityScore += structureSummary.entityCount / heuristics.maxEntityCountPerFile;
69853
69865
  }
69854
69866
  if (structureSummary.functionCount > heuristics.maxFunctionCountPerFile) {
69855
69867
  reasons.push(`functions ${structureSummary.functionCount}/${heuristics.maxFunctionCountPerFile}`);
69868
+ severityScore += structureSummary.functionCount / heuristics.maxFunctionCountPerFile;
69856
69869
  }
69857
69870
  if (structureSummary.maxFunctionComplexity > heuristics.maxFunctionComplexity) {
69858
69871
  reasons.push(buildComplexityReason(structureSummary, heuristics.maxFunctionComplexity));
69872
+ severityScore += structureSummary.maxFunctionComplexity / heuristics.maxFunctionComplexity;
69859
69873
  }
69860
69874
  }
69861
69875
  if (reasons.length === 0) {
@@ -69865,6 +69879,7 @@
69865
69879
  absolutePath: filePath,
69866
69880
  relativePath,
69867
69881
  reasons,
69882
+ severityScore,
69868
69883
  };
69869
69884
  }
69870
69885
  /**
@@ -70324,6 +70339,37 @@
70324
70339
  }
70325
70340
  // Note: [🟡] Code for repository script [resolveRefactorCandidateProject](scripts/find-refactor-candidates/resolveRefactorCandidateProject.ts) should never be published outside of `@promptbook/cli`
70326
70341
 
70342
+ /**
70343
+ * Keeps at most `limit` refactor candidates, preferring the most important ones.
70344
+ *
70345
+ * When there are more candidates than `limit`, only the highest-severity candidates are kept
70346
+ * (ties broken by relative path for determinism). When `limit` is `undefined` or there are fewer
70347
+ * candidates than the limit, every candidate is returned. The original input order is preserved
70348
+ * among the kept candidates, so `limit` acts purely as a filter and never reorders prompts.
70349
+ *
70350
+ * @private function of findRefactorCandidates
70351
+ */
70352
+ function selectMostImportantRefactorCandidates(candidates, limit) {
70353
+ if (limit === undefined || candidates.length <= limit) {
70354
+ return candidates;
70355
+ }
70356
+ const candidatesRankedByImportance = [...candidates].sort(compareRefactorCandidatesByImportance);
70357
+ const keptRelativePaths = new Set(candidatesRankedByImportance.slice(0, limit).map((candidate) => candidate.relativePath));
70358
+ return candidates.filter((candidate) => keptRelativePaths.has(candidate.relativePath));
70359
+ }
70360
+ /**
70361
+ * Orders refactor candidates from most to least important.
70362
+ *
70363
+ * @private function of selectMostImportantRefactorCandidates
70364
+ */
70365
+ function compareRefactorCandidatesByImportance(candidateA, candidateB) {
70366
+ if (candidateB.severityScore !== candidateA.severityScore) {
70367
+ return candidateB.severityScore - candidateA.severityScore;
70368
+ }
70369
+ return candidateA.relativePath.localeCompare(candidateB.relativePath);
70370
+ }
70371
+ // Note: [🟡] Code for repository script [selectMostImportantRefactorCandidates](scripts/find-refactor-candidates/selectMostImportantRefactorCandidates.ts) should never be published outside of `@promptbook/cli`
70372
+
70327
70373
  /**
70328
70374
  * Calculates the next available prompt numbering sequence for a month.
70329
70375
  */
@@ -70647,7 +70693,7 @@
70647
70693
  * @public exported from `@promptbook/cli`
70648
70694
  */
70649
70695
  async function findRefactorCandidates(options = {}) {
70650
- const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL } = options;
70696
+ const { level = DEFAULT_REFACTOR_CANDIDATE_LEVEL, limit } = options;
70651
70697
  const heuristics = getRefactorCandidateLevelConfiguration(level);
70652
70698
  initializeFindRefactorCandidatesRun();
70653
70699
  console.info(colors__default["default"].cyan('⚡🏭 Find refactor candidates'));
@@ -70671,8 +70717,10 @@
70671
70717
  console.info(colors__default["default"].green('All candidates already have prompts.'));
70672
70718
  return;
70673
70719
  }
70720
+ const selectedCandidatesToWrite = selectMostImportantRefactorCandidates(candidatesToWrite, limit);
70721
+ const skippedByLimit = candidatesToWrite.length - selectedCandidatesToWrite.length;
70674
70722
  const createdPrompts = await writeRefactorCandidatePrompts({
70675
- candidates: candidatesToWrite,
70723
+ candidates: selectedCandidatesToWrite,
70676
70724
  rootDir,
70677
70725
  promptsDir,
70678
70726
  });
@@ -70680,6 +70728,9 @@
70680
70728
  if (alreadyTracked > 0) {
70681
70729
  console.info(colors__default["default"].gray(`Skipped ${alreadyTracked} candidate(s) with existing prompts.`));
70682
70730
  }
70731
+ if (skippedByLimit > 0) {
70732
+ console.info(colors__default["default"].gray(`Skipped ${skippedByLimit} lower-priority candidate(s) because of \`--limit ${limit}\`.`));
70733
+ }
70683
70734
  }
70684
70735
  /**
70685
70736
  * Prints discovered refactor candidates with their reasons.