Skip to content

Commit 7af280b

Browse files
committed
github: Update agents and instructions
1 parent c2f3e50 commit 7af280b

File tree

13 files changed

+55
-119
lines changed

13 files changed

+55
-119
lines changed

.github/agents.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Specialized agents for Sharpy development. Each agent has domain expertise and c
5757

5858
```bash
5959
dotnet build sharpy.sln && dotnet test # Build + test
60-
dotnet format # Format before commit
60+
dotnet format whitespace # Format before commit
6161
dotnet run --project src/Sharpy.Cli -- emit csharp file.spy # Debug codegen
6262
python3 -c "..." # Verify Python behavior
6363
```

.github/agents/documentation-sync.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Keeps documentation synchronized with implementation.
2121
```bash
2222
# Test code blocks from docs
2323
for file in examples/*.spy; do
24-
dotnet run --project src/Sharpy.Cli -- check "$file"
24+
dotnet run --project src/Sharpy.Cli -- build "$file"
2525
done
2626
```
2727

.github/agents/hallucination-defense.agent.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Validates factual accuracy of claims. **Read-only.**
1010

1111
## Verification Categories
1212

13-
1. **.NET API**dotnet script -e "..." to verify behavior
14-
2. **Roslyn API** — Check SyntaxFactory method exists
15-
3. **Python semantics** — python3 -c "..." to verify
13+
1. **.NET API**Create test program or use `csharp` REPL to verify behavior
14+
2. **Roslyn API** — Check SyntaxFactory method exists in docs or via test
15+
3. **Python semantics**`python3 -c "..."` to verify
1616
4. **C# 9.0 availability** — Records yes, file-scoped namespaces no
17-
5. **Sharpy implementation** — grep -r "feature" src/
17+
5. **Sharpy implementation**`grep -r "feature" src/`
1818

1919
## Output Format
2020

.github/agents/implementer.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ For new language features:
3737

3838
```bash
3939
dotnet build sharpy.sln && dotnet test # Build + test
40-
dotnet format # Format before commit
40+
dotnet format whitespace # Format before commit
4141
python3 -c "..." # Verify Python behavior
4242
dotnet run --project src/Sharpy.Cli -- emit csharp file.spy # Debug codegen
4343
```

.github/agents/parser-expert.agent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Specializes in the Sharpy parser. Handles EBNF grammar translation, AST node con
1010

1111
## Scope
1212

13-
**Owns:** `src/Sharpy.Compiler/Parser/` and `src/Sharpy.Compiler/Ast/`
13+
**Owns:** `src/Sharpy.Compiler/Parser/` (including `Parser/Ast/`)
1414

1515
**Does NOT modify:** Lexer, Semantic, CodeGen, or Sharpy.Core
1616

