agentblueprint 0.7.17 → 0.7.19

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.
package/dist/renderers.js CHANGED
@@ -60,6 +60,9 @@ function arr(val) {
60
60
  function rec(val) {
61
61
  return val && typeof val === 'object' && !Array.isArray(val) ? val : {};
62
62
  }
63
+ function jsonTemplate(value) {
64
+ return `${JSON.stringify(value, null, 2)}\n`;
65
+ }
63
66
  /** Returns string representation for numbers, passes through strings, '' otherwise */
64
67
  function numStr(val) {
65
68
  if (typeof val === 'number')
@@ -72,6 +75,24 @@ function numStr(val) {
72
75
  function isPlaceholder(val) {
73
76
  return ['—', '–', '-', 'N/A', 'n/a', 'TBD', 'null', 'undefined', 'none'].includes(val.trim());
74
77
  }
78
+ /** Checks if the business profile has minimal data (fewer than 3 meaningful fields populated) */
79
+ function isProfileSparse(bp) {
80
+ if (!bp)
81
+ return true;
82
+ const meaningfulFields = ['industry', 'size', 'revenue', 'description',
83
+ 'technologyProfile', 'organizationalCapabilities', 'businessOperations', 'constraintsProfile'];
84
+ const populated = meaningfulFields.filter(f => {
85
+ const val = bp[f];
86
+ if (!val)
87
+ return false;
88
+ if (typeof val === 'string' && val.trim() === '')
89
+ return false;
90
+ if (typeof val === 'object' && Object.keys(val).length === 0)
91
+ return false;
92
+ return true;
93
+ });
94
+ return populated.length < 3;
95
+ }
75
96
  /** Strips a trailing unit suffix to prevent double-units (e.g. "3.6 months" + " months") */
76
97
  function stripTrailingUnit(val, unit) {
77
98
  return val.replace(new RegExp(`\\s*${unit}\\s*$`, 'i'), '');
@@ -1564,6 +1585,21 @@ function buildGettingStartedReturnVisit(input) {
1564
1585
  lines.push('Direct record or API edits are best for existing deployments, live tuning,');
1565
1586
  lines.push('or blocked packaging paths. Document fallback reasons in blueprint-local `PROGRESS.md`.');
1566
1587
  lines.push('');
1588
+ lines.push('## Maintain the business profile and artifacts');
1589
+ lines.push('');
1590
+ lines.push('Markdown files are readable snapshots. MCP/CLI writes are the source of truth.');
1591
+ lines.push('When implementation reveals new profile facts or artifact corrections, update');
1592
+ lines.push('Agent Blueprint with a focused patch:');
1593
+ lines.push('');
1594
+ lines.push('1. Read the current markdown context in `references/` and `CURRENT-STATE.md`');
1595
+ lines.push('2. Fill in the matching template in `editable/*.json`');
1596
+ lines.push('3. Call the matching MCP write tool, such as `update_business_profile`,');
1597
+ lines.push(' `update_use_case`, `update_blueprint`, `update_business_case`, or');
1598
+ lines.push(' `update_implementation_plan`');
1599
+ lines.push('4. Re-download this export after staleness changes or recalculations');
1600
+ lines.push('');
1601
+ lines.push('See `references/artifact-editing.md` for the full workflow and tool mapping.');
1602
+ lines.push('');
1567
1603
  lines.push('For the next pilot slice or agent:');
1568
1604
  lines.push('1. Review the spec in `SKILL.md` and `references/agent-specifications.md`');
1569
1605
  lines.push('2. Build the smallest executable slice that proves a useful path');
@@ -1681,6 +1717,37 @@ function buildGettingStarted(input) {
1681
1717
  lines.push(staleWarnings);
1682
1718
  lines.push('');
1683
1719
  }
1720
+ // Phase 0: Profile interview (only when profile is sparse and base skill is present)
1721
+ if (isProfileSparse(input.businessProfileData) && input.baseSkill) {
1722
+ lines.push('## Phase 0: Build your organization profile');
1723
+ lines.push('');
1724
+ lines.push('Organization context is incomplete. Before deploying agents, build a');
1725
+ lines.push('comprehensive business profile using the interview protocol:');
1726
+ lines.push('');
1727
+ lines.push('1. Read `.claude/skills/agent-blueprint/references/INTERVIEW_PROTOCOL.md`');
1728
+ lines.push('2. Follow the document-first approach: gather existing docs, extract, then interview for gaps');
1729
+ lines.push('3. Output structured JSON for platform sync, or rewrite `references/organization-context.md` locally');
1730
+ lines.push('');
1731
+ lines.push('A richer profile produces better-tailored agent recommendations and more accurate financial projections.');
1732
+ lines.push('');
1733
+ }
1734
+ lines.push('## Maintain the business profile');
1735
+ lines.push('');
1736
+ lines.push('If you learn new facts while implementing, update Agent Blueprint instead of');
1737
+ lines.push('only editing local markdown snapshots.');
1738
+ lines.push('');
1739
+ lines.push('1. Read `references/organization-context.md` and the current implementation context');
1740
+ lines.push('2. Fill in `editable/business-profile.update.json` with only verified changes');
1741
+ lines.push('3. Call the `update_business_profile` MCP tool with the `fields` object');
1742
+ lines.push('4. Re-download this export when staleness changes affect downstream artifacts');
1743
+ lines.push('');
1744
+ lines.push('## Ad-hoc artifact edits');
1745
+ lines.push('');
1746
+ lines.push('Markdown files are readable snapshots. MCP/CLI writes are the source of truth.');
1747
+ lines.push('For piecemeal edits to use cases, blueprints, business cases, or implementation');
1748
+ lines.push('plans, follow `references/artifact-editing.md` and use the templates in');
1749
+ lines.push('`editable/*.json`.');
1750
+ lines.push('');
1684
1751
  // Step 1
1685
1752
  lines.push('## Step 1: Understand the architecture');
1686
1753
  lines.push('');
@@ -2077,6 +2144,281 @@ function buildPlatformConnectivity() {
2077
2144
  return lines.join('\n');
2078
2145
  }
2079
2146
  // =============================================================================
2147
+ // ARTIFACT EDITING REFERENCE + JSON TEMPLATES
2148
+ // =============================================================================
2149
+ function buildArtifactEditingReference(input) {
2150
+ const lines = [
2151
+ '# Artifact Editing Reference',
2152
+ '',
2153
+ '> Markdown files in this export are readable snapshots. Agent Blueprint MCP/CLI',
2154
+ '> writes are the source of truth for saved changes.',
2155
+ '',
2156
+ `Blueprint ID: \`${input.blueprintId}\``,
2157
+ '',
2158
+ '## Workflow',
2159
+ '',
2160
+ '1. Read the current markdown context in `references/` and `SKILL.md`.',
2161
+ '2. Prepare a focused JSON patch using the matching file in `editable/`.',
2162
+ '3. Call the matching MCP write tool with only the fields or sections that changed.',
2163
+ '4. If the tool reports downstream staleness, refresh the affected artifact before relying on it.',
2164
+ '5. Re-download this blueprint export after important changes so local markdown snapshots match Agent Blueprint.',
2165
+ '',
2166
+ 'Do not edit markdown snapshots as the canonical record. Local markdown edits are notes only unless they are written back through MCP or CLI.',
2167
+ '',
2168
+ '## Tool Mapping',
2169
+ '',
2170
+ '| Change area | Template | Write tool |',
2171
+ '|-------------|----------|------------|',
2172
+ '| Profile facts, systems, capabilities, operations, constraints | `editable/business-profile.update.json` | `update_business_profile` |',
2173
+ '| Use case, pain points, outcomes, success metrics | `editable/use-case.update.json` | `update_use_case` |',
2174
+ '| Agent team, architecture, phases, success criteria | `editable/blueprint.update.json` | `update_blueprint` |',
2175
+ '| ROI narrative, benefits, risks, recommendation | `editable/business-case.update.json` | `update_business_case`, then `recalculate_financials` when numbers need refresh |',
2176
+ '| Implementation sequencing, epics, resources, agent specs | `editable/implementation-plan.update.json` | `update_implementation_plan` |',
2177
+ '',
2178
+ '## Patch Rules',
2179
+ '',
2180
+ '- Keep patches small. Include only the top-level fields or sections you intend to change.',
2181
+ '- Delete placeholder keys before submitting if you are not changing them.',
2182
+ '- Preserve IDs, agent names, phase names, and metric names unless the user explicitly asks to rename them.',
2183
+ '- For financial narrative edits, call `update_business_case` first. Call `recalculate_financials` only when numeric assumptions or ROI inputs changed.',
2184
+ '- Unknown keys may be ignored or preserved depending on the endpoint. Prefer the keys shown in the templates.',
2185
+ '',
2186
+ '## MCP Examples',
2187
+ '',
2188
+ 'Business profile:',
2189
+ '',
2190
+ '```json',
2191
+ '{',
2192
+ ' "fields": {',
2193
+ ' "companyName": "Replace with verified company name",',
2194
+ ' "technology": { "systems": [] }',
2195
+ ' }',
2196
+ '}',
2197
+ '```',
2198
+ '',
2199
+ 'Blueprint section:',
2200
+ '',
2201
+ '```json',
2202
+ '{',
2203
+ ` "blueprintId": "${input.blueprintId}",`,
2204
+ ' "sections": {',
2205
+ ' "executiveSummary": "Replace with the revised summary"',
2206
+ ' }',
2207
+ '}',
2208
+ '```',
2209
+ '',
2210
+ 'After a successful write, inspect the response for `downstreamStale` or staleness warnings. Refresh or recalculate those artifacts before treating the export as current.',
2211
+ ];
2212
+ return lines.join('\n');
2213
+ }
2214
+ function buildBusinessProfileUpdateTemplate() {
2215
+ return jsonTemplate({
2216
+ _instructions: 'Replace placeholders, delete unused keys, then call update_business_profile with the fields object. Use only verified facts.',
2217
+ fields: {
2218
+ companyName: '<replace with verified company name>',
2219
+ industry: '<replace with industry>',
2220
+ size: '<replace with employee or company size>',
2221
+ revenue: '<replace with revenue range if known>',
2222
+ currency: 'USD',
2223
+ description: '<replace with concise business description>',
2224
+ companyWebsite: '<replace with company website>',
2225
+ technology: {
2226
+ systems: [
2227
+ {
2228
+ name: '<replace with system name>',
2229
+ category: '<replace with system category>',
2230
+ criticality: '<replace with criticality>',
2231
+ },
2232
+ ],
2233
+ },
2234
+ capabilities: {
2235
+ technicalTeam: {
2236
+ developmentCapacity: '<replace with capacity if known>',
2237
+ aiMlExperience: '<replace with AI/ML experience level>',
2238
+ },
2239
+ },
2240
+ operations: {
2241
+ keyProcesses: [
2242
+ {
2243
+ name: '<replace with process name>',
2244
+ volume: '<replace with process volume if known>',
2245
+ },
2246
+ ],
2247
+ painPoints: ['<replace with operational pain point>'],
2248
+ },
2249
+ constraints: {
2250
+ budget: {
2251
+ totalAiBudget: '<replace with budget if known>',
2252
+ },
2253
+ timeline: {
2254
+ preferredTimeline: '<replace with timeline if known>',
2255
+ },
2256
+ },
2257
+ strategicInitiatives: [
2258
+ {
2259
+ title: '<replace with initiative title>',
2260
+ description: '<replace with initiative description>',
2261
+ },
2262
+ ],
2263
+ },
2264
+ });
2265
+ }
2266
+ function buildUseCaseUpdateTemplate(input) {
2267
+ return jsonTemplate({
2268
+ _instructions: 'Replace placeholders, delete unused sections, then call update_use_case with blueprintId and sections.',
2269
+ blueprintId: input.blueprintId,
2270
+ sections: {
2271
+ title: '<replace with use case title>',
2272
+ description: '<replace with concise use case description>',
2273
+ businessChallenge: '<replace with updated business challenge>',
2274
+ description5Ws: {
2275
+ who: '<replace with impacted people or teams>',
2276
+ what: '<replace with work being changed>',
2277
+ where: '<replace with business area or systems>',
2278
+ when: '<replace with timing or trigger>',
2279
+ why: '<replace with reason this matters>',
2280
+ },
2281
+ currentPainPoints: ['<replace with pain point>'],
2282
+ desiredBusinessOutcomes: ['<replace with desired outcome>'],
2283
+ processDocumentation: {
2284
+ steps: [
2285
+ {
2286
+ stepNumber: 1,
2287
+ description: '<replace with current process step>',
2288
+ performer: '<replace with performer>',
2289
+ },
2290
+ ],
2291
+ },
2292
+ transformationStory: {
2293
+ situation: '<replace with current situation>',
2294
+ complication: '<replace with complication>',
2295
+ resolution: '<replace with desired resolution>',
2296
+ },
2297
+ typedSuccessMetrics: [
2298
+ {
2299
+ metric: '<replace with metric name>',
2300
+ target: '<replace with target>',
2301
+ },
2302
+ ],
2303
+ organizationalConstraints: ['<replace with constraint>'],
2304
+ affectedDepartments: ['<replace with department>'],
2305
+ },
2306
+ });
2307
+ }
2308
+ function buildBlueprintUpdateTemplate(input) {
2309
+ return jsonTemplate({
2310
+ _instructions: 'Replace placeholders, delete unused sections, then call update_blueprint with blueprintId and sections. Top-level sections are shallow-merged.',
2311
+ blueprintId: input.blueprintId,
2312
+ sections: {
2313
+ executiveSummary: '<replace with revised executive summary>',
2314
+ agenticPattern: '<replace with agentic pattern if changed>',
2315
+ enhancedDigitalTeam: [
2316
+ {
2317
+ name: '<replace with agent name>',
2318
+ role: '<replace with agent role>',
2319
+ agentRole: '<replace with orchestration role>',
2320
+ responsibilities: ['<replace with responsibility>'],
2321
+ },
2322
+ ],
2323
+ phases: [
2324
+ {
2325
+ name: '<replace with phase name>',
2326
+ phaseGoal: '<replace with phase goal>',
2327
+ durationWeeks: '<replace with duration in weeks>',
2328
+ },
2329
+ ],
2330
+ architectureRationale: {
2331
+ whyAgentic: ['<replace with rationale>'],
2332
+ },
2333
+ successCriteria: {
2334
+ kpis: [
2335
+ {
2336
+ name: '<replace with KPI name>',
2337
+ target: '<replace with target>',
2338
+ },
2339
+ ],
2340
+ },
2341
+ },
2342
+ });
2343
+ }
2344
+ function buildBusinessCaseUpdateTemplate(input) {
2345
+ return jsonTemplate({
2346
+ _instructions: 'Replace placeholders, delete unused sections, then call update_business_case with blueprintId and sections. If numeric assumptions or ROI inputs changed, call recalculate_financials next.',
2347
+ blueprintId: input.blueprintId,
2348
+ sections: {
2349
+ executiveSummary: {
2350
+ purpose: '<replace with revised purpose>',
2351
+ valueProposition: '<replace with revised value proposition>',
2352
+ },
2353
+ businessContext: {
2354
+ problemStatement: '<replace with updated problem statement>',
2355
+ },
2356
+ objectives: {
2357
+ successMetrics: [
2358
+ {
2359
+ metric: '<replace with metric name>',
2360
+ targetValue: '<replace with target value>',
2361
+ },
2362
+ ],
2363
+ },
2364
+ proposedSolution: {
2365
+ summary: '<replace with solution summary>',
2366
+ },
2367
+ benefits: {
2368
+ tangibleBenefits: {
2369
+ processEfficiency: '<replace with benefit>',
2370
+ },
2371
+ },
2372
+ risks: {
2373
+ implementationRisks: [
2374
+ {
2375
+ title: '<replace with risk title>',
2376
+ severity: '<replace with severity>',
2377
+ impact: '<replace with impact>',
2378
+ },
2379
+ ],
2380
+ },
2381
+ recommendation: {
2382
+ summary: '<replace with recommendation>',
2383
+ },
2384
+ },
2385
+ });
2386
+ }
2387
+ function buildImplementationPlanUpdateTemplate(input) {
2388
+ return jsonTemplate({
2389
+ _instructions: 'Replace placeholders, delete unused sections, then call update_implementation_plan with blueprintId and sections.',
2390
+ blueprintId: input.blueprintId,
2391
+ sections: {
2392
+ projectOverview: {
2393
+ summary: '<replace with updated implementation summary>',
2394
+ },
2395
+ epics: [
2396
+ {
2397
+ name: '<replace with epic name>',
2398
+ description: '<replace with epic description>',
2399
+ phase: '<replace with phase>',
2400
+ },
2401
+ ],
2402
+ dependencies: ['<replace with dependency>'],
2403
+ resources: {
2404
+ team: ['<replace with required role or team>'],
2405
+ },
2406
+ risks: [
2407
+ {
2408
+ title: '<replace with implementation risk>',
2409
+ mitigation: '<replace with mitigation>',
2410
+ },
2411
+ ],
2412
+ agentSpecifications: [
2413
+ {
2414
+ name: '<replace with agent name>',
2415
+ implementationNotes: '<replace with implementation notes>',
2416
+ },
2417
+ ],
2418
+ },
2419
+ });
2420
+ }
2421
+ // =============================================================================
2080
2422
  // IMPLEMENTATION STATE TEMPLATE
2081
2423
  // =============================================================================
2082
2424
  function buildImplementationState(input) {
@@ -2371,6 +2713,31 @@ function buildAgentsMd(input) {
2371
2713
  lines.push('');
2372
2714
  lines.push(` ${bpId}`);
2373
2715
  lines.push('');
2716
+ lines.push('## Source of truth for edits');
2717
+ lines.push('');
2718
+ lines.push('Markdown files in this export are readable snapshots. Agent Blueprint MCP/CLI');
2719
+ lines.push('writes are the source of truth for saved profile and artifact changes.');
2720
+ lines.push('Use `references/artifact-editing.md` and `editable/*.json` to prepare focused');
2721
+ lines.push('patches, then write them back with MCP tools.');
2722
+ lines.push('');
2723
+ lines.push('## Maintain the business profile');
2724
+ lines.push('');
2725
+ lines.push('When you discover new profile facts, systems, capabilities, operations,');
2726
+ lines.push('constraints, or strategic initiatives:');
2727
+ lines.push('1. Read `references/organization-context.md`');
2728
+ lines.push('2. Fill in `editable/business-profile.update.json`');
2729
+ lines.push('3. Call `update_business_profile` with the `fields` object');
2730
+ lines.push('4. Re-download or refresh stale artifacts before continuing');
2731
+ lines.push('');
2732
+ lines.push('## Ad-hoc artifact edits');
2733
+ lines.push('');
2734
+ lines.push('For piecemeal corrections, use the matching template and MCP write tool:');
2735
+ lines.push('- Use case changes: `editable/use-case.update.json` -> `update_use_case`');
2736
+ lines.push('- Blueprint changes: `editable/blueprint.update.json` -> `update_blueprint`');
2737
+ lines.push('- Business case changes: `editable/business-case.update.json` -> `update_business_case`');
2738
+ lines.push('- Financial number changes: `update_business_case`, then `recalculate_financials`');
2739
+ lines.push('- Implementation plan changes: `editable/implementation-plan.update.json` -> `update_implementation_plan`');
2740
+ lines.push('');
2374
2741
  lines.push('## When to sync implementation state');
2375
2742
  lines.push('');
2376
2743
  lines.push('Sync after each of these events:');
@@ -2659,6 +3026,13 @@ export function renderSkillDirectory(input) {
2659
3026
  files.set('references/guardrails-and-governance.md', buildGuardrailsAndGovernance(input));
2660
3027
  files.set('references/evaluation-criteria.md', buildEvaluationCriteria(input));
2661
3028
  files.set('references/platform-connectivity.md', buildPlatformConnectivity());
3029
+ files.set('references/artifact-editing.md', buildArtifactEditingReference(input));
3030
+ // Editable JSON helper templates (not canonical state)
3031
+ files.set('editable/business-profile.update.json', buildBusinessProfileUpdateTemplate());
3032
+ files.set('editable/use-case.update.json', buildUseCaseUpdateTemplate(input));
3033
+ files.set('editable/blueprint.update.json', buildBlueprintUpdateTemplate(input));
3034
+ files.set('editable/business-case.update.json', buildBusinessCaseUpdateTemplate(input));
3035
+ files.set('editable/implementation-plan.update.json', buildImplementationPlanUpdateTemplate(input));
2662
3036
  // Getting Started guide
2663
3037
  files.set('GETTING-STARTED.md', buildGettingStarted(input));
2664
3038
  // Sync rules (universal -- all coding agents via AGENTS.md standard)