@goldensheepai/shep-core
v0.1.4
Published
Shep language core: parser, verifier, type system, and code generation
Readme
@goldensheepai/shep-core
The core engine for ShepLang — parser, verifier, type system, and AST.
What is shep-core?
shep-core is the foundational package for ShepLang. It provides:
- Lexer & Parser — Tokenizes and parses
.shepfiles into an AST - Type System — Full type inference and checking for ShepLang constructs
- Verifier — Validates specs for correctness, wiring, and constraint satisfaction
- AST Types — TypeScript interfaces for the entire ShepLang AST
Installation
npm install @goldensheepai/shep-coreUsage
import { parse, verifySpec } from '@goldensheepai/shep-core';
// Parse a ShepLang program
const source = `
app "MyApp"
data User {
email: text (required)
role: enum(admin, user)
}
`;
const ast = parse(source);
// Verify the spec
const result = verifySpec(ast);
if (result.issues.length === 0) {
console.log('Spec is valid!');
} else {
result.issues.forEach(issue => {
console.log(`${issue.severity}: ${issue.message}`);
});
}API Reference
parse(source: string): ShepSpec
Parses ShepLang source code and returns the AST.
verifySpec(spec: ShepSpec): VerificationResult
Validates a parsed spec for:
- Type correctness
- Entity/screen/flow wiring
- Constraint satisfaction
- Relationship cycles
tokenize(source: string): Token[]
Returns the token stream for a ShepLang program.
AST Types
The package exports all AST node types:
import type {
ShepSpec,
EntityNode,
ScreenNode,
FlowNode,
RuleNode,
FieldNode,
AINode
} from '@goldensheepai/shep-core';Error Codes
| Code | Description | |------|-------------| | E001 | Unknown entity reference | | E002 | Unknown field reference | | E003 | Type mismatch | | S001 | Screen references unknown entity | | F001 | Flow references unknown screen | | R001 | Rule constraint conflict |
Related Packages
- @goldensheepai/shep-cli — CLI tool
- @goldensheepai/shep-sheplang — TypeScript codegen
- @goldensheepai/shep-shepthon — Python codegen
- @goldensheepai/shep-lsp — Language Server
License
MIT © Golden Sheep AI