.github/copilot-instructions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Source (.spy) → Lexer → Parser (AST) → Semantic → ValidationPipeline →
2929
```bash
3030
dotnet build sharpy.sln # Build all
3131
dotnet test # Run all tests
32-
dotnet format # Format before committing
32+
dotnet format whitespace # Format before committing
3333
dotnet run --project src/Sharpy.Cli -- run file.spy # Compile and execute
3434
dotnet run --project src/Sharpy.Cli -- emit csharp file.spy # Debug codegen
3535
dotnet run --project src/Sharpy.Cli -- emit ast file.spy # Debug parser
@@ -117,4 +117,4 @@ $"return {value};"
117117

118118
## CI/CD
119119

120-
`.github/workflows/`: `dotnet9.yml`, `dotnet10.yml` (tests on both .NET 9 and 10).
120+
`.github/workflows/`: `dotnet10.yml` (tests on .NET 10).

.github/instructions/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ For new language features, touch these components in order:
3535

3636
Language specification lives in `docs/language_specification/`. Always check specs before implementing.
3737

38-
See [../.github/copilot-instructions.md](../copilot-instructions.md) for repository-wide guidance.
38+
See [copilot-instructions.md](../copilot-instructions.md) for repository-wide guidance.

.github/instructions/Sharpy.Compiler.Tests/HOW_TO_CONTRIBUTE.instructions.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
````instructions
12
# Sharpy.Compiler.Tests
23
34
Compiler test suite. Location: `src/Sharpy.Compiler.Tests/`
@@ -93,12 +94,6 @@ var result = helper.Compile();
9394
| `errors/` | Expected compilation failures (`.error` files) |
9495
| `imports/` | Module imports |
9596
| `generics/` | Generic types and functions |
96-
var result = CompileAndExecute("print(42)");
97-
Assert.True(result.Success);
98-
Assert.Equal("42\n", result.StandardOutput);
99-
}
100-
}
101-
```
10297
10398
## File-Based Tests
10499
@@ -115,3 +110,5 @@ TestFixtures/
115110
```bash
116111
dotnet test --filter "FullyQualifiedName~FileBasedIntegrationTests"
117112
```
113+
114+
````
Lines changed: 27 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
````instructions
12
# Sharpy.Core
23
34
Standard library with Pythonic APIs for .NET. Location: `src/Sharpy.Core/`
@@ -22,22 +23,23 @@ Standard library with Pythonic APIs for .NET. Location: `src/Sharpy.Core/`
2223
2324
## Adding a Builtin Function
2425
25-
Add to `partial class Exports` (split across files):
26-
```csharp
27-
// NewFunction.cs
28-
namespace Sharpy.Core;
29-
30-
public static partial class Exports
31-
{
32-
public static TResult NewFunction<T, TResult>(T input) => ...;
33-
}
34-
```
26+
1. **Add to `partial class Exports`** (split across files):
27+
```csharp
28+
// NewFunction.cs
29+
namespace Sharpy.Core;
3530
36-
Then:
37-
```bash
38-
python3 -c "print(new_function(...))" # Verify expected behavior
39-
dotnet test --filter "FullyQualifiedName~NewFunctionTests"
40-
```
31+
public static partial class Exports
32+
{
33+
public static TResult NewFunction<T, TResult>(T input) => ...;
34+
}
35+
```
36+
2. **Verify expected behavior against Python:**
37+
```bash
38+
python3 -c "print(new_function(...))"
39+
```
40+
3. **Add tests** in `Sharpy.Core.Tests/NewFunctionTests.cs`
41+
4. **Test against Python** to verify behavior matches
42+
5. **Document** in language reference if needed
4143
4244
## Python-style Indexing Pattern
4345
@@ -73,28 +75,24 @@ dotnet test --filter "FullyQualifiedName~DictTests"
7375
```
7476
7577
**CRITICAL:** Always verify behavior against `python3 -c "..."` first. Fix bugs, don't change test expectations.
76-
```
77-
3. **Add tests** in `Sharpy.Core.Tests/NewFunctionTests.cs`
78-
4. **Test against Python** to verify behavior matches
79-
5. **Document** in language reference if needed
8078
81-
### Adding a New Collection Method
79+
## Adding a New Collection Method
8280
8381
1. **Add method to partial class** (e.g., in `Partial.List/`)
84-
2. **Follow Python semantics** - check Python documentation
82+
2. **Follow Python semantics** check Python documentation
8583
3. **Add comprehensive tests**
8684
4. **Test edge cases** (empty, single-element, etc.)
8785
5. **Update documentation** if it's a public API
8886
89-
### Implementing an Operator Protocol
87+
## Implementing an Operator Protocol
9088
9189
1. **Define interface** (e.g., `INewOperator.cs`)
9290
2. **Implement on relevant types**
9391
3. **Add operator overload** if appropriate
9492
4. **Test with multiple types**
9593
5. **Document protocol** in specs
9694
97-
### Fixing a Bug
95+
## Fixing a Bug
9896
9997
1. **Write a test that reproduces the bug:**
10098
```csharp
@@ -114,77 +112,15 @@ dotnet test --filter "FullyQualifiedName~DictTests"
114112
115113
## Performance Considerations
116114
117-
- **Minimize allocations** - Reuse collections where possible
118-
- **Use struct for small value types** - `Index`, `Slice`
119-
- **Lazy evaluation** - Use iterators instead of materializing lists
120-
- **Leverage .NET BCL** - Don't reinvent optimized data structures
121-
122-
## Dependencies
123-
124-
- **.NET 9.0/10.0** - BCL and runtime
125-
- **System.Collections.Generic** - Underlying collection types
126-
- **System.Linq** - Query operations
115+
- **Minimize allocations** — Reuse collections where possible
116+
- **Use struct for small value types** — `Index`, `Slice`
117+
- **Lazy evaluation** — Use iterators instead of materializing lists
118+
- **Leverage .NET BCL** — Don't reinvent optimized data structures
127119
128120
## Related Documentation
129121
130122
- **Main README:** `README.md` (repository root)
131123
- **Core Tests Guide:** `.github/instructions/Sharpy.Core.Tests/HOW_TO_CONTRIBUTE.instructions.md`
132-
- **Type System Spec:** `docs/specs/type_system.md`
133-
- **Builtins Reference:** `docs/specs/builtins.md`
134-
135-
## Example: Adding a New List Method
136-
137-
Let's add `list.insert_all(index, items)` to insert multiple items at once:
138-
139-
### 1. Implementation
140-
```csharp
141-
// In Partial.List/List.Mutation.cs
142-
public void InsertAll(int index, IEnumerable<T> items)
143-
{
144-
var actualIndex = index < 0 ? _inner.Count + index : index;
145-
if (actualIndex < 0) actualIndex = 0;
146-
if (actualIndex > _inner.Count) actualIndex = _inner.Count;
147-
148-
_inner.InsertRange(actualIndex, items);
149-
}
150-
```
151-
152-
### 2. Tests
153-
```csharp
154-
// In Sharpy.Core.Tests/Partial.ListTests/ListTests.Mutation.cs
155-
[Fact]
156-
public void TestInsertAll_InMiddle()
157-
{
158-
var list = new List<int> { 1, 2, 5, 6 };
159-
list.InsertAll(2, new[] { 3, 4 });
160-
Assert.Equal(new[] { 1, 2, 3, 4, 5, 6 }, list);
161-
}
162-
163-
[Fact]
164-
public void TestInsertAll_NegativeIndex()
165-
{
166-
var list = new List<int> { 1, 4, 5 };
167-
list.InsertAll(-2, new[] { 2, 3 });
168-
Assert.Equal(new[] { 1, 2, 3, 4, 5 }, list);
169-
}
170-
171-
[Fact]
172-
public void TestInsertAll_Empty()
173-
{
174-
var list = new List<int> { 1, 2 };
175-
list.InsertAll(1, Array.Empty<int>());
176-
Assert.Equal(new[] { 1, 2 }, list);
177-
}
178-
```
179-
180-
### 3. Verify
181-
```bash
182-
dotnet test --filter "FullyQualifiedName~TestInsertAll"
183-
```
184-
185-
## Getting Help
124+
- **Language Specification:** `docs/language_specification/`
186125
187-
- Check Python documentation for expected behavior
188-
- Review existing implementations for patterns
189-
- Run tests frequently to catch issues early
190-
- Consult type system documentation for type-related questions
126+
````

.github/instructions/samples/HOW_TO_CONTRIBUTE.instructions.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,13 @@ dotnet test --filter "FullyQualifiedName~Integration"
100100

101101
```bash
102102
# Emit tokens to debug lexer issues
103-
dotnet run --project src/Sharpy.Cli -- samples/problem.spy --emit-tokens
103+
dotnet run --project src/Sharpy.Cli -- emit tokens samples/problem.spy
104+
105+
# Emit AST to debug parser issues
106+
dotnet run --project src/Sharpy.Cli -- emit ast samples/problem.spy
104107

105108
# Check for detailed error messages
106-
dotnet run --project src/Sharpy.Cli -- samples/problem.spy 2>&1 | less
109+
dotnet run --project src/Sharpy.Cli -- build samples/problem.spy 2>&1 | less
107110
```
108111

109112
## Sample Categories

0 commit comments

Comments
 (0)