Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
794176e
hello-world: initial planning, not yet broken down to tasks
akollegger Dec 13, 2025
4f4e824
hello-world: task breakdown
akollegger Dec 13, 2025
1ea4079
hello-world: iterating on design docs
akollegger Dec 14, 2025
c1ebd4b
hello-world: simplified ToolSpecification to use identifer as functio…
akollegger Dec 14, 2025
396a6d2
hello-world: use identifiers for parameter name, making them globally…
akollegger Dec 15, 2025
b4ca697
hello-world: wip renaming elements
akollegger Dec 15, 2025
f0f74cf
hello-world: revised terminology to reflect pattern-based elements as…
akollegger Dec 15, 2025
d6fb782
hello-world: added a high-level architecture document to describe the…
akollegger Dec 15, 2025
1b82c44
hello-world: split into two modules, 1) for the agentic pattern langu…
akollegger Dec 15, 2025
c5fcd62
hello-world: revised tasks to align with new architectural approach
akollegger Dec 15, 2025
7a485ed
hello-world: added a phase to enable the cli to run agents from gram …
akollegger Dec 15, 2025
3e675e1
hello-world: phase 2, foundational implementation sketching out classes
akollegger Dec 15, 2025
e873830
refactor: Separate parsing from programmatic creation and add Functio…
akollegger Dec 15, 2025
0d79396
hello-world: test scenarios pass for gram-based, coding-based, or mix…
akollegger Dec 15, 2025
39d503a
hello-world: phase 5 runs a simple agent
akollegger Dec 15, 2025
359a7f2
hello-world: hello-world agent fully supported
akollegger Dec 16, 2025
a68c05a
hello-world: integration tests with live LLM
akollegger Dec 16, 2025
f269b8e
hello-world: mock LLM for scenario testing
akollegger Dec 16, 2025
b1a449c
hello-world: cli exec of gram-defined agent, binding to builtin tool
akollegger Dec 16, 2025
95c3855
hello-world: added logging to debug interactions
akollegger Dec 16, 2025
3d268fb
hello-world: cli accepts multiple messages, passed to agent in sequence
akollegger Dec 16, 2025
6f534b8
hello-world: now using codefences for long prompts
akollegger Dec 17, 2025
bffde24
hello-world: test coverage; error-handling
akollegger Dec 18, 2025
3dc6ac4
Update cabal.project to use git source repositories for pattern, subj…
akollegger Dec 18, 2025
e89fa6b
hello-world: ready for PR
akollegger Dec 18, 2025
e0a6fb3
hello-world: bumped haskell CI to use ghc 9.10.3
akollegger Dec 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .cursor/rules/gram-validation.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Gram Syntax Validation Rules

## Validation Requirement
- **Always** validate gram notation syntax using `gram-lint` CLI tool
- Run validation on any `.gram` file before considering it complete
- All gram examples must pass `gram-lint` syntax checks

## Usage
```bash
gram-lint path/to/file.gram
```

## When to Validate
- Before committing changes to `.gram` files
- When creating new gram examples in tests or documentation
- When modifying existing gram notation
- As part of code review process

## Examples
All gram syntax in these locations must be validated:
- `specs/**/*.gram` - Specification examples
- `docs/**/*.gram` - Documentation examples
- `tests/**/*.gram` - Test fixtures
- Any inline gram notation in code comments or documentation

## Integration
- When writing or modifying gram notation, verify syntax with `gram-lint` to ensure correctness
- All gram examples in code, tests, and documentation should pass `gram-lint` validation
- If `gram-lint` reports errors, fix the syntax before proceeding
2 changes: 2 additions & 0 deletions .cursor/rules/specify-rules.mdc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Auto-generated from all feature plans. Last updated: 2025-12-10

## Active Technologies
- In-memory conversation context (no persistence required for initial implementation) (002-llm-agent)
- In-memory tool registry and conversation context (no persistence required for initial implementation) (003-hello-world-agent)

- Haskell / GHC 2024 (GHC2024 language standard) (001-foundation-setup)

Expand All @@ -23,6 +24,7 @@ tests/
Haskell / GHC 2024 (GHC2024 language standard): Follow standard conventions

## Recent Changes
- 003-hello-world-agent: Added Haskell / GHC 2024 (GHC2024 language standard)
- 002-llm-agent: Added Haskell / GHC 2024 (GHC2024 language standard)

- 001-foundation-setup: Added Haskell / GHC 2024 (GHC2024 language standard)
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-haskell@v1
with:
ghc-version: '8.10.3'
cabal-version: '3.2'
ghc-version: '9.10.3'
cabal-version: 'latest'

