@bastani/atomic 0.8.9-0 → 0.8.10-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.
@@ -18,6 +18,7 @@ import { clampThinkingLevel, cleanupSessionResources, getSupportedThinkingLevels
18
18
  import { theme } from "../modes/interactive/theme/theme.js";
19
19
  import { stripFrontmatter } from "../utils/frontmatter.js";
20
20
  import { sleep } from "../utils/sleep.js";
21
+ import { ATOMIC_GUIDE_COMMAND_NAME, ATOMIC_GUIDE_HELP_CHOICES, atomicGuideModeForChoice, getAtomicGuideMessage, isAtomicGuideHelpChoice, normalizeAtomicGuideMode, } from "./atomic-guide-command.js";
21
22
  import { formatNoApiKeyFoundMessage, formatNoModelSelectedMessage } from "./auth-guidance.js";
22
23
  import { executeBashWithOperations } from "./bash-executor.js";
23
24
  import { calculateContextTokens, collectEntriesForBranchSummary, compact, estimateContextTokens, generateBranchSummary, prepareCompaction, shouldCompact, } from "./compaction/index.js";
@@ -663,6 +664,7 @@ export class AgentSession {
663
664
  this._baseSystemPromptOptions = {
664
665
  cwd: this._cwd,
665
666
  selectedModel: this.model,
667
+ selectedThinkingLevel: this.thinkingLevel,
666
668
  skills: loadedSkills,
667
669
  contextFiles: loadedContextFiles,
668
670
  customPrompt: loaderSystemPrompt,
@@ -694,12 +696,16 @@ export class AgentSession {
694
696
  const preflightResult = options?.preflightResult;
695
697
  let messages;
696
698
  try {
697
- // Handle extension commands first (execute immediately, even during streaming)
698
- // Extension commands manage their own LLM interaction via pi.sendMessage()
699
+ // Handle slash commands first (execute immediately, even during streaming).
700
+ // Builtin and extension commands manage their own LLM interaction via custom messages.
699
701
  if (expandPromptTemplates && text.startsWith("/")) {
700
- const handled = await this._tryExecuteExtensionCommand(text);
701
- if (handled) {
702
- // Extension command executed, no prompt to send
702
+ const handledBuiltin = await this._tryExecuteBuiltinSlashCommand(text);
703
+ if (handledBuiltin) {
704
+ preflightResult?.(true);
705
+ return;
706
+ }
707
+ const handledExtension = await this._tryExecuteExtensionCommand(text);
708
+ if (handledExtension) {
703
709
  preflightResult?.(true);
704
710
  return;
705
711
  }
@@ -810,6 +816,36 @@ export class AgentSession {
810
816
  await this.agent.prompt(messages);
811
817
  await this.waitForRetry();
812
818
  }
819
+ /**
820
+ * Try to execute a built-in slash command. Returns true if command was found and executed.
821
+ */
822
+ async _tryExecuteBuiltinSlashCommand(text) {
823
+ const spaceIndex = text.indexOf(" ");
824
+ const commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);
825
+ if (commandName !== ATOMIC_GUIDE_COMMAND_NAME)
826
+ return false;
827
+ const args = spaceIndex === -1 ? "" : text.slice(spaceIndex + 1);
828
+ const mode = normalizeAtomicGuideMode(args);
829
+ if (mode === "help" && this._extensionUIContext) {
830
+ const choice = await this._extensionUIContext.select("Atomic. Select where to start:", [
831
+ ...ATOMIC_GUIDE_HELP_CHOICES,
832
+ ]);
833
+ if (!choice || !isAtomicGuideHelpChoice(choice))
834
+ return true;
835
+ await this.sendCustomMessage({
836
+ customType: "atomic",
837
+ content: getAtomicGuideMessage(atomicGuideModeForChoice(choice), this._cwd),
838
+ display: true,
839
+ }, { triggerTurn: false });
840
+ return true;
841
+ }
842
+ await this.sendCustomMessage({
843
+ customType: "atomic",
844
+ content: getAtomicGuideMessage(mode, this._cwd),
845
+ display: true,
846
+ }, { triggerTurn: false });
847
+ return true;
848
+ }
813
849
  /**
814
850
  * Try to execute an extension command. Returns true if command was found and executed.
815
851
  */
@@ -1168,6 +1204,7 @@ export class AgentSession {
1168
1204
  this.agent.state.thinkingLevel = effectiveLevel;
1169
1205
  if (isChanging) {
1170
1206
  this.sessionManager.appendThinkingLevelChange(effectiveLevel);
1207
+ this._refreshBaseSystemPromptFromActiveTools();
1171
1208
  if (this.supportsThinking() || effectiveLevel !== "off") {
1172
1209
  this.settingsManager.setDefaultThinkingLevel(effectiveLevel);
1173
1210
  }