Texts that named what does not exist (T1-T5, T16, T21), and a check for tool names
- family/anthropic.md: plan_write/plan_update and their statuses, not the todo tool removed in spec 1.1.0. - ask_user's result: 'call ask_user again', not 'question'. - --help: -m takes a model's id; settings.json's example likewise. - /trust makes the project directory, so 'no project directory yet — /trust creates it' is true; it points at /reload. - SECURITY.md: auto mode. - tasks.json: the plan, not 'todo', is the checklist of the task at hand. - tests/harness.test.ts: no prompt text, tool description or tool result may name a tool the registry does not have, or a former name of one. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
9 files changed
+90
-9
No files matched your search
@@ -66,6 +66,16 @@ All notable changes to LLeMbas CLI. The format follows
|
||||
gets TERM, then KILL. A foreground command that ends but leaves a program running
|
||||
(`server &`) says so in its result. A program that must outlive lembas has to leave the
|
||||
group (`setsid`); `nohup … &` alone does not.
|
||||
- **Texts that named what does not exist.** The prompt for Claude-family models told them to
|
||||
use a `todo` tool with statuses the plan does not have (it is `plan_write`/`plan_update`,
|
||||
`doing` and `done`); a question answered with a question told the model to "call question
|
||||
again" (the tool is `ask_user`); `--help` showed `--model conn/model` (2.0 has no connection
|
||||
prefix: a model is named by its id); `SECURITY.md` spoke of an `unrestricted` mode (`auto`).
|
||||
A check now fails when a prompt, a tool description or a tool's result names a tool that does
|
||||
not exist.
|
||||
- **`/trust` makes the project directory** when the project has none — `/tasks`, `/decisions`
|
||||
and `/decide` said "/trust creates it", and it did not — and says `/reload` loads the
|
||||
project's config (it said to restart).
|
||||
- A command that could not be started says why instead of "stopped (SIGTERM)".
|
||||
|
||||
### Terminal — LLeMbas TTY is now LLeMbas TERM
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ untrusted. A report is most useful when it shows one of these:
|
||||
- secrets — API keys, OAuth tokens — written somewhere readable, logged, or sent to a host other
|
||||
than the one they belong to.
|
||||
|
||||
A model doing something unwise **with** the user's approval, or in `unrestricted` mode, is how
|
||||
A model doing something unwise **with** the user's approval, or in `auto` mode, is how
|
||||
LLeMbas CLI is meant to work, not a vulnerability; ways to make that clearer are still welcome as
|
||||
ordinary issues ([GitHub Issues](https://github.com/LLeMbas/LLeMbas-CLI/issues)).
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!-- Source: OpenCode session/prompt/anthropic.txt (MIT, © 2025 opencode) — professional
|
||||
objectivity and todo discipline; product references removed, tool names the CLI's. -->
|
||||
objectivity and plan discipline; product references removed, tool names the CLI's. -->
|
||||
# Professional objectivity
|
||||
Prioritise technical accuracy over agreeing with the user. Give direct, objective information without superlatives, praise or emotional validation, and disagree when the facts call for it — respectful correction is worth more than false agreement. When unsure, investigate before confirming what the user believes.
|
||||
|
||||
# Tracking the work
|
||||
For anything with three or more steps, use the todo tool from the start and keep it current: one item in_progress at a time, marked completed the moment it is done — never in a batch at the end. It is how the user sees where you are.
|
||||
For anything with three or more steps, write a plan with plan_write from the start and keep it current with plan_update: one task doing at a time, marked done the moment it is checked — never in a batch at the end. It is how the user sees where you are.
|
||||
@@ -27,7 +27,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"value": {
|
||||
"description": "set: the new value, as text — high, connection/model, 0.7, true, a list as ddg,searxng.",
|
||||
"description": "set: the new value, as text — high, a model's id, 0.7, true, a list as ddg,searxng.",
|
||||
"type": "string"
|
||||
},
|
||||
"scope": {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"cli": [],
|
||||
"llembas": []
|
||||
},
|
||||
"description": "The project's task board (.agent/tasks.md): work that outlives this session — as opposed to todo, which is your checklist for the task at hand.\n\n- list: show the board. add: a new item (to todo unless you say). move: an item to todo, doing or done. remove: drop an item.\n- Add what the user asks you to remember or what you find that should be done later; move items as you work on them. Refer to items by their number.",
|
||||
"description": "The project's task board (.agent/tasks.md): work that outlives this session — as opposed to your plan (plan_write), which is for the task at hand.\n\n- list: show the board. add: a new item (to todo unless you say). move: an item to todo, doing or done. remove: drop an item.\n- Add what the user asks you to remember or what you find that should be done later; move items as you work on them. Refer to items by their number.",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
|
||||
+2
-1
@@ -105,7 +105,8 @@ Local mode:
|
||||
start asks, and the answer is kept in the local directory.
|
||||
|
||||
Options for run:
|
||||
-m, --model conn/model model to use (default: the project's \`model\`, else the one last used in
|
||||
-m, --model ID a model the server serves, by its id — lembas models lists them
|
||||
(default: the project's \`model\`, else the one last used in
|
||||
this directory, else config.yaml \`model\`). With no terminal at
|
||||
all (cron, a pipeline) a model for interactive use only is refused:
|
||||
run it at a terminal (ssh -t), or name another model
|
||||
|
||||
@@ -128,7 +128,7 @@ export function formatAnswers(req: QuestionRequest, reply: QuestionReply): strin
|
||||
const final = req.questions.map((_, i) => i + 1).filter((n) => !back.includes(n))
|
||||
lines.push(
|
||||
"",
|
||||
`${final.length ? `Q${final.join(", Q")} ${final.length > 1 ? "are" : "is"} answered. ` : ""}Instead of answering Q${back.join(", Q")}, the user asked you a question. Answer it in your reply, then call question again with only Q${back.join(", Q")} — adjusted if your answer changes the options.`,
|
||||
`${final.length ? `Q${final.join(", Q")} ${final.length > 1 ? "are" : "is"} answered. ` : ""}Instead of answering Q${back.join(", Q")}, the user asked you a question. Answer it in your reply, then call ask_user again with only Q${back.join(", Q")} — adjusted if your answer changes the options.`,
|
||||
)
|
||||
}
|
||||
return lines.join("\n")
|
||||
|
||||
+11
-2
@@ -1,5 +1,6 @@
|
||||
// Built-in slash commands; custom markdown commands, skills and MCP prompts join them in the
|
||||
// palette.
|
||||
import { initProjectDir } from "../project/init.ts"
|
||||
import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs"
|
||||
import { terminalCommands } from "../terminal/command.ts"
|
||||
import { join } from "node:path"
|
||||
@@ -1394,10 +1395,18 @@ export const COMMANDS: Command[] = [
|
||||
},
|
||||
{
|
||||
name: "trust",
|
||||
description: "trust this project (its .agent config is then honoured — restart to apply)",
|
||||
description: "trust this project: its project directory is made if there is none, and its config honoured after /reload",
|
||||
run(c) {
|
||||
setTrust(c.app.project.root, "trusted")
|
||||
c.view.info(`${c.app.project.root} is trusted. Restart lembas to load its config.`)
|
||||
// The first-run screen makes the project directory only when it is answered "trust"; a
|
||||
// project first opened read-only gets it here, so /tasks, /decide and the rest have a place.
|
||||
let made: string[] = []
|
||||
try {
|
||||
made = initProjectDir(c.app.project)
|
||||
} catch (e) {
|
||||
c.view.info(`could not make ${c.app.project.dir}: ${(e as Error).message}`, "warn")
|
||||
}
|
||||
c.view.info(`${c.app.project.root} is trusted${made.length ? ` (made ${made.join(", ")})` : ""}. /reload loads its config.`)
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
@@ -255,3 +255,64 @@ test("acp.md names every _lembas method the code handles or sends, and every cap
|
||||
const { LEMBAS_PROTOCOL } = await import("../src/acp/agent.ts")
|
||||
expect(doc).toContain(`**${LEMBAS_PROTOCOL}**. CLI`)
|
||||
})
|
||||
|
||||
// A text that names a tool names one that exists. A prompt told every Claude-family model to
|
||||
// "use the todo tool" two majors after it had gone, and a tool's result told the model to "call
|
||||
// question again"; neither failed anything, because a call under a former name is still
|
||||
// converted. Three readings, over every prompt text, every description in harness/tools and the
|
||||
// tools' own source (their results are texts the model reads):
|
||||
// `X tool` X is a tool, or an ordinary word (the list below)
|
||||
// call X again X is a tool
|
||||
// a former tool name (an alias in the spec) never stands in backquotes, before "tool", or
|
||||
// after "call"/"use the"
|
||||
function toolMentions(text: string): { former: string[]; unknown: string[] } {
|
||||
const tools = new Set(Object.keys(TOOL_SPECS))
|
||||
const formerNames = new Set(Object.values(TOOL_SPECS).flatMap((t) => [...t.aliases.cli, ...t.aliases.llembas]).filter((n) => !tools.has(n)))
|
||||
// Words that stand before "tool" without being one's name.
|
||||
const ordinary = new Set("a the that this no its real stored outside how do every each contains prompts another any one same other which whose what of or and your their right wrong new old first next last single shared file web search team plan job mcp dedicated specific earlier s".split(" "))
|
||||
const former = new Set<string>()
|
||||
const unknown = new Set<string>()
|
||||
for (const m of text.matchAll(/`?\b([a-z][a-z_]*)`? tool\b(?!s)/g)) {
|
||||
const w = m[1]!
|
||||
if (formerNames.has(w)) former.add(w)
|
||||
else if (!tools.has(w) && !ordinary.has(w)) unknown.add(w)
|
||||
}
|
||||
for (const m of text.matchAll(/\b[Cc]all `?([a-z][a-z_]*)`? again\b/g)) {
|
||||
const w = m[1]!
|
||||
if (formerNames.has(w)) former.add(w)
|
||||
else if (!tools.has(w) && !["it", "them", "that", "this"].includes(w)) unknown.add(w)
|
||||
}
|
||||
// In backquotes a former name is a tool's — unless some tool has a parameter of that name
|
||||
// (`notes` is a field of a calendar event).
|
||||
const params = new Set(Object.values(TOOL_SPECS).flatMap((t) => Object.keys((t.parameters.properties ?? {}) as object)))
|
||||
for (const n of formerNames) if (new RegExp((params.has(n) ? "" : "`" + n + "`|") + "\\b(?:[Cc]all|[Uu]se the|[Ww]ith the) " + n + "\\b").test(text)) former.add(n)
|
||||
return { former: [...former], unknown: [...unknown] }
|
||||
}
|
||||
|
||||
test("the reader of tool mentions finds the two that were wrong", () => {
|
||||
expect(toolMentions("use the todo tool from the start")).toEqual({ former: ["todo"], unknown: [] })
|
||||
expect(toolMentions("Answer it in your reply, then call question again with only Q2")).toEqual({ former: ["question"], unknown: [] })
|
||||
expect(toolMentions("Use the frobnicate tool, then call frob again.")).toEqual({ former: [], unknown: ["frobnicate", "frob"] })
|
||||
expect(toolMentions("the read tool, the `plan_write` tool, a tool, call ask_user again, add to todo, doing or done")).toEqual({ former: [], unknown: [] })
|
||||
})
|
||||
|
||||
test("no prompt text, tool description or tool result names a tool the registry does not have", () => {
|
||||
const walk = (d: string, ext: string): string[] => readdirSync(d, { withFileTypes: true }).flatMap((e) => (e.isDirectory() ? walk(join(d, e.name), ext) : e.name.endsWith(ext) ? [join(d, e.name)] : []))
|
||||
const bad: Record<string, unknown> = {}
|
||||
const look = (name: string, text: string) => {
|
||||
const m = toolMentions(text)
|
||||
if (m.former.length || m.unknown.length) bad[name] = m
|
||||
}
|
||||
// Without the source comment at a prompt's head, which may name what a text came from.
|
||||
for (const f of walk(join(HARNESS, "prompts"), ".md")) look(relative(HARNESS, f), readFileSync(f, "utf8").replace(/<!--[\s\S]*?-->/g, ""))
|
||||
const strings = (x: unknown): string[] => (typeof x === "string" ? [x] : Array.isArray(x) ? x.flatMap(strings) : x && typeof x === "object" ? Object.entries(x).flatMap(([k, v]) => (k === "aliases" || k === "argument_aliases" ? [] : strings(v))) : [])
|
||||
for (const f of walk(join(HARNESS, "tools"), ".json")) look(relative(HARNESS, f), strings(JSON.parse(readFileSync(f, "utf8"))).join("\n"))
|
||||
for (const f of ["loop.json", "purpose.json"]) look(f, strings(JSON.parse(readFileSync(join(HARNESS, f), "utf8"))).join("\n"))
|
||||
// The tools' own texts: every string and template in src/tool, comments left out.
|
||||
for (const f of walk(join(HARNESS, "..", "src", "tool"), ".ts")) {
|
||||
if (f.endsWith("names.ts")) continue
|
||||
const code = readFileSync(f, "utf8").replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "")
|
||||
look(relative(join(HARNESS, ".."), f), (code.match(/"(?:[^"\\\n]|\\.)*"|`(?:[^`\\]|\\.)*`/g) ?? []).join("\n"))
|
||||
}
|
||||
expect(bad).toEqual({})
|
||||
})
|
||||
Reference in new issue
Block a user