@sprucelabs/spruce-templates 29.2.1 → 29.3.1
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/build/index.d.ts +3 -0
- package/build/index.js +13 -1
- package/build/templates/markdown/AGENTS.md.hbs +140 -0
- package/build/templates/markdown/CLAUDE.md.hbs +3 -0
- package/build/templates/markdown/PROJECT.md.hbs +3 -0
- package/package.json +2 -2
- /package/build/templates/{typescript → markdown}/agent/SYSTEM_PROMPT.md.hbs +0 -0
package/build/index.d.ts
CHANGED
|
@@ -141,6 +141,9 @@ export declare const templates: {
|
|
|
141
141
|
}): string;
|
|
142
142
|
theme(): string;
|
|
143
143
|
logTransport(): string;
|
|
144
|
+
claudeMd(): string;
|
|
145
|
+
agentsMd(): string;
|
|
146
|
+
projectMd(): string;
|
|
144
147
|
};
|
|
145
148
|
export type Templates = typeof templates;
|
|
146
149
|
export { default as importExtractorUtil } from './utilities/importExtractor.utility';
|
package/build/index.js
CHANGED
|
@@ -274,7 +274,7 @@ exports.templates = {
|
|
|
274
274
|
return template({});
|
|
275
275
|
},
|
|
276
276
|
agentSystemPrompt(options) {
|
|
277
|
-
const template = templateImporter_utility_1.default.getTemplate('agent/SYSTEM_PROMPT.md.hbs');
|
|
277
|
+
const template = templateImporter_utility_1.default.getTemplate('agent/SYSTEM_PROMPT.md.hbs', 'markdown');
|
|
278
278
|
return template(options);
|
|
279
279
|
},
|
|
280
280
|
viewControllerPlugin(options) {
|
|
@@ -289,6 +289,18 @@ exports.templates = {
|
|
|
289
289
|
const template = templateImporter_utility_1.default.getTemplate('log/transport.plugin.ts.hbs');
|
|
290
290
|
return template({});
|
|
291
291
|
},
|
|
292
|
+
claudeMd() {
|
|
293
|
+
const template = templateImporter_utility_1.default.getTemplate('CLAUDE.md.hbs', 'markdown');
|
|
294
|
+
return template({});
|
|
295
|
+
},
|
|
296
|
+
agentsMd() {
|
|
297
|
+
const template = templateImporter_utility_1.default.getTemplate('AGENTS.md.hbs', 'markdown');
|
|
298
|
+
return template({});
|
|
299
|
+
},
|
|
300
|
+
projectMd() {
|
|
301
|
+
const template = templateImporter_utility_1.default.getTemplate('PROJECT.md.hbs', 'markdown');
|
|
302
|
+
return template({});
|
|
303
|
+
},
|
|
292
304
|
};
|
|
293
305
|
var importExtractor_utility_2 = require("./utilities/importExtractor.utility");
|
|
294
306
|
Object.defineProperty(exports, "importExtractorUtil", { enumerable: true, get: function () { return __importDefault(importExtractor_utility_2).default; } });
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
# Agent SOPs
|
|
2
|
+
|
|
3
|
+
## Coding Workflow
|
|
4
|
+
|
|
5
|
+
1. **Outline a plan** - Present each step with a concise description and code samples
|
|
6
|
+
2. **Get approval** - Wait for approval before starting; go through each step one at a time to allow for edits
|
|
7
|
+
3. **Detail the step** - Before executing, present the step in full detail (complete code, file paths, rationale) for review and approval
|
|
8
|
+
4. **Execute** - Implement the approved step, then present the next step in detail and repeat
|
|
9
|
+
|
|
10
|
+
## Planning Principles
|
|
11
|
+
|
|
12
|
+
- Plans describe discrete, concrete mutations to code/config.
|
|
13
|
+
- One step maps to one conceptual change set; split unrelated changes.
|
|
14
|
+
- Each step is proposed, approved, then executed before moving on.
|
|
15
|
+
- Each step must explicitly list the concrete file changes (add/remove/modify) it will make.
|
|
16
|
+
- If scope changes mid-stream, update the plan with a brief reason before proceeding.
|
|
17
|
+
|
|
18
|
+
## Research Principles
|
|
19
|
+
|
|
20
|
+
- Research (reading files, scanning logs, running read-only commands) can proceed without a formal plan or step approvals.
|
|
21
|
+
- Always complete research before making suggestions.
|
|
22
|
+
- Never stop research based on initial findings.
|
|
23
|
+
- Focus on holistic and detailed analysis: both wide (breadth) and deep (depth).
|
|
24
|
+
- When scanning for documentation, check `docs/` in addition to root-level files.
|
|
25
|
+
- Treat `docs/PROJECT.md` as critical project-specific instructions and read it early.
|
|
26
|
+
- Any code/config changes, script edits, or stateful commands still require the full plan/approval workflow.
|
|
27
|
+
|
|
28
|
+
## Replanning Principles
|
|
29
|
+
|
|
30
|
+
- When plans change, reprint the full plan with status markers.
|
|
31
|
+
- Mark completed steps as checked off, removed steps as crossed out, and new steps as highlighted.
|
|
32
|
+
- Always explain why the plan changed before continuing.
|
|
33
|
+
|
|
34
|
+
## Bugfixing Principles
|
|
35
|
+
|
|
36
|
+
- Investigate problems thoroughly (think RCA) before proposing fixes.
|
|
37
|
+
- Explain the understood issue back to the user to prove comprehension.
|
|
38
|
+
- No "stabbing at things" or guesswork changes.
|
|
39
|
+
- If the problem is not understood, zoom out and review again.
|
|
40
|
+
|
|
41
|
+
## Coding Standards
|
|
42
|
+
|
|
43
|
+
- Prefer OOP designs; use composition where possible.
|
|
44
|
+
- Maximum of one inheritance layer.
|
|
45
|
+
- Keep things DRY: after writing code, review for reuse opportunities and extract shared pieces.
|
|
46
|
+
- Place type definitions at the bottom of files.
|
|
47
|
+
- All class names are to be capitalized in PascalCase.
|
|
48
|
+
- Files that define a class should be named after that class in PascalCase (e.g., `DataFetcher.py` for class `DataFetcher`) and the class should be the default export.
|
|
49
|
+
- We take types and formatting seriously, consider running `yarn fix.lint` after making changes.
|
|
50
|
+
- Before pushing, run `yarn fix.lint` and `yarn build.ci` successfully.
|
|
51
|
+
|
|
52
|
+
## Refactor Principles
|
|
53
|
+
|
|
54
|
+
- Do not use git commands to refactor (e.g., avoid `git mv`).
|
|
55
|
+
- Make refactors via local file changes, then commit those changes.
|
|
56
|
+
|
|
57
|
+
## SOLID Principles for AI Agents
|
|
58
|
+
|
|
59
|
+
Applying these five design principles helps prevent "super-agent" bloat, reduces fragility when switching LLM providers, and ensures specialized agents collaborate effectively.
|
|
60
|
+
|
|
61
|
+
### 1. Single Responsibility Principle (SRP)
|
|
62
|
+
- **Definition:** An agent should have one, and only one, reason to change. It should focus on a single core task.
|
|
63
|
+
- **Detailed Explanation:** In agentic workflows, SRP prevents monolithic "God Agents" that handle everything from data retrieval to final formatting. Instead, break workflows into specialized sub-agents. This improves reliability by giving each agent a tighter, more focused system prompt.
|
|
64
|
+
- **Example:**
|
|
65
|
+
- **Bad:** A "Support Agent" that reads emails, queries the database, processes returns, and sends confirmation emails.
|
|
66
|
+
- **Good:** A Classifier Agent (categorizes intent) -> A Retrieval Agent (fetches data) -> A Resolution Agent (proposes action) -> A Writer Agent (drafts response).
|
|
67
|
+
|
|
68
|
+
### 2. Open-Closed Principle (OCP)
|
|
69
|
+
- **Definition:** Agents should be open for extension but closed for modification.
|
|
70
|
+
- **Detailed Explanation:** You should be able to add new capabilities to your system (extension) without rewriting the core orchestration logic (modification). This is typically achieved through standardized protocols and pluggable tool interfaces.
|
|
71
|
+
- **Example:**
|
|
72
|
+
- **Scenario:** Your orchestrator works with a "Search Tool." If you want to add "Voice Search," you shouldn't have to rewrite the orchestrator.
|
|
73
|
+
- **Implementation:** Define a BaseTool interface. New tools like VoiceSearchTool inherit from BaseTool. The orchestrator interacts with BaseTool, automatically supporting any new tool you add later.
|
|
74
|
+
|
|
75
|
+
### 3. Liskov Substitution Principle (LSP)
|
|
76
|
+
- **Definition:** Subclasses or specific agent implementations must be substitutable for their base types without altering the correctness of the system.
|
|
77
|
+
- **Detailed Explanation:** In 2026, agents often swap between different LLMs (e.g., GPT-5 to Claude 4) or specialized models for cost/speed. LSP ensures that if you swap a "Reasoning Agent" for a faster "Drafting Agent," the system's output format and interface remain consistent so the next agent in the pipeline doesn't break.
|
|
78
|
+
- **Example:**
|
|
79
|
+
- If your system expects a SearchAgent to return a JSON list of URLs, any new VectorSearchAgent must also return a JSON list of URLs, not raw text or markdown, to ensure downstream compatibility.
|
|
80
|
+
|
|
81
|
+
### 4. Interface Segregation Principle (ISP)
|
|
82
|
+
- **Definition:** An agent should not be forced to depend on tools or interfaces it does not use.
|
|
83
|
+
- **Detailed Explanation:** Don't give an agent a massive toolkit if it only needs one tool. Large context windows filled with irrelevant tool descriptions lead to "tool-use hallucinations" and increased token costs. Create smaller, specific "toolsets" for specific agent roles.
|
|
84
|
+
- **Example:**
|
|
85
|
+
- **Bad:** Giving a "Proofreading Agent" access to DeleteDatabase, SendEmail, and WriteFile.
|
|
86
|
+
- **Good:** Giving it a specific TextEditing interface that only exposes ReadText and SubmitCorrection.
|
|
87
|
+
|
|
88
|
+
### 5. Dependency Inversion Principle (DIP)
|
|
89
|
+
- **Definition:** Depend on abstractions, not concretions. High-level agent logic should not depend on low-level implementation details.
|
|
90
|
+
- **Detailed Explanation:** Your core business logic shouldn't be hard-coded to a specific LLM API or a specific database. Instead, the agent should depend on an abstract "Inference Provider" or "Data Store" interface. This allows you to switch from OpenAI to an in-house Llama model just by changing the underlying implementation.
|
|
91
|
+
- **Example:**
|
|
92
|
+
- **Concretion (Bad):** OpenAI.chat_completion(prompt) called directly inside your agent code.
|
|
93
|
+
- **Abstraction (Good):** Agent.generate(prompt) which calls an abstract LLMProvider. You can then "inject" OpenAIProvider, AnthropicProvider, or LocalModelProvider at runtime.
|
|
94
|
+
|
|
95
|
+
## Test-Driven Development (TDD) Protocols
|
|
96
|
+
|
|
97
|
+
All development must strictly adhere to the Three Laws of TDD. These laws mandate a "nano-cycle" workflow where the time between running tests is measured in seconds or minutes, ensuring the system remains executing at all times.
|
|
98
|
+
|
|
99
|
+
### The Three Laws
|
|
100
|
+
|
|
101
|
+
1. No Production Code Without Failure: You may not write any production code unless it is to make a failing unit test pass.
|
|
102
|
+
2. Minimal Test Writing: You may not write more of a unit test than is sufficient to fail; failing to compile is considered a valid failure.
|
|
103
|
+
3. Minimal Production Code: You may not write more production code than is sufficient to pass the currently failing unit test.
|
|
104
|
+
|
|
105
|
+
### The Red-Green-Refactor Cycle
|
|
106
|
+
|
|
107
|
+
The criticalness of TDD lies in its tight feedback loop, which provides immediate verification and prevents "invisible drift" in complex systems. All our tests watch and rerun on every change, this is our continuous safety net while developing. The tests will also run in CI/CD pipelines to ensure no regressions are introduced.
|
|
108
|
+
|
|
109
|
+
- Red (Tight Specification): Write a failing test first that approaches to solve the first, smallest piece of functionality you want to add.
|
|
110
|
+
- Most times, this is failing because the function or class does not yet exist.
|
|
111
|
+
- It can cover calling a method with missing or incorrect parameters
|
|
112
|
+
- It can cover edge cases or error conditions.
|
|
113
|
+
- Write the smallest test possible to force the production code changes to be as small as possible.
|
|
114
|
+
- Think of the test as a challenge to the production code writer to solve with the least amount of code.
|
|
115
|
+
- Green (Rapid Feedback): Write the absolute minimum code to pass the test. The priority here is the feedback speed—once the test is green, you have a "safe harbor" of working code.
|
|
116
|
+
- This code may be ugly, unoptimized, or even hard-coded.
|
|
117
|
+
- The goal is to get to a passing state as quickly as possible to maintain momentum and confidence.
|
|
118
|
+
- Think of this as a challenge to the test writer to write another test that forces improvement.
|
|
119
|
+
- In the end, the code should have no choice but to work.
|
|
120
|
+
- Many times the production code starts in the same file as the test code for speed, just at the bottom.
|
|
121
|
+
- Refactor (Fearless Optimization): With a passing test suite as a safety net, you must clean up and optimize the code. This is the only time design improvements should happen. The feedback loop ensures that if a refactor breaks logic, you know exactly which change caused the issue within seconds.
|
|
122
|
+
- It is best to refactor after you have written the same code twice and the tests pass.
|
|
123
|
+
- Follow CLEAN code principles here. It's ok to refactor the same code to match different patterns as the codebase evolves.
|
|
124
|
+
- Keep functions/methods small, only a few lines of code, the idea being that we need to trust the function/method names and not be conserned with the implementation details.
|
|
125
|
+
- When the implementation is done, move the production code to its proper file and location.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
### Why This is Critical for Agents
|
|
129
|
+
|
|
130
|
+
- Instant Verification: Frequent test runs (every 30–60 seconds) mean debugging is nearly eliminated because the bug must be in the handful of lines written since the last pass.
|
|
131
|
+
- Confidence to Release: A comprehensive suite of "cannot fail" tests allows for rapid iteration and deployment with total confidence in system stability.
|
|
132
|
+
- Prevention of Rot: Slow feedback loops lead to developer fatigue and code rot. Keeping tests fast and the cycle tight ensures the cost of refactoring remains low.
|
|
133
|
+
|
|
134
|
+
## Commit Message Convention
|
|
135
|
+
|
|
136
|
+
Commit messages must follow semver intent for CI/CD:
|
|
137
|
+
|
|
138
|
+
- `patch: {detailed description of changes}` for immaterial behavior changes
|
|
139
|
+
- `minor: {detailed description of changes}` for new features
|
|
140
|
+
- `major: {detailed description of changes}` for breaking changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "29.
|
|
6
|
+
"version": "29.3.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"build/**/*",
|
|
9
9
|
"tsconfig.json",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"conventional-changelog-sprucelabs"
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "008edf88dfecfb6c1bb2618681dcb606d10b9dd9"
|
|
84
84
|
}
|
|
File without changes
|