- name: Cache
uses: actions/cache@v3
Expand Down
14 changes: 9 additions & 5 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ module AgentTest where

import Test.Tasty
import Test.Tasty.HUnit
import PatternAgent.Agent
import PatternAgent.Language.Core

testAgentCreation :: TestTree
testAgentCreation = testCase "Create agent" $ do
Expand Down Expand Up @@ -362,11 +362,15 @@ Use `haskell-tools.nvim` or `coc-haskell` with HLS.
- **`PatternAgent.Core`**: Core type definitions (re-exports PatternAgent type)
- **`PatternAgent.Types`**: Type aliases and supporting types
- **`PatternAgent.Agent`**: Agent type and creation
- **`PatternAgent.LLM`**: Standalone LLM API client
- **`PatternAgent.Execution`**: Agent execution logic
- **`PatternAgent.Context`**: Conversation context management
- **`PatternAgent.Language.Core`**: Agent and Tool as Pattern Subject, creation, lenses
- **`PatternAgent.Language.Schema`**: Schema validation
- **`PatternAgent.Language.TypeSignature`**: Type signature parsing & JSON schema generation
- **`PatternAgent.Language.Serialization`**: Gram ↔ Pattern conversion
- **`PatternAgent.Runtime.Execution`**: Agent execution engine
- **`PatternAgent.Runtime.ToolLibrary`**: ToolImpl and ToolLibrary
- **`PatternAgent.Runtime.LLM`**: LLM API client
- **`PatternAgent.Runtime.Context`**: Conversation context management
- **`PatternAgent.Env`**: Environment variable loading from .env files
- **`PatternAgent.Tool`**: Tool system (not yet implemented)

### Adding New Features

Expand Down
56 changes: 56 additions & 0 deletions MINIMAL_GRAM_ISSUE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Minimal Example: Multiline Gram Parsing Issue

## Issue Description

When parsing gram notation with multiline format, a newline immediately after `} |` causes a parse error: "unexpected newline".

## Minimal Failing Example

```gram
[test:Agent {
description: "test"
} |
[tool:Tool {description: "test"} | (param::Text)==>(::String)]
]
```

**Error**: `gram:3:4: unexpected newline expecting '"', ''', '(', '-', '@', '[', '`', '{', digit, space, or tab`

The error occurs at position 3:4, which is the newline character immediately after `} |`.

## Working Single-line Version

```gram
[test:Agent {description: "test"} | [tool:Tool {description: "test"} | (param::Text)==>(::String)]]
```

This single-line version parses successfully.

## Test Code

```haskell
import qualified Gram
import qualified Data.Text as T

main = do
let gramMultiline = T.unlines
[ "[test:Agent {"
, " description: \"test\""
, "} |"
, " [tool:Tool {description: \"test\"} | (param::Text)==>(::String)]"
, "]"
]

case Gram.fromGram (T.unpack gramMultiline) of
Right _ -> putStrLn "Success"
Left err -> putStrLn $ "Error: " ++ show err
```

## Expected Behavior

The multiline format should parse successfully, as it's valid gram syntax according to `gram-lint`. The parser should handle newlines after `} |` when followed by pattern elements on subsequent lines.

## Context

This issue was discovered when writing tests for `pattern-agent` that parse agents with nested tools from gram notation. The example file `specs/003-hello-world-agent/examples/helloAgent.gram` uses the same multiline format and passes `gram-lint`, but fails when parsed programmatically with `Gram.fromGram`.

50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,56 @@ Areas under active exploration:

Early development - establishing foundations through practical examples.

## Running the CLI

The pattern-agent CLI can be used to execute agents from gram files or interact directly with LLMs.

### Building

```bash
cabal build
```

### Usage

**Important:** When using `cabal exec pattern-agent`, you must use `--` to separate cabal's flags from pattern-agent's flags:

```bash
# Standard mode (direct LLM interaction)
cabal exec pattern-agent -- "What is the capital of France?"

# With debug output
cabal exec pattern-agent -- --debug "What is the capital of France?"

# Agent mode (load agent from gram file with tool support)
cabal exec pattern-agent -- --agent examples/helloAgent.gram "Hello!"

# Agent mode with debug
cabal exec pattern-agent -- --agent examples/helloAgent.gram --debug "Hello!"
```

### Prerequisites

Set the `OPENAI_API_KEY` environment variable:

```bash
export OPENAI_API_KEY=your-api-key-here
```

### After Installation

If you install the executable:

```bash
cabal install --installdir=$HOME/.local/bin
```

You can then run it directly without `cabal exec`:

```bash
pattern-agent --agent examples/helloAgent.gram "Hello!"
```

## Future Directions

- Decomposition toolkit with factorization strategies
Expand Down
Loading
Loading