brainclaw 0.19.7 → 0.19.11

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.
@@ -2,7 +2,7 @@ import readline from 'node:readline';
2
2
  import { Worker } from 'node:worker_threads';
3
3
  import { getTriggeredItems, renderTriggeredItems } from '../core/lifecycle.js';
4
4
  import { resolveCrossProjectTarget, writeCrossProjectNote } from '../core/cross-project.js';
5
- import { renderBootstrapSummary, runBootstrapProfile } from '../core/bootstrap.js';
5
+ import { applyBootstrapImport, renderBootstrapInterview, renderBootstrapSummary, runBootstrapProfile, uninstallBootstrapImport } from '../core/bootstrap.js';
6
6
  import { buildAgentToolingContext, renderAgentToolingSummary } from '../core/agent-context.js';
7
7
  import { buildCoordinationSnapshot } from '../core/coordination.js';
8
8
  import { buildContext, renderContextMarkdown, renderContextPromptTemplate } from '../core/context.js';
@@ -30,6 +30,7 @@ import { detectAiAgent } from '../core/ai-agent-detection.js';
30
30
  import { checkGitPresence, scanGitRepos, parseRoots, parseRepoSelection, parseAgentSelection, runGlobalInstall, initReposAndConfigureAgents, readSetupState, ALL_KNOWN_AGENTS, } from './setup.js';
31
31
  import { resolveTargetStore, resolveStoreChain } from '../core/store-resolution.js';
32
32
  import { readUnseenEvents, buildNotificationSummary } from '../core/event-log.js';
33
+ import { BootstrapInterviewAnswerSchema } from '../core/schema.js';
33
34
  export const SCHEMA_VERSION = '0.6.0';
34
35
  export const MCP_PROTOCOL_VERSIONS = ['2025-11-25', '2024-11-05'];
35
36
  export const MCP_SERVER_NOT_INITIALIZED = -32002;
@@ -61,12 +62,21 @@ export const MCP_READ_TOOLS = [
61
62
  },
62
63
  {
63
64
  name: 'bclaw_bootstrap',
64
- description: 'Derive brownfield bootstrap signals from repository docs, manifests, and git history.',
65
+ description: 'Derive brownfield bootstrap signals, adaptive interview prompts for CLI or IDE chat agents, and an import proposal from repository docs, manifests, native agent files, and git history.',
65
66
  inputSchema: {
66
67
  type: 'object',
67
68
  properties: {
68
69
  target: { type: 'string', description: 'Optional path or scope to tailor the bootstrap.' },
69
70
  refresh: { type: 'boolean', description: 'Force a fresh bootstrap scan.' },
71
+ audience: { type: 'string', description: 'Optional interview audience filter: cli, ide_chat, or any.' },
72
+ interview: { type: 'boolean', description: 'Render interview text instead of the summary text.' },
73
+ apply: { type: 'boolean', description: 'Apply the current import proposal into canonical memory.' },
74
+ uninstall: { type: 'boolean', description: 'Uninstall the last bootstrap-managed import.' },
75
+ interviewAnswers: {
76
+ type: 'array',
77
+ description: 'Optional structured interview answers. Each answer may include question_id, response_text, response_items, response_boolean, and explicit suggestions.',
78
+ items: { type: 'object' },
79
+ },
70
80
  },
71
81
  },
72
82
  },
@@ -506,6 +516,18 @@ export function createToolErrorResponse(kind, message, details) {
506
516
  },
507
517
  }, true);
508
518
  }
519
+ function normalizeBootstrapInterviewAnswersArg(value) {
520
+ if (!Array.isArray(value)) {
521
+ return [];
522
+ }
523
+ return value.map((entry) => BootstrapInterviewAnswerSchema.parse(entry));
524
+ }
525
+ function normalizeBootstrapInterviewAudienceArg(value) {
526
+ if (value === 'cli' || value === 'ide_chat' || value === 'any') {
527
+ return value;
528
+ }
529
+ return 'any';
530
+ }
509
531
  function requireObjectParams(params, id) {
510
532
  if (params === undefined) {
511
533
  return {};
@@ -1040,20 +1062,71 @@ export function handleMcpReadToolCall(name, args = {}, context = {}) {
1040
1062
  };
1041
1063
  }
1042
1064
  if (name === 'bclaw_bootstrap') {
1065
+ const interviewAnswers = normalizeBootstrapInterviewAnswersArg(args.interviewAnswers);
1066
+ if (args.apply && args.uninstall) {
1067
+ throw new Error('bclaw_bootstrap does not allow apply and uninstall at the same time.');
1068
+ }
1069
+ if (args.uninstall) {
1070
+ const result = uninstallBootstrapImport(cwd);
1071
+ const text = !result.receipt
1072
+ ? 'No bootstrap import receipt found.'
1073
+ : `Bootstrap uninstall completed: ${result.deactivatedCount} instruction(s) deactivated, ${result.deletedCount} artifact(s) deleted, ${result.skippedCount} artifact(s) skipped.`;
1074
+ return {
1075
+ content: [{ type: 'text', text }],
1076
+ structuredContent: {
1077
+ receipt: result.receipt,
1078
+ deactivated_count: result.deactivatedCount,
1079
+ deleted_count: result.deletedCount,
1080
+ skipped_count: result.skippedCount,
1081
+ },
1082
+ };
1083
+ }
1084
+ if (args.apply) {
1085
+ const applied = applyBootstrapImport({
1086
+ target: args.target,
1087
+ refresh: args.refresh,
1088
+ interviewAnswers,
1089
+ cwd,
1090
+ });
1091
+ return {
1092
+ content: [{
1093
+ type: 'text',
1094
+ text: `Bootstrap import applied: ${applied.createdCount} item(s) created, ${applied.skippedCount} suggestion(s) skipped.`,
1095
+ }],
1096
+ structuredContent: {
1097
+ created_count: applied.createdCount,
1098
+ skipped_count: applied.skippedCount,
1099
+ receipt: applied.receipt,
1100
+ import_plan: applied.proposal,
1101
+ },
1102
+ };
1103
+ }
1043
1104
  const result = runBootstrapProfile({
1044
1105
  target: args.target,
1045
1106
  refresh: args.refresh,
1107
+ interviewAnswers,
1046
1108
  cwd,
1047
1109
  });
1110
+ const audience = normalizeBootstrapInterviewAudienceArg(args.audience);
1111
+ const text = args.interview
1112
+ ? renderBootstrapInterview(result, audience)
1113
+ : renderBootstrapSummary(result);
1048
1114
  return {
1049
- content: [{ type: 'text', text: renderBootstrapSummary(result) }],
1115
+ content: [{ type: 'text', text }],
1050
1116
  structuredContent: {
1051
1117
  summary: result.profile.summary,
1052
1118
  target: result.profile.target,
1053
1119
  repo_fingerprint: result.profile.repo_fingerprint,
1054
1120
  sources_scanned: result.profile.sources_scanned,
1121
+ workspace_kind: result.profile.workspace_kind,
1122
+ onboarding_mode: result.profile.onboarding_mode,
1123
+ confidence: result.profile.confidence,
1124
+ native_instruction_files: result.profile.native_instruction_files,
1125
+ gaps: result.profile.gaps,
1055
1126
  seed_count: result.profile.seed_count,
1056
1127
  seeds: result.seeds,
1128
+ import_plan: result.importPlan,
1129
+ last_application: result.lastApplication,
1057
1130
  reused_profile: result.reusedProfile,
1058
1131
  },
1059
1132
  };