spl-lang 0.3.0 → 0.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/README.md +4 -4
- package/dist/ast.d.ts +1 -1
- package/dist/llm.d.ts +1 -1
- package/dist/llm.js +1 -1
- package/dist/parser.js +6 -6
- package/docs/syntax.ebnf +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ under `~/.spl` (override with `SPL_HOME`); `spl logout` removes those saved cred
|
|
|
30
30
|
Prose and code fences are not silently extracted.
|
|
31
31
|
- **Repairs:** `repairs=0..5` retries only malformed/invalid generation, not transport errors
|
|
32
32
|
or external actions. Agents require `repairs=0`. Use `assert` for business rules.
|
|
33
|
-
- **Guidance:** `
|
|
33
|
+
- **Guidance:** `enforce`/`forbid` and `len` influence prompts, not runtime guarantees.
|
|
34
34
|
- **Capabilities:** nested `restrict fs/net/exec/mcp` clauses intersect. Shell command
|
|
35
35
|
inspection is best effort; MCP servers are trusted services, not OS-sandboxed.
|
|
36
36
|
- **Bindings:** `let` declares/redeclares function/script locals; `x = ...` and `x += ...`
|
|
@@ -85,7 +85,7 @@ See [embedding](../docs/internals.html#embedding).
|
|
|
85
85
|
|
|
86
86
|
## Migration
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
and `let` before
|
|
90
|
-
`reasoning`, ordinary raw functions, and explicit agents instead.
|
|
88
|
+
Use `enforce` and `forbid` for scoped prompt guidance; `instruct` and `avoid` are not accepted.
|
|
89
|
+
0.3 removes `think{level=...}`, tool-command syntax, and `let` before
|
|
90
|
+
compound/member/index assignments. Use `reasoning`, ordinary raw functions, and explicit agents instead.
|
|
91
91
|
Bare blocks no longer create scopes. See the [migration table](../README.md#breaking-changes-in-03).
|
package/dist/ast.d.ts
CHANGED
package/dist/llm.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { ToolHost } from './tools.js';
|
|
|
4
4
|
import { type Value } from './values.js';
|
|
5
5
|
export type ReasoningLevel = 'low' | 'medium' | 'high';
|
|
6
6
|
export interface Constraint {
|
|
7
|
-
kind: '
|
|
7
|
+
kind: 'enforce' | 'forbid';
|
|
8
8
|
text: string;
|
|
9
9
|
}
|
|
10
10
|
export interface LlmRequest {
|
package/dist/llm.js
CHANGED
|
@@ -14,7 +14,7 @@ export function buildPrompt(opts) {
|
|
|
14
14
|
const sections = [];
|
|
15
15
|
if (opts.constraints.length) {
|
|
16
16
|
sections.push('Response guidance (not runtime validation):\n' +
|
|
17
|
-
opts.constraints.map((c) => `- ${c.kind === '
|
|
17
|
+
opts.constraints.map((c) => `- ${c.kind === 'enforce' ? 'Follow' : 'Avoid'}: ${c.text}`).join('\n'));
|
|
18
18
|
}
|
|
19
19
|
const guidance = opts.restrictions.guidance();
|
|
20
20
|
if (guidance.length)
|
package/dist/parser.js
CHANGED
|
@@ -2,7 +2,7 @@ import { SplSyntaxError } from './errors.js';
|
|
|
2
2
|
import { tokenize } from './lexer.js';
|
|
3
3
|
const KEYWORDS = new Set([
|
|
4
4
|
'let', 'if', 'elif', 'else', 'for', 'in', 'while', 'def', 'return', 'try', 'except', 'assert', 'fail',
|
|
5
|
-
'success', '
|
|
5
|
+
'success', 'enforce', 'forbid', 'restrict', 'think', 'agent', 'break', 'continue', 'pass', 'and', 'or', 'not',
|
|
6
6
|
'True', 'False', 'None',
|
|
7
7
|
]);
|
|
8
8
|
export const MODIFIER_NAMES = ['len', 'fmt', 'reasoning', 'show', 'schema', 'repairs', 'model'];
|
|
@@ -242,17 +242,17 @@ class Parser {
|
|
|
242
242
|
this.next();
|
|
243
243
|
return { t: 'success', line, value: this.atStatementEnd() ? undefined : this.parseExpr() };
|
|
244
244
|
}
|
|
245
|
-
case '
|
|
246
|
-
case '
|
|
245
|
+
case 'enforce':
|
|
246
|
+
case 'forbid': {
|
|
247
247
|
const kind = t.value;
|
|
248
248
|
this.next();
|
|
249
249
|
const text = this.parseExpr();
|
|
250
250
|
return { t: 'constraint', line, kind, text, body: this.parseBlock() };
|
|
251
251
|
}
|
|
252
252
|
case 'restrict': return this.parseRestrict();
|
|
253
|
-
case '
|
|
254
|
-
case '
|
|
255
|
-
this.fail(`
|
|
253
|
+
case 'instruct':
|
|
254
|
+
case 'avoid':
|
|
255
|
+
this.fail(`use '${t.value === 'instruct' ? 'enforce' : 'forbid'}' instead of '${t.value}' for scoped prompt guidance`);
|
|
256
256
|
default:
|
|
257
257
|
break;
|
|
258
258
|
}
|
package/docs/syntax.ebnf
CHANGED
|
@@ -20,7 +20,7 @@ for_stmt = "for" , NAME , { "," , NAME } , "in" , expr , block ;
|
|
|
20
20
|
while_stmt = "while" , expr , block ;
|
|
21
21
|
def_stmt = "def" , NAME , "(" , [ NAME , { "," , NAME } , [ "," ] ] , ")" , block ;
|
|
22
22
|
try_stmt = "try" , block , NL* , "except" , NAME , block ;
|
|
23
|
-
guidance_stmt = ( "
|
|
23
|
+
guidance_stmt = ( "enforce" | "forbid" ) , expr , block ;
|
|
24
24
|
restrict_stmt = "restrict" , restrict_clause , { "," , restrict_clause } , block ;
|
|
25
25
|
restrict_clause = [ "fs" | "net" | "exec" | "mcp" ] , expr ;
|
|
26
26
|
|
|
@@ -63,7 +63,8 @@ modifier = ( "len" | "fmt" | "reasoning" | "show" | "schema" | "repairs" |
|
|
|
63
63
|
Generation (? and think) has no tools. agent explicitly enables restricted runtime/MCP tools.
|
|
64
64
|
Raw tools are ordinary positional functions: read_file(path), write_file(path, content),
|
|
65
65
|
web_fetch(url), web_search(query), shell(command). They never invoke a model.
|
|
66
|
-
|
|
66
|
+
enforce/forbid are scoped prompt guidance.
|
|
67
|
+
schema/assert validate data; restrict checks actions. *)
|
|
67
68
|
|
|
68
69
|
string = [ "r" ] , quote , { char | escape | interpolation } , closing_quote ;
|
|
69
70
|
quote = "'" | '"' | "'''" | '"""' ;
|
|
@@ -76,6 +77,6 @@ NL = newline ;
|
|
|
76
77
|
|
|
77
78
|
(* "{{"/"}}" are literal braces; raw strings have no interpolation or escapes.
|
|
78
79
|
Reserved words: let if elif else for in while def return try except assert fail success
|
|
79
|
-
|
|
80
|
-
Removed syntax:
|
|
80
|
+
enforce forbid restrict think agent break continue pass and or not True False None.
|
|
81
|
+
Removed syntax: think{level=...}, tool{param=...} 'instructions',
|
|
81
82
|
let x += ... and let d.key = ... . *)
|