substrate-ai 0.1.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.
@@ -0,0 +1,72 @@
1
+ # Substrate Task Graph — Parallel Template
2
+ # A set of tasks that all run concurrently.
3
+ #
4
+ # All tasks below have no dependencies (depends_on: []), so they all start
5
+ # simultaneously when the orchestration session begins.
6
+ # Each task is assigned to a different agent to illustrate per-task agent routing.
7
+
8
+ # version: format version for compatibility tracking with Substrate.
9
+ version: "1.0"
10
+
11
+ # session: configuration that applies to the entire orchestration run.
12
+ session:
13
+ # name: human-readable label for this session.
14
+ name: parallel-workflow
15
+ # base_branch: the git branch that all agent worktrees branch from.
16
+ base_branch: main
17
+
18
+ tasks:
19
+ # All four tasks below start simultaneously (no depends_on).
20
+ # Each runs in its own git worktree so they don't conflict.
21
+ feature-auth:
22
+ name: "Implement Authentication"
23
+ description: "Implement user authentication module"
24
+ # agent: claude-code handles general TypeScript/JavaScript tasks well.
25
+ agent: claude-code
26
+ # type: categorizes the task. Options: coding, testing, docs, debugging, refactoring
27
+ type: coding
28
+ # prompt: the full instruction sent to the agent.
29
+ prompt: |
30
+ Implement the authentication module at src/auth/.
31
+ Include login, logout, and JWT token validation.
32
+ Write unit tests alongside the implementation.
33
+ # depends_on: empty list means this task starts immediately.
34
+ depends_on: []
35
+
36
+ feature-api:
37
+ name: "Implement REST API"
38
+ description: "Implement REST API endpoints"
39
+ # agent: codex illustrates using a different agent for a different task.
40
+ # Each task can specify a different agent — useful for specialization.
41
+ agent: codex
42
+ type: coding
43
+ prompt: |
44
+ Implement the REST API endpoints defined in docs/api-spec.yaml.
45
+ Use Express.js and add OpenAPI documentation comments.
46
+ Ensure all endpoints have proper error handling and input validation.
47
+ depends_on: []
48
+
49
+ feature-ui:
50
+ name: "Implement UI Components"
51
+ description: "Implement frontend UI components"
52
+ # agent: gemini illustrates yet another agent choice.
53
+ agent: gemini
54
+ type: coding
55
+ prompt: |
56
+ Create the React UI components for the dashboard.
57
+ Use the design mockups in docs/mockups/ as reference.
58
+ Follow the existing component patterns in src/components/.
59
+ depends_on: []
60
+
61
+ feature-db:
62
+ name: "Set Up Database Schema"
63
+ description: "Set up database schema and migrations"
64
+ # agent: auto means the routing engine picks the best available agent
65
+ # based on the current routing policy and agent availability.
66
+ agent: auto
67
+ type: coding
68
+ prompt: |
69
+ Create the database schema and migration files.
70
+ Use the entity definitions in docs/data-model.md.
71
+ Ensure migrations are idempotent and reversible.
72
+ depends_on: []
@@ -0,0 +1,103 @@
1
+ # Substrate Task Graph — Research Then Implement Template
2
+ # Pattern: parallel research → synthesize → parallel implementation
3
+ #
4
+ # This is a fan-out / fan-in pattern:
5
+ # Fan-out: multiple research tasks run in parallel (no dependencies between them)
6
+ # Fan-in: synthesize waits for ALL research tasks before starting
7
+ # Fan-out: multiple implementation tasks run in parallel after synthesize
8
+ #
9
+ # Visualization:
10
+ # research-existing-code ─┐
11
+ # ├─→ synthesize ─┬─→ implement-core
12
+ # research-best-practices ─┘ └─→ implement-tests
13
+
14
+ # version: format version for compatibility tracking with Substrate.
15
+ version: "1.0"
16
+
17
+ # session: configuration that applies to the entire orchestration run.
18
+ session:
19
+ # name: human-readable label for this session.
20
+ name: research-implement-workflow
21
+ # base_branch: the git branch that all agent worktrees branch from.
22
+ base_branch: main
23
+
24
+ tasks:
25
+ # Phase 1: Parallel research tasks (both start immediately — fan-out).
26
+ # These run concurrently in separate git worktrees.
27
+ research-existing-code:
28
+ name: "Research Existing Codebase"
29
+ description: "Research the existing codebase for patterns and constraints"
30
+ # agent: which CLI agent handles this task.
31
+ agent: claude-code
32
+ # type: Options: coding, testing, docs, debugging, refactoring
33
+ type: docs
34
+ # prompt: full instruction sent to the agent.
35
+ prompt: |
36
+ Analyze the existing codebase. Document:
37
+ - Key architectural patterns and design decisions
38
+ - Relevant existing modules that the new feature will interact with
39
+ - Constraints and conventions (naming, error handling, testing style)
40
+ - Potential conflicts or integration points
41
+ Save findings to docs/research-codebase.md.
42
+ # depends_on: empty list means this task starts immediately (fan-out start).
43
+ depends_on: []
44
+
45
+ research-best-practices:
46
+ name: "Research Best Practices"
47
+ description: "Research industry best practices for the target feature"
48
+ agent: claude-code
49
+ type: docs
50
+ prompt: |
51
+ Research best practices for implementing [FEATURE].
52
+ Document recommended approaches, trade-offs, and real-world examples.
53
+ Compare at least two alternative implementation strategies.
54
+ Save findings to docs/research-practices.md.
55
+ # depends_on: also empty — runs concurrently with research-existing-code.
56
+ depends_on: []
57
+
58
+ # Phase 2: Synthesize findings — fan-in (waits for BOTH research tasks).
59
+ # This task cannot start until research-existing-code AND research-best-practices
60
+ # have both completed successfully.
61
+ synthesize:
62
+ name: "Synthesize Research"
63
+ description: "Synthesize research findings into an implementation plan"
64
+ agent: claude-code
65
+ type: docs
66
+ prompt: |
67
+ Read docs/research-codebase.md and docs/research-practices.md.
68
+ Produce a detailed implementation plan at docs/implementation-plan.md.
69
+ The plan should specify:
70
+ - Which modules to create or modify
71
+ - The recommended implementation strategy (with rationale)
72
+ - The order of implementation steps
73
+ - Key risks and mitigations
74
+ depends_on:
75
+ - research-existing-code # fan-in: waits for both research tasks to complete
76
+ - research-best-practices # both must finish before synthesize can start
77
+
78
+ # Phase 3: Parallel implementation — fan-out (both start after synthesize).
79
+ # These tasks run concurrently once the implementation plan is ready.
80
+ implement-core:
81
+ name: "Implement Core Logic"
82
+ description: "Implement the core business logic per the implementation plan"
83
+ agent: claude-code
84
+ type: coding
85
+ prompt: |
86
+ Read docs/implementation-plan.md and implement the core module.
87
+ Focus on the business logic layer only (no UI, no test code).
88
+ Follow the architectural patterns documented in docs/research-codebase.md.
89
+ depends_on:
90
+ - synthesize # will not start until synthesize completes (fan-out start)
91
+
92
+ implement-tests:
93
+ name: "Implement Test Suite"
94
+ description: "Implement the test suite per the implementation plan"
95
+ agent: claude-code
96
+ type: testing
97
+ prompt: |
98
+ Read docs/implementation-plan.md and implement the test suite.
99
+ Write tests in parallel with implement-core — test the interfaces/contracts,
100
+ not the internal implementation details.
101
+ Target 80%+ coverage for the new core module.
102
+ depends_on:
103
+ - synthesize # also waits for synthesize, then runs in parallel with implement-core
@@ -0,0 +1,91 @@
1
+ # Substrate Task Graph — Review Cycle Template
2
+ # Pattern: implement → review → revise
3
+ #
4
+ # This template demonstrates a quality-focused workflow where code is
5
+ # written, then reviewed, then revised based on review feedback.
6
+ #
7
+ # To add another review iteration, duplicate the review + revise pair:
8
+ # review-2:
9
+ # depends_on: [revise]
10
+ # revise-2:
11
+ # depends_on: [review-2]
12
+
13
+ # version: format version for compatibility tracking with Substrate.
14
+ version: "1.0"
15
+
16
+ # session: configuration that applies to the entire orchestration run.
17
+ session:
18
+ # name: human-readable label for this session.
19
+ name: review-cycle-workflow
20
+ # base_branch: the git branch that all agent worktrees branch from.
21
+ base_branch: main
22
+
23
+ tasks:
24
+ # Step 1: Initial implementation — starts immediately (no dependencies).
25
+ implement:
26
+ name: "Implement Feature"
27
+ description: "Implement the target feature"
28
+ # agent: which CLI agent handles this task.
29
+ agent: claude-code
30
+ # type: Options: coding, testing, docs, debugging, refactoring
31
+ type: coding
32
+ # prompt: full instruction sent to the agent.
33
+ prompt: |
34
+ Implement the feature described in docs/feature-spec.md.
35
+ Focus on correctness and completeness.
36
+ Code quality and style will be reviewed in the next step.
37
+ # depends_on: empty list means this task starts immediately.
38
+ depends_on: []
39
+
40
+ # Step 2: Code review — runs after implementation completes.
41
+ # A different agent can be assigned here for an independent perspective.
42
+ review:
43
+ name: "Code Review"
44
+ description: "Review the implementation for quality and correctness"
45
+ agent: claude-code
46
+ type: debugging
47
+ prompt: |
48
+ Review the code changes made in the 'implement' task.
49
+ Check for: correctness, error handling, test coverage, code style,
50
+ security concerns, and adherence to the spec in docs/feature-spec.md.
51
+ Write your review findings to docs/review-notes.md.
52
+ Be specific: cite file names, line numbers, and suggested fixes.
53
+ depends_on:
54
+ - implement # review will not start until implement is completed
55
+
56
+ # Step 3: Revision — applies the review feedback.
57
+ revise:
58
+ name: "Apply Review Feedback"
59
+ description: "Apply review feedback and finalize the implementation"
60
+ agent: claude-code
61
+ type: coding
62
+ prompt: |
63
+ Read docs/review-notes.md and apply all required changes.
64
+ Address every concern raised in the review.
65
+ After making changes, update docs/review-notes.md to mark each
66
+ item as resolved with a brief note explaining what was changed.
67
+ depends_on:
68
+ - review # revise will not start until review is completed
69
+
70
+ # --- To add a second review cycle, uncomment and customize: ---
71
+ # review-2:
72
+ # name: "Final Code Review"
73
+ # description: "Final review after revisions"
74
+ # agent: claude-code
75
+ # type: debugging
76
+ # prompt: |
77
+ # Perform a final review of the revised code.
78
+ # Verify all items from docs/review-notes.md are resolved.
79
+ # Confirm the implementation meets all spec requirements.
80
+ # depends_on:
81
+ # - revise
82
+ #
83
+ # revise-2:
84
+ # name: "Final Revision"
85
+ # description: "Apply final review feedback"
86
+ # agent: claude-code
87
+ # type: coding
88
+ # prompt: |
89
+ # Apply any remaining feedback from the final review.
90
+ # depends_on:
91
+ # - review-2
@@ -0,0 +1,68 @@
1
+ # Substrate Task Graph — Sequential Template
2
+ # A series of tasks that run one after another.
3
+ #
4
+ # This template demonstrates a simple sequential pipeline where each task
5
+ # depends on the previous one completing before it starts.
6
+
7
+ # version: format version for compatibility tracking with Substrate.
8
+ # Currently "1.0" is the supported version.
9
+ version: "1.0"
10
+
11
+ # session: configuration that applies to the entire orchestration run.
12
+ session:
13
+ # name: a human-readable label for this session (appears in logs and status output).
14
+ name: sequential-workflow
15
+ # base_branch: the git branch that all agent worktrees branch from.
16
+ base_branch: main
17
+
18
+ tasks:
19
+ # Task 1: the first step in the sequence.
20
+ # Format: each task key is the unique task ID used in depends_on references.
21
+ step-1:
22
+ # name: short label shown in status output and logs.
23
+ name: "Gather Requirements"
24
+ # description: optional longer explanation of what this task does.
25
+ description: "First step: analyze the project and produce a requirements document"
26
+ # agent: which CLI agent handles this task.
27
+ # Options: claude-code, codex, gemini, auto (auto lets the routing engine pick)
28
+ agent: claude-code
29
+ # type: categorizes the task for routing and reporting purposes.
30
+ # Options: coding, testing, docs, debugging, refactoring
31
+ type: docs
32
+ # prompt: the instruction sent verbatim to the agent.
33
+ prompt: |
34
+ Analyze the project requirements and produce a detailed spec document.
35
+ Save the output to docs/spec.md.
36
+ Include: goals, non-goals, acceptance criteria, and open questions.
37
+ # depends_on: list of task IDs that must complete before this task runs.
38
+ # An empty list means this task can start immediately.
39
+ depends_on: []
40
+
41
+ # Task 2: runs only after step-1 completes successfully.
42
+ step-2:
43
+ name: "Implement Feature"
44
+ description: "Second step: implement the feature described in the spec"
45
+ agent: claude-code
46
+ type: coding
47
+ prompt: |
48
+ Read docs/spec.md and implement the described feature.
49
+ Follow existing code conventions and patterns in the codebase.
50
+ Ensure all acceptance criteria from the spec are addressed.
51
+ depends_on:
52
+ - step-1 # step-2 will not start until step-1 is completed
53
+
54
+ # Task 3: final step — runs only after step-2 completes.
55
+ # To add more sequential steps, copy this block and update the id and depends_on.
56
+ step-3:
57
+ name: "Write Tests"
58
+ description: "Third step: write tests for the implementation"
59
+ agent: claude-code
60
+ type: testing
61
+ prompt: |
62
+ Write comprehensive unit and integration tests for the code written in step-2.
63
+ Target 80%+ coverage for new code.
64
+ Ensure all edge cases from docs/spec.md are covered.
65
+ # budget_usd: optional per-task cost cap. Overrides the session-level budget.
66
+ # budget_usd: 2.00
67
+ depends_on:
68
+ - step-2 # step-3 will not start until step-2 is completed
@@ -0,0 +1,102 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/modules/config/config-schema.ts
4
+ /** Subscription routing modes */
5
+ const SubscriptionRoutingSchema = z.enum([
6
+ "auto",
7
+ "subscription",
8
+ "api",
9
+ "disabled"
10
+ ]);
11
+ /** Rate limit configuration for a provider */
12
+ const RateLimitSchema = z.object({
13
+ tokens: z.number().int().positive(),
14
+ window_seconds: z.number().int().positive()
15
+ }).strict();
16
+ /** Per-provider configuration */
17
+ const ProviderConfigSchema = z.object({
18
+ enabled: z.boolean(),
19
+ cli_path: z.string().optional(),
20
+ subscription_routing: SubscriptionRoutingSchema,
21
+ max_concurrent: z.number().int().min(1).max(32),
22
+ rate_limit: RateLimitSchema.optional(),
23
+ api_key_env: z.string().optional(),
24
+ api_billing: z.boolean()
25
+ }).strict();
26
+ /** Map of all known providers */
27
+ const ProvidersSchema = z.object({
28
+ claude: ProviderConfigSchema.optional(),
29
+ codex: ProviderConfigSchema.optional(),
30
+ gemini: ProviderConfigSchema.optional()
31
+ }).strict();
32
+ const LogLevelSchema = z.enum([
33
+ "trace",
34
+ "debug",
35
+ "info",
36
+ "warn",
37
+ "error",
38
+ "fatal"
39
+ ]);
40
+ const GlobalSettingsSchema = z.object({
41
+ log_level: LogLevelSchema,
42
+ max_concurrent_tasks: z.number().int().min(1).max(64),
43
+ budget_cap_tokens: z.number().int().min(0),
44
+ budget_cap_usd: z.number().min(0),
45
+ workspace_dir: z.string().optional(),
46
+ update_check: z.boolean().optional()
47
+ }).strict();
48
+ const CostTrackerConfigSchema = z.object({
49
+ enabled: z.boolean(),
50
+ token_rates_provider: z.enum(["builtin", "custom"]),
51
+ track_planning_costs: z.boolean(),
52
+ savings_reporting: z.boolean()
53
+ }).strict();
54
+ const BudgetConfigSchema = z.object({
55
+ default_task_budget_usd: z.number().min(0),
56
+ default_session_budget_usd: z.number().min(0),
57
+ planning_costs_count_against_budget: z.boolean(),
58
+ warning_threshold_percent: z.number().min(0).max(100)
59
+ }).strict();
60
+ const RoutingRuleSchema = z.object({
61
+ task_type: z.string(),
62
+ preferred_provider: z.string(),
63
+ fallback_providers: z.array(z.string())
64
+ }).strict();
65
+ const RoutingPolicySchema = z.object({
66
+ default_provider: z.string(),
67
+ rules: z.array(RoutingRuleSchema)
68
+ }).strict();
69
+ /** Current supported config format version */
70
+ const CURRENT_CONFIG_FORMAT_VERSION = "1";
71
+ /** Current supported task graph version */
72
+ const CURRENT_TASK_GRAPH_VERSION = "1";
73
+ /** All config format versions this toolkit can read and validate */
74
+ const SUPPORTED_CONFIG_FORMAT_VERSIONS = ["1"];
75
+ /** All task graph format versions this toolkit can read and validate */
76
+ const SUPPORTED_TASK_GRAPH_VERSIONS = ["1"];
77
+ const SubstrateConfigSchema = z.object({
78
+ config_format_version: z.enum(["1"]),
79
+ task_graph_version: z.enum(["1"]).optional(),
80
+ global: GlobalSettingsSchema,
81
+ providers: ProvidersSchema,
82
+ cost_tracker: CostTrackerConfigSchema.optional(),
83
+ budget: BudgetConfigSchema.optional()
84
+ }).strict();
85
+ const PartialProviderConfigSchema = ProviderConfigSchema.partial();
86
+ const PartialGlobalSettingsSchema = GlobalSettingsSchema.partial();
87
+ const PartialSubstrateConfigSchema = z.object({
88
+ config_format_version: z.enum(["1"]).optional(),
89
+ task_graph_version: z.enum(["1"]).optional(),
90
+ global: PartialGlobalSettingsSchema.optional(),
91
+ providers: z.object({
92
+ claude: PartialProviderConfigSchema.optional(),
93
+ codex: PartialProviderConfigSchema.optional(),
94
+ gemini: PartialProviderConfigSchema.optional()
95
+ }).partial().optional(),
96
+ cost_tracker: CostTrackerConfigSchema.partial().optional(),
97
+ budget: BudgetConfigSchema.partial().optional()
98
+ }).strict();
99
+
100
+ //#endregion
101
+ export { CURRENT_CONFIG_FORMAT_VERSION, CURRENT_TASK_GRAPH_VERSION, PartialSubstrateConfigSchema, SUPPORTED_CONFIG_FORMAT_VERSIONS, SUPPORTED_TASK_GRAPH_VERSIONS, SubstrateConfigSchema };
102
+ //# sourceMappingURL=config-schema-C9tTMcm1.js.map