@arcbridge/core 0.2.0 → 0.3.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.
package/dist/index.d.ts CHANGED
@@ -933,6 +933,13 @@ declare function deleteTaskFromYaml(projectRoot: string, phaseId: string, taskId
933
933
  success: boolean;
934
934
  warning?: string;
935
935
  };
936
+ /**
937
+ * Delete a phase from phases.yaml and its associated task file.
938
+ */
939
+ declare function deletePhaseFromYaml(projectRoot: string, phaseId: string): {
940
+ success: boolean;
941
+ warning?: string;
942
+ };
936
943
 
937
944
  /**
938
945
  * Generate sync loop trigger files based on configured platforms.
@@ -1137,4 +1144,4 @@ declare function loadConfig(projectRoot: string): {
1137
1144
  error: string | null;
1138
1145
  };
1139
1146
 
1140
- export { type ActivityRow, type AdrFrontmatter, AdrFrontmatterSchema, type AgentRole, AgentRoleSchema, type AggregatedRow, type ArcBridgeConfig, ArcBridgeConfigSchema, type BuildingBlock, BuildingBlockSchema, type BuildingBlocksFrontmatter, BuildingBlocksFrontmatterSchema, CURRENT_SCHEMA_VERSION, type ChangedFile, type Database, type DotnetProjectInfo, type DriftEntry, type DriftKind, type DriftOptions, type DriftSeverity, type ExportFormat, type ExtractedSymbol, type GenerateDatabaseResult, type GitRef, type IndexResult, type IndexerOptions, type InitProjectInput, type InsertActivityParams, type LatestQualitySnapshot, type LoadRolesResult, type MetricsResult, type Phase, PhaseSchema, type PhasesFile, PhasesFileSchema, type ProjectLanguage, QualityCategorySchema, QualityPrioritySchema, type QualityScenario, QualityScenarioSchema, QualityScenarioStatusSchema, type QualityScenariosFile, QualityScenariosFileSchema, type QueryMetricsParams, type ScenarioTestResult, type Service, type SessionTotals, type SymbolKind, type Task, type TaskFile, TaskFileSchema, type TaskInferenceResult, TaskSchema, type TestOutcome, type VerifyResult, addPhaseToYaml, addTaskToYaml, applyInferences, deleteTaskFromYaml, detectDrift, detectProjectLanguage, discoverDotnetServices, exportMetrics, generateAgentRoles, generateArc42, generateConfig, generateDatabase, generatePlan, generateSyncFiles, getChangedFiles, getHeadSha, getSessionTotals, getUncommittedChanges, indexPackageDependencies, indexProject, inferTaskStatuses, initializeSchema, insertActivity, loadConfig, loadRole, loadRoles, migrate, openDatabase, openMemoryDatabase, queryMetrics, refreshFromDocs, resolveRef, scopeToProject, setSyncCommit, suppressSqliteWarning, syncPhaseToYaml, syncScenarioToYaml, syncTaskToYaml, transaction, verifyScenarios, writeDriftLog };
1147
+ export { type ActivityRow, type AdrFrontmatter, AdrFrontmatterSchema, type AgentRole, AgentRoleSchema, type AggregatedRow, type ArcBridgeConfig, ArcBridgeConfigSchema, type BuildingBlock, BuildingBlockSchema, type BuildingBlocksFrontmatter, BuildingBlocksFrontmatterSchema, CURRENT_SCHEMA_VERSION, type ChangedFile, type Database, type DotnetProjectInfo, type DriftEntry, type DriftKind, type DriftOptions, type DriftSeverity, type ExportFormat, type ExtractedSymbol, type GenerateDatabaseResult, type GitRef, type IndexResult, type IndexerOptions, type InitProjectInput, type InsertActivityParams, type LatestQualitySnapshot, type LoadRolesResult, type MetricsResult, type Phase, PhaseSchema, type PhasesFile, PhasesFileSchema, type ProjectLanguage, QualityCategorySchema, QualityPrioritySchema, type QualityScenario, QualityScenarioSchema, QualityScenarioStatusSchema, type QualityScenariosFile, QualityScenariosFileSchema, type QueryMetricsParams, type ScenarioTestResult, type Service, type SessionTotals, type SymbolKind, type Task, type TaskFile, TaskFileSchema, type TaskInferenceResult, TaskSchema, type TestOutcome, type VerifyResult, addPhaseToYaml, addTaskToYaml, applyInferences, deletePhaseFromYaml, deleteTaskFromYaml, detectDrift, detectProjectLanguage, discoverDotnetServices, exportMetrics, generateAgentRoles, generateArc42, generateConfig, generateDatabase, generatePlan, generateSyncFiles, getChangedFiles, getHeadSha, getSessionTotals, getUncommittedChanges, indexPackageDependencies, indexProject, inferTaskStatuses, initializeSchema, insertActivity, loadConfig, loadRole, loadRoles, migrate, openDatabase, openMemoryDatabase, queryMetrics, refreshFromDocs, resolveRef, scopeToProject, setSyncCommit, suppressSqliteWarning, syncPhaseToYaml, syncScenarioToYaml, syncTaskToYaml, transaction, verifyScenarios, writeDriftLog };
package/dist/index.js CHANGED
@@ -832,6 +832,41 @@ ${input.quality_priorities.map((q, i) => `| ${i + 1} | ${q} | *Describe what ${q
832
832
  };
833
833
  }
834
834
 
835
+ // src/templates/arc42/02-constraints.ts
836
+ function constraintsTemplate(input) {
837
+ return {
838
+ frontmatter: {
839
+ section: "constraints",
840
+ schema_version: 1
841
+ },
842
+ body: `# Architecture Constraints
843
+
844
+ Document the constraints that shape architectural decisions for ${input.name}. Constraints are non-negotiable requirements from the environment \u2014 they are not chosen, they are given.
845
+
846
+ ## Technical Constraints
847
+
848
+ | Constraint | Description |
849
+ |-----------|-------------|
850
+ | *e.g., Must run on Node.js 22+* | *Explain why this constraint exists* |
851
+ | *e.g., No native dependencies* | *Required for CI/CD compatibility* |
852
+
853
+ ## Organizational Constraints
854
+
855
+ | Constraint | Description |
856
+ |-----------|-------------|
857
+ | *e.g., Team of 1-2 developers* | *Impacts architecture complexity budget* |
858
+ | *e.g., Must ship MVP in 4 weeks* | *Impacts scope and technology choices* |
859
+
860
+ ## Legal / Compliance Constraints
861
+
862
+ | Constraint | Description |
863
+ |-----------|-------------|
864
+ | *e.g., GDPR compliance required* | *Impacts data storage and processing* |
865
+ | *e.g., MIT-compatible dependencies only* | *Impacts library selection* |
866
+ `
867
+ };
868
+ }
869
+
835
870
  // src/templates/arc42/03-context.ts
836
871
  function techStack(template) {
837
872
  switch (template) {
@@ -887,6 +922,47 @@ ${techStack(input.template)}
887
922
  };
888
923
  }
889
924
 
925
+ // src/templates/arc42/04-solution-strategy.ts
926
+ function solutionStrategyTemplate(input) {
927
+ return {
928
+ frontmatter: {
929
+ section: "solution-strategy",
930
+ schema_version: 1
931
+ },
932
+ body: `# Solution Strategy
933
+
934
+ Document the fundamental decisions and solution approaches that drive the architecture of ${input.name}. This section explains *why* the architecture looks the way it does \u2014 connecting quality goals to technical decisions.
935
+
936
+ ## Technology Decisions
937
+
938
+ | Decision | Rationale | Quality Goal |
939
+ |----------|-----------|-------------|
940
+ | *e.g., Use TypeScript* | *Type safety reduces runtime errors* | *Reliability, Maintainability* |
941
+ | *e.g., Use SQLite for local storage* | *Zero-config, no external service dependency* | *Maintainability* |
942
+
943
+ ## Architecture Approach
944
+
945
+ *Describe the high-level architecture pattern and why it was chosen.*
946
+
947
+ - *e.g., Layered architecture with clear module boundaries (enforced by ArcBridge building blocks)*
948
+ - *e.g., YAML as source of truth, DB as queryable cache \u2014 enables version control and human readability*
949
+
950
+ ## Quality Goal Strategies
951
+
952
+ | Quality Goal | Strategy |
953
+ |-------------|----------|
954
+ ${input.quality_priorities.map((q) => `| ${q} | *How will you achieve ${q}?* |`).join("\n")}
955
+
956
+ ## Decomposition Approach
957
+
958
+ *How is the system broken down into building blocks? What principles guide the decomposition?*
959
+
960
+ - *e.g., Feature-based: each major feature is a building block with clear interfaces*
961
+ - *e.g., Layer-based: presentation, business logic, data access*
962
+ `
963
+ };
964
+ }
965
+
890
966
  // src/templates/arc42/05-building-blocks.ts
891
967
  import { existsSync as existsSync2, readdirSync } from "fs";
892
968
  import { join as join3 } from "path";
@@ -2297,7 +2373,9 @@ function generateArc42(targetDir, input) {
2297
2373
  mkdirSync2(decisionsDir, { recursive: true });
2298
2374
  const sections = [
2299
2375
  { file: "01-introduction.md", template: introductionTemplate },
2376
+ { file: "02-constraints.md", template: constraintsTemplate },
2300
2377
  { file: "03-context.md", template: contextTemplate },
2378
+ { file: "04-solution-strategy.md", template: solutionStrategyTemplate },
2301
2379
  { file: "05-building-blocks.md", template: buildingBlocksTemplate },
2302
2380
  { file: "06-runtime-views.md", template: runtimeViewsTemplate },
2303
2381
  { file: "07-deployment.md", template: deploymentTemplate },
@@ -2335,7 +2413,7 @@ function phasePlanTemplate(_input) {
2335
2413
  id: "phase-0-setup",
2336
2414
  name: "Project Setup",
2337
2415
  phase_number: 0,
2338
- status: "in-progress",
2416
+ status: "planned",
2339
2417
  description: "Initialize project structure, install dependencies, configure tooling",
2340
2418
  gate_requirements: [
2341
2419
  "Project builds successfully",
@@ -2600,7 +2678,7 @@ function phasePlanTemplate2(_input) {
2600
2678
  id: "phase-0-setup",
2601
2679
  name: "Project Setup",
2602
2680
  phase_number: 0,
2603
- status: "in-progress",
2681
+ status: "planned",
2604
2682
  description: "Initialize Vite + React project, configure TypeScript, install dependencies",
2605
2683
  gate_requirements: [
2606
2684
  "Project builds successfully with Vite",
@@ -2866,7 +2944,7 @@ function phasePlanTemplate3(_input) {
2866
2944
  id: "phase-0-setup",
2867
2945
  name: "Project Setup",
2868
2946
  phase_number: 0,
2869
- status: "in-progress",
2947
+ status: "planned",
2870
2948
  description: "Initialize API service, configure TypeScript, set up database and middleware",
2871
2949
  gate_requirements: [
2872
2950
  "Project builds successfully",
@@ -3049,7 +3127,7 @@ function phasePlanTemplate4(_input) {
3049
3127
  id: "phase-0-setup",
3050
3128
  name: "Project Setup",
3051
3129
  phase_number: 0,
3052
- status: "in-progress",
3130
+ status: "planned",
3053
3131
  description: "Initialize ASP.NET Core project, configure DI, set up database and middleware pipeline",
3054
3132
  gate_requirements: [
3055
3133
  "Project builds and runs successfully",
@@ -3248,7 +3326,7 @@ function phasePlanTemplate5(_input) {
3248
3326
  id: "phase-0-setup",
3249
3327
  name: "Project Setup",
3250
3328
  phase_number: 0,
3251
- status: "in-progress",
3329
+ status: "planned",
3252
3330
  description: "Initialize Unity project structure, configure input system, core game loop, and assembly definitions",
3253
3331
  gate_requirements: [
3254
3332
  "Unity project opens and runs without errors",
@@ -3533,7 +3611,9 @@ You are responsible for maintaining these sections in \`.arcbridge/arc42/\`. Upd
3533
3611
  | Section | File | When to update |
3534
3612
  |---------|------|----------------|
3535
3613
  | **01 Introduction & Goals** | \`01-introduction.md\` | When project scope, stakeholders, or key goals change |
3614
+ | **02 Architecture Constraints** | \`02-constraints.md\` | When new constraints are discovered (technical, organizational, legal) |
3536
3615
  | **03 Context & Scope** | \`03-context.md\` | When adding/removing external systems, APIs, or integrations |
3616
+ | **04 Solution Strategy** | \`04-solution-strategy.md\` | When fundamental technology or architecture decisions change |
3537
3617
  | **05 Building Blocks** | \`05-building-blocks.md\` | When adding new modules, changing responsibilities, or restructuring layers |
3538
3618
  | **06 Runtime Views** | \`06-runtime-views.md\` | When adding key workflows (e.g., auth flow, order processing, data sync) |
3539
3619
  | **07 Deployment** | \`07-deployment.md\` | When changing infrastructure, environments, or deployment strategy |
@@ -3557,14 +3637,41 @@ You are responsible for maintaining these sections in \`.arcbridge/arc42/\`. Upd
3557
3637
  - All ADRs and their status
3558
3638
  - Building block \u2192 code mapping
3559
3639
 
3640
+ ## Post-Init Tailoring (CRITICAL \u2014 Do This Before Writing Code)
3641
+
3642
+ The building blocks, quality scenarios, and phase tasks generated during init are a **generic starting template**, not a project-specific plan. Before writing any code, systematically tailor the generated content to the actual project:
3643
+
3644
+ 1. **Building blocks:** Review each generated block against the project description. Delete blocks that don't apply (e.g., "API Client" for a client-only app). Add blocks for the real modules/features you'll build. **Declare interfaces between blocks** to specify dependencies \u2014 drift detection and phase gates rely on this.
3645
+ 2. **Quality scenarios:** Review each scenario against the project's quality priorities. Delete irrelevant ones (e.g., "API response time" for a localStorage-only app). Add scenarios that reflect the actual requirements.
3646
+ 3. **Phase tasks:** Phase 0-1 tasks are ready to use. **Phase 2+ tasks are examples \u2014 delete them** and create tasks that match the features you're actually building. Keep phases small and focused (3-6 tasks per phase). Add more phases if needed using \`arcbridge_create_phase\` \u2014 6, 8, or 10 phases is fine for larger projects.
3647
+ 4. **Reindex** after making changes so drift detection picks up your tailored architecture.
3648
+
3649
+ The goal is that by the time you start Phase 0, the building blocks describe your architecture, the quality scenarios test your requirements, and the tasks reflect your build plan.
3650
+
3651
+ ### Building Block interfaces
3652
+
3653
+ Each building block in \`05-building-blocks.md\` should declare its dependencies on other blocks using the \`interfaces\` field. This is required for drift detection to catch undeclared cross-block dependencies at phase gates.
3654
+
3655
+ Format \u2014 within the \`blocks:\` array, list the IDs of other blocks this block depends on:
3656
+ \`\`\`yaml
3657
+ blocks:
3658
+ - id: canvas-engine
3659
+ name: Canvas Engine
3660
+ level: 1
3661
+ responsibility: "Render and manage collaborative canvas state"
3662
+ service: main
3663
+ code_paths:
3664
+ - "src/canvas/"
3665
+ interfaces:
3666
+ - workflow-model
3667
+ - shared-types
3668
+ \`\`\`
3669
+
3670
+ If your code imports across block boundaries without declaring the interface, \`arcbridge_check_drift\` will flag it and \`arcbridge_complete_phase\` will block the gate.
3671
+
3560
3672
  ## Project Planning
3561
3673
 
3562
- At the start of a project (after init), plan the full roadmap:
3563
- - **ArcBridge generates 4 phases as a starting template** (Setup, Foundation, Features, Polish). These are a baseline \u2014 adapt them to your project's actual scope and complexity.
3564
- - **For larger projects, add more phases** using \`arcbridge_create_phase\`. Split "Core Features" into multiple phases if needed (e.g., "Auth & Users", "Core Business Logic", "Integrations", "Polish").
3565
- - **Phase 0-1 tasks are ready to use** \u2014 they cover setup and foundation for this template
3566
- - **Phase 2+ tasks are examples** \u2014 replace them with real tasks derived from the project's requirements and specifications
3567
- - Review the phase plan with \`arcbridge_get_phase_plan\` and replace example tasks with project-specific ones
3674
+ - Review the phase plan with \`arcbridge_get_phase_plan\`
3568
3675
  - Create tasks using \`arcbridge_create_task\` with the phase ID shown in the plan
3569
3676
  - Keep each phase reasonably scoped \u2014 3-6 tasks per phase is ideal
3570
3677
  - Map tasks to building blocks so drift detection tracks coverage
@@ -7171,7 +7278,7 @@ function safeParseJson(value, fallback) {
7171
7278
 
7172
7279
  // src/sync/yaml-writer.ts
7173
7280
  import { join as join15 } from "path";
7174
- import { existsSync as existsSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5 } from "fs";
7281
+ import { existsSync as existsSync8, readFileSync as readFileSync8, writeFileSync as writeFileSync5, mkdirSync as mkdirSync5, unlinkSync } from "fs";
7175
7282
  import { parse as parse2, stringify as stringify4 } from "yaml";
7176
7283
  function syncTaskToYaml(projectRoot, phaseId, taskId, status, completedAt) {
7177
7284
  const taskPath = join15(
@@ -7355,6 +7462,41 @@ function deleteTaskFromYaml(projectRoot, phaseId, taskId) {
7355
7462
  };
7356
7463
  }
7357
7464
  }
7465
+ function deletePhaseFromYaml(projectRoot, phaseId) {
7466
+ try {
7467
+ const phasesPath = join15(projectRoot, ".arcbridge", "plan", "phases.yaml");
7468
+ if (!existsSync8(phasesPath)) {
7469
+ return { success: false, warning: "phases.yaml not found" };
7470
+ }
7471
+ const raw = readFileSync8(phasesPath, "utf-8");
7472
+ const result = PhasesFileSchema.safeParse(parse2(raw));
7473
+ if (!result.success) {
7474
+ return {
7475
+ success: false,
7476
+ warning: "Could not parse phases.yaml \u2014 phase may reappear after reindex"
7477
+ };
7478
+ }
7479
+ const phasesFile = result.data;
7480
+ const before = phasesFile.phases.length;
7481
+ phasesFile.phases = phasesFile.phases.filter((p) => p.id !== phaseId);
7482
+ if (phasesFile.phases.length === before) {
7483
+ return { success: false, warning: `Phase '${phaseId}' not found in phases.yaml` };
7484
+ }
7485
+ writeFileSync5(phasesPath, stringify4(phasesFile), "utf-8");
7486
+ const taskFilePath = join15(projectRoot, ".arcbridge", "plan", "tasks", `${phaseId}.yaml`);
7487
+ try {
7488
+ unlinkSync(taskFilePath);
7489
+ } catch (e) {
7490
+ if (e.code !== "ENOENT") throw e;
7491
+ }
7492
+ return { success: true };
7493
+ } catch (err) {
7494
+ return {
7495
+ success: false,
7496
+ warning: `YAML update failed: ${err instanceof Error ? err.message : String(err)}`
7497
+ };
7498
+ }
7499
+ }
7358
7500
 
7359
7501
  // src/sync/task-inference.ts
7360
7502
  function inferTaskStatuses(db, phaseId) {
@@ -8332,6 +8474,7 @@ export {
8332
8474
  addPhaseToYaml,
8333
8475
  addTaskToYaml,
8334
8476
  applyInferences,
8477
+ deletePhaseFromYaml,
8335
8478
  deleteTaskFromYaml,
8336
8479
  detectDrift,
8337
8480
  detectProjectLanguage,