flaude-harness 0.0.0-stage → 1.0.3
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 +150 -2
- package/bin/flaude +10 -0
- package/bin/flaude-admin +10 -0
- package/bin/flaude-admin.cmd +7 -0
- package/bin/flaude-admin.ps1 +8 -0
- package/bin/flaude.cmd +7 -0
- package/bin/flaude.ps1 +8 -0
- package/dist/plugin/hooks/core.js +421 -0
- package/dist/src/cli/certify.js +428 -0
- package/dist/src/cli/flaude-admin.js +900 -0
- package/dist/src/core/broker.js +113 -0
- package/dist/src/core/credentials.js +119 -0
- package/dist/src/core/lock.js +77 -0
- package/dist/src/core/log.js +53 -0
- package/dist/src/core/paths.js +61 -0
- package/dist/src/core/redact.js +161 -0
- package/dist/src/core/register.js +164 -0
- package/dist/src/core/registry.js +81 -0
- package/dist/src/install/cli.js +93 -0
- package/dist/src/install/install.js +759 -0
- package/dist/src/install/layout.js +116 -0
- package/dist/src/install/manifest.js +83 -0
- package/dist/src/install/probe.js +281 -0
- package/dist/src/install/settings.js +266 -0
- package/dist/src/launcher/flaude.js +377 -0
- package/dist/src/local/gguf.js +372 -0
- package/dist/src/local/index.js +19 -0
- package/dist/src/local/scan.js +556 -0
- package/dist/src/local/serve.js +429 -0
- package/dist/src/router/governor.js +133 -0
- package/dist/src/router/records.js +149 -0
- package/dist/src/router/repair.js +220 -0
- package/dist/src/router/residency.js +70 -0
- package/dist/src/router/responses.js +221 -0
- package/dist/src/router/sanitize.js +111 -0
- package/dist/src/router/server.js +1679 -0
- package/dist/src/router/steward.js +391 -0
- package/dist/src/router/translate.js +803 -0
- package/dist/src/steward/hooks.js +701 -0
- package/dist/src/steward/requirements.js +340 -0
- package/dist/src/steward/verify.js +522 -0
- package/dist/tests/certify.test.js +481 -0
- package/dist/tests/core.test.js +559 -0
- package/dist/tests/identity.test.js +101 -0
- package/dist/tests/install.test.js +723 -0
- package/dist/tests/local.test.js +660 -0
- package/dist/tests/plugin.test.js +301 -0
- package/dist/tests/preanswer.test.js +294 -0
- package/dist/tests/router.test.js +1175 -0
- package/dist/tests/steward.test.js +860 -0
- package/docs/reference/install.md +159 -0
- package/docs/reference/models.md +174 -0
- package/docs/reference/operations.md +74 -0
- package/docs/reference/steward.md +79 -0
- package/docs/reference/windows-validation.md +150 -0
- package/package.json +29 -4
- package/plugin/.claude-plugin/plugin.json +10 -0
- package/plugin/README.md +23 -0
- package/plugin/assets/flaude-splash.png +0 -0
- package/plugin/hooks/control.ts +115 -0
- package/plugin/hooks/core.ts +470 -0
- package/plugin/hooks/hooks.json +3 -0
- package/plugin/hooks/importer.tsx +128 -0
- package/plugin/hooks/picker.tsx +87 -0
- package/plugin/hooks/register.tsx +467 -0
- package/plugin/hooks/secret.ts +25 -0
- package/plugin/tests/panes.test.tsx +195 -0
- package/plugin/tsconfig.json +3 -0
- package/plugin/types/index.d.ts +67 -0
- package/steward/hooks/post_write.py +67 -0
- package/steward/hooks/post_write.sh +16 -0
- package/steward/hooks/pre_bash.py +112 -0
- package/steward/hooks/pre_bash.sh +16 -0
- package/steward/hooks/session_start.py +175 -0
- package/steward/hooks/session_start.sh +15 -0
- package/steward/hooks/steward_lib.py +1012 -0
- package/steward/hooks/stop.py +163 -0
- package/steward/hooks/stop.sh +15 -0
- package/steward/system-prompt.md +452 -0
package/README.md
CHANGED
|
@@ -1,3 +1,151 @@
|
|
|
1
|
-
#
|
|
1
|
+
# FLAUDE
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="docs/assets/flaude-splash.png" alt="FLAUDE — Founders Edition: two black cats under a neon rainbow prism" width="320">
|
|
4
|
+
|
|
5
|
+
**One harness, one identity, every vendor.** Built in a garage in Brown County, Indiana, because
|
|
6
|
+
switching models shouldn't mean switching tools, re-reading your own project to a stranger, or
|
|
7
|
+
signing up for another subscription treadmill.
|
|
8
|
+
|
|
9
|
+
FLAUDE is a Claude Code harness that stays *you* while the model underneath changes. Mid-session.
|
|
10
|
+
No restart. DeepSeek, Z.AI's GLM, OpenAI, Ollama, or a GGUF file sitting on your own disk — the
|
|
11
|
+
conversation, the goal you stated, and the work already done all survive the swap.
|
|
12
|
+
|
|
13
|
+
Listen instead of reading: [the README, narrated in 3 min 38 s](https://theworkingcopy.floydslabs.com/flaude-harness/audio.html).
|
|
14
|
+
|
|
15
|
+
<p align="center">
|
|
16
|
+
<img src="docs/assets/screens/01-model-manager.png" alt="The model manager listing models with provider, protocol, window, grade and auth" width="900">
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
## What it is, without the marketing department
|
|
20
|
+
|
|
21
|
+
Claude Code is a great front door. It is also a front door with one key. FLAUDE keeps the door and
|
|
22
|
+
replaces the lock.
|
|
23
|
+
|
|
24
|
+
The model manager lives inside the harness. It adds a provider by address, adds a local model by
|
|
25
|
+
path, tests it step by step, and grades it **before** you trust it with your afternoon. The grade
|
|
26
|
+
is not a vibe — it's tool calls in one step, tool calls in sequence, streaming, obedience,
|
|
27
|
+
structured output and recall at depth, run for real and stamped with how long ago it was measured.
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
MODEL PROVIDER PROTOCOL WINDOW GRADE SOURCE AUTH
|
|
31
|
+
ollama/chimera-beta-local:latest ollama ollama catalog 66K A 21h local none
|
|
32
|
+
deepseek/deepseek-flash deepseek anthropic unknown A 21h cloud broker lease (claude → deepseek)
|
|
33
|
+
* openai/gpt-6.2-sol openai openai catalog 1050K A 21h cloud broker lease (claudx → openai)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`*` is what new sessions start on. Switch a live session with `flaude-admin use <model>`.
|
|
37
|
+
|
|
38
|
+
## The part we actually care about: it doesn't hand you a menu
|
|
39
|
+
|
|
40
|
+
Every session gets the steward system prompt, and the four steward hooks are wired in. FLAUDE adds
|
|
41
|
+
its own behaviour on top: the goal you stated is carried across vendor switches, questions you
|
|
42
|
+
already answered don't come back, and a turn that would hand back unfinished work gets continued.
|
|
43
|
+
The full behaviour is in [docs/reference/steward.md](docs/reference/steward.md).
|
|
44
|
+
|
|
45
|
+
That is not a paragraph asking the model nicely. It is a stop-hook check, and it says no:
|
|
46
|
+
|
|
47
|
+
<p align="center">
|
|
48
|
+
<img src="docs/assets/screens/03-steward.png" alt="The stop hook returning decision block for a menu and for a known next action" width="900">
|
|
49
|
+
</p>
|
|
50
|
+
|
|
51
|
+
A hedged offer is refused. A "would you like me to…" is refused. A turn that tries to end while the
|
|
52
|
+
next action is known is refused. A question that reaches you without a recommended path is refused.
|
|
53
|
+
What survives is a recommendation and the work already done — which is the only honest thing a tool
|
|
54
|
+
can hand back at 2:47 AM.
|
|
55
|
+
|
|
56
|
+
## Install
|
|
57
|
+
|
|
58
|
+
You need **Node.js 22 or newer** and **Claude Code** (`claude` on PATH). That's the list.
|
|
59
|
+
|
|
60
|
+
macOS and Ubuntu, from the folder that holds this file:
|
|
61
|
+
|
|
62
|
+
```sh
|
|
63
|
+
sh install.sh
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Windows PowerShell 5.1 or PowerShell 7, in that folder:
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
.\install.ps1
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
If your script policy stops `install.ps1`, run `install.cmd` instead: it runs the same commands and
|
|
73
|
+
is not a script, so no policy applies.
|
|
74
|
+
|
|
75
|
+
The installer looks at the machine first and **prints what it found**: Node, Claude Code, a steward
|
|
76
|
+
install, broker credentials (their presence only — that file is never read), Ollama and the local
|
|
77
|
+
model servers, the usual model folders, and the other harnesses on the machine (read-only; FLAUDE
|
|
78
|
+
never changes them). Then it installs without asking a single question, and if something needed is
|
|
79
|
+
missing it stops with a plain reason instead of a stack trace.
|
|
80
|
+
|
|
81
|
+
Start it:
|
|
82
|
+
|
|
83
|
+
```sh
|
|
84
|
+
flaude
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Check the whole stack without changing anything:
|
|
88
|
+
|
|
89
|
+
```sh
|
|
90
|
+
flaude-admin doctor
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
<p align="center">
|
|
94
|
+
<img src="docs/assets/screens/02-doctor.png" alt="flaude-admin doctor reporting every check ok and All checks passed" width="900">
|
|
95
|
+
</p>
|
|
96
|
+
|
|
97
|
+
## What you get
|
|
98
|
+
|
|
99
|
+
| Piece | What it does |
|
|
100
|
+
|---|---|
|
|
101
|
+
| `flaude` | Starts Claude Code in FLAUDE's own configuration, with a router for this session on loopback. |
|
|
102
|
+
| The router | Sends each request to the session's current model, translated when the vendor does not speak Claude Code's protocol. A vendor that fails is replaced by the next one in your chain. |
|
|
103
|
+
| `/models` | The picker: browse, see status and context, switch now. |
|
|
104
|
+
| `/models add` | Add a provider by address or a local model by path, test it step by step, grade it, save it. |
|
|
105
|
+
| `flaude-admin` | The command line for all of it: `list`, `use`, `add`, `test`, `certify`, `doctor`, `log`, `cost`, `export`, `import`. |
|
|
106
|
+
| Local models | GGUF files and MLX folders are found and read from their own metadata; a model is served on demand and stopped when you switch away. |
|
|
107
|
+
|
|
108
|
+
It runs on macOS, Ubuntu and Windows PowerShell. The installer, the launcher, the paths, the router
|
|
109
|
+
and these documents contain no macOS-only assumption.
|
|
110
|
+
|
|
111
|
+
## Where things live
|
|
112
|
+
|
|
113
|
+
| | macOS, Ubuntu | Windows |
|
|
114
|
+
|---|---|---|
|
|
115
|
+
| Config and history | `~/.config/flaude` | `%APPDATA%\flaude` |
|
|
116
|
+
| The program | `~/.config/flaude/app` | `%APPDATA%\flaude\app` |
|
|
117
|
+
| State: models, logs, keys | `~/.config/flaude/state` | `%LOCALAPPDATA%\flaude` |
|
|
118
|
+
| Launcher entries | `~/.local/bin/flaude`, `~/.local/bin/flaude-admin` | `%LOCALAPPDATA%\flaude\bin\flaude.cmd`, `flaude-admin.cmd` |
|
|
119
|
+
|
|
120
|
+
The other harnesses on the machine (`claude`, `zlaude`, `dlaude`, `claudx`) are not touched.
|
|
121
|
+
|
|
122
|
+
The management commands also work without the second name: `flaude doctor`, `flaude use <model>`,
|
|
123
|
+
`flaude update`, `flaude rollback`, `flaude export`, `flaude import <file>`, `flaude log`, `flaude cost`,
|
|
124
|
+
`flaude status`, `flaude sessions`, `flaude models`. A management word followed by other words is a
|
|
125
|
+
prompt, not a command: `flaude log the build output` starts a session.
|
|
126
|
+
|
|
127
|
+
## Tests
|
|
128
|
+
|
|
129
|
+
165 of them, and the Stop hook is exercised with real payloads rather than described: a hedge is
|
|
130
|
+
blocked, a known `NEXT` is blocked, a question without a recommendation is blocked, `NEXT: NONE` is
|
|
131
|
+
allowed. On this machine macOS is green, Ubuntu 24.04.5 and Debian are green, and the installer runs
|
|
132
|
+
end to end on all three.
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
npm install && npm run build && npm test
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Documentation
|
|
139
|
+
|
|
140
|
+
- [Install, update, roll back, uninstall](docs/reference/install.md)
|
|
141
|
+
- [Validate on Windows (R153–R155)](docs/reference/windows-validation.md)
|
|
142
|
+
- [Models: switch, add, serve, grade](docs/reference/models.md)
|
|
143
|
+
- [The steward behaviour and its per-project switches](docs/reference/steward.md)
|
|
144
|
+
- [Operations: layout, logs, recovery, security](docs/reference/operations.md)
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
Two black cats run QA here. Bella (Senior Quality Assurance, Rubenesque, walks on keyboards) and
|
|
149
|
+
Bowser (Technical Director, skinny, monitors routers) approved the parts they could sit on.
|
|
150
|
+
|
|
151
|
+
Because existing solutions pissed us off. That's the whole roadmap.
|
package/bin/flaude
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# FLAUDE launcher shim: thin by design; everything portable lives in the Node launcher.
|
|
3
|
+
set -u
|
|
4
|
+
HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) || exit 1
|
|
5
|
+
NODE="${FLAUDE_NODE:-node}"
|
|
6
|
+
if ! command -v "$NODE" >/dev/null 2>&1; then
|
|
7
|
+
echo "flaude: Node.js 22 or newer is required (https://nodejs.org), or set FLAUDE_NODE." >&2
|
|
8
|
+
exit 127
|
|
9
|
+
fi
|
|
10
|
+
exec "$NODE" "$HERE/../dist/src/launcher/flaude.js" "$@"
|
package/bin/flaude-admin
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# FLAUDE control plane shim.
|
|
3
|
+
set -u
|
|
4
|
+
HERE=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P) || exit 1
|
|
5
|
+
NODE="${FLAUDE_NODE:-node}"
|
|
6
|
+
if ! command -v "$NODE" >/dev/null 2>&1; then
|
|
7
|
+
echo "flaude-admin: Node.js 22 or newer is required, or set FLAUDE_NODE." >&2
|
|
8
|
+
exit 127
|
|
9
|
+
fi
|
|
10
|
+
exec "$NODE" "$HERE/../dist/src/cli/flaude-admin.js" "$@"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
REM FLAUDE shim: the .cmd does the launching so PowerShell execution policy is not in the path.
|
|
3
|
+
setlocal
|
|
4
|
+
set "NODE=%FLAUDE_NODE%"
|
|
5
|
+
if "%NODE%"=="" set "NODE=node"
|
|
6
|
+
where "%NODE%" >nul 2>nul || (echo flaude-admin: Node.js 22 or newer is required, or set FLAUDE_NODE. 1>&2 & exit /b 127)
|
|
7
|
+
"%NODE%" "%~dp0..\dist\src\cli\flaude-admin.js" %*
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
# FLAUDE shim for Windows PowerShell 5.1 and PowerShell 7.
|
|
3
|
+
$node = $env:FLAUDE_NODE
|
|
4
|
+
if (-not $node) { $node = "node" }
|
|
5
|
+
if (-not (Get-Command $node -ErrorAction SilentlyContinue)) { Write-Error "flaude-admin: Node.js 22 or newer is required, or set FLAUDE_NODE."; exit 127 }
|
|
6
|
+
$entry = Join-Path $PSScriptRoot "..\dist\src\cli\flaude-admin.js"
|
|
7
|
+
& $node $entry @args
|
|
8
|
+
exit $LASTEXITCODE
|
package/bin/flaude.cmd
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
REM FLAUDE shim: the .cmd does the launching so PowerShell execution policy is not in the path.
|
|
3
|
+
setlocal
|
|
4
|
+
set "NODE=%FLAUDE_NODE%"
|
|
5
|
+
if "%NODE%"=="" set "NODE=node"
|
|
6
|
+
where "%NODE%" >nul 2>nul || (echo flaude: Node.js 22 or newer is required, or set FLAUDE_NODE. 1>&2 & exit /b 127)
|
|
7
|
+
"%NODE%" "%~dp0..\dist\src\launcher\flaude.js" %*
|
package/bin/flaude.ps1
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
$ErrorActionPreference = "Stop"
|
|
2
|
+
# FLAUDE shim for Windows PowerShell 5.1 and PowerShell 7.
|
|
3
|
+
$node = $env:FLAUDE_NODE
|
|
4
|
+
if (-not $node) { $node = "node" }
|
|
5
|
+
if (-not (Get-Command $node -ErrorAction SilentlyContinue)) { Write-Error "flaude: Node.js 22 or newer is required, or set FLAUDE_NODE."; exit 127 }
|
|
6
|
+
$entry = Join-Path $PSScriptRoot "..\dist\src\launcher\flaude.js"
|
|
7
|
+
& $node $entry @args
|
|
8
|
+
exit $LASTEXITCODE
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KEY_NEEDED = exports.RECORD_NOTE = exports.WIDE_ROW = exports.REDACTED = exports.MID = exports.ELLIPSIS = void 0;
|
|
4
|
+
exports.splashImage = splashImage;
|
|
5
|
+
exports.clip = clip;
|
|
6
|
+
exports.pad = pad;
|
|
7
|
+
exports.tokensLabel = tokensLabel;
|
|
8
|
+
exports.windowLabel = windowLabel;
|
|
9
|
+
exports.sourceLabel = sourceLabel;
|
|
10
|
+
exports.gradeLabel = gradeLabel;
|
|
11
|
+
exports.pickerRow = pickerRow;
|
|
12
|
+
exports.rowText = rowText;
|
|
13
|
+
exports.pickerView = pickerView;
|
|
14
|
+
exports.wrap = wrap;
|
|
15
|
+
exports.switchCost = switchCost;
|
|
16
|
+
exports.certifiedLabel = certifiedLabel;
|
|
17
|
+
exports.detailLines = detailLines;
|
|
18
|
+
exports.statusLine = statusLine;
|
|
19
|
+
exports.normalizeQuestion = normalizeQuestion;
|
|
20
|
+
exports.findAnswer = findAnswer;
|
|
21
|
+
exports.appliedAnswer = appliedAnswer;
|
|
22
|
+
exports.preanswerNote = preanswerNote;
|
|
23
|
+
exports.userOnlyQuestion = userOnlyQuestion;
|
|
24
|
+
exports.redact = redact;
|
|
25
|
+
exports.emptyForm = emptyForm;
|
|
26
|
+
exports.idleRun = idleRun;
|
|
27
|
+
exports.suggestId = suggestId;
|
|
28
|
+
exports.inferProtocol = inferProtocol;
|
|
29
|
+
exports.parseList = parseList;
|
|
30
|
+
exports.validateForm = validateForm;
|
|
31
|
+
exports.importRequest = importRequest;
|
|
32
|
+
exports.explainFailure = explainFailure;
|
|
33
|
+
exports.parseCertReport = parseCertReport;
|
|
34
|
+
exports.ELLIPSIS = '…';
|
|
35
|
+
exports.MID = '·';
|
|
36
|
+
exports.REDACTED = '[redacted]';
|
|
37
|
+
/**
|
|
38
|
+
* The initial loading splash: the owner's image, sized to the pane. The terminal reads the file
|
|
39
|
+
* itself; the plugin only names it. A square picture is about twice as many columns as rows
|
|
40
|
+
* because a terminal cell is about twice as tall as it is wide.
|
|
41
|
+
*/
|
|
42
|
+
function splashImage(root, width) {
|
|
43
|
+
const columns = Math.max(16, Math.min(40, Math.floor(width) - 2));
|
|
44
|
+
return {
|
|
45
|
+
file: `${root}/assets/flaude-splash.png`,
|
|
46
|
+
columns,
|
|
47
|
+
rows: Math.max(8, Math.round(columns / 2)),
|
|
48
|
+
alt: 'FLAUDE: a black cat on a prism inside an orange gear, with neon blue lettering',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/** Cut to `width` cells, ending in an ellipsis when something was cut. */
|
|
52
|
+
function clip(text, width) {
|
|
53
|
+
if (width <= 0)
|
|
54
|
+
return '';
|
|
55
|
+
const chars = Array.from(text);
|
|
56
|
+
return chars.length <= width ? text : chars.slice(0, width - 1).join('') + exports.ELLIPSIS;
|
|
57
|
+
}
|
|
58
|
+
function pad(text, width) {
|
|
59
|
+
const cut = clip(text, width);
|
|
60
|
+
return cut + ' '.repeat(Math.max(0, width - Array.from(cut).length));
|
|
61
|
+
}
|
|
62
|
+
function thousands(n) {
|
|
63
|
+
const digits = String(Math.round(n));
|
|
64
|
+
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
|
65
|
+
}
|
|
66
|
+
/** A token count as a person reads it. A number that is not known reads `unknown`. */
|
|
67
|
+
function tokensLabel(n) {
|
|
68
|
+
if (n === null || n === undefined || !Number.isFinite(n) || n <= 0)
|
|
69
|
+
return 'unknown';
|
|
70
|
+
if (n >= 1000000 && n % 100000 === 0)
|
|
71
|
+
return `${(n / 1000000).toFixed(1).replace(/\.0$/, '')}M`;
|
|
72
|
+
if (n >= 1000)
|
|
73
|
+
return `${Math.round(n / 1000)}K`;
|
|
74
|
+
return String(Math.round(n));
|
|
75
|
+
}
|
|
76
|
+
/** The window with its label: where the number comes from is part of the answer. */
|
|
77
|
+
function windowLabel(window) {
|
|
78
|
+
if (!window || !window.tokens)
|
|
79
|
+
return 'unknown';
|
|
80
|
+
return `${window.source} ${tokensLabel(window.tokens)}`;
|
|
81
|
+
}
|
|
82
|
+
function sourceLabel(model) {
|
|
83
|
+
return model.local ? 'local' : model.cloud ? 'cloud' : '-';
|
|
84
|
+
}
|
|
85
|
+
function gradeLabel(grade) {
|
|
86
|
+
return grade === 'A' || grade === 'B' || grade === 'C' ? grade : '-';
|
|
87
|
+
}
|
|
88
|
+
/** From this width on, a row carries the provider, protocol, grade, window and source inline. */
|
|
89
|
+
exports.WIDE_ROW = 84;
|
|
90
|
+
/** One picker row, fitted to the pane and never past its width. */
|
|
91
|
+
function pickerRow(model, width) {
|
|
92
|
+
const mark = model.active ? '* ' : ' ';
|
|
93
|
+
const key = `row:${model.id}`;
|
|
94
|
+
const strong = !!model.active;
|
|
95
|
+
if (width >= exports.WIDE_ROW) {
|
|
96
|
+
const tail = ` ${pad(model.providerId, 10)} ${pad(model.protocol ?? '?', 10)} ${gradeLabel(model.grade)} ${pad(windowLabel(model.window), 15)} ${sourceLabel(model)}`;
|
|
97
|
+
return { key, strong, head: mark + pad(model.id, width - 54), tail };
|
|
98
|
+
}
|
|
99
|
+
return { key, strong, head: mark + clip(model.id, Math.max(8, width - 2)), tail: '' };
|
|
100
|
+
}
|
|
101
|
+
function rowText(row) {
|
|
102
|
+
return row.head + row.tail;
|
|
103
|
+
}
|
|
104
|
+
/** Everything the picker pane draws, as plain data: the row holding the focus ring is the one it describes. */
|
|
105
|
+
function pickerView(snapshot, highlighted, note, width) {
|
|
106
|
+
const room = Math.max(28, width);
|
|
107
|
+
const models = snapshot?.models ?? [];
|
|
108
|
+
const current = models.find(model => model.id === highlighted) ?? models.find(model => model.active) ?? models[0];
|
|
109
|
+
const focusFirst = highlighted ?? current?.id ?? null;
|
|
110
|
+
return {
|
|
111
|
+
width: room,
|
|
112
|
+
loading: !snapshot,
|
|
113
|
+
empty: !!snapshot && !models.length,
|
|
114
|
+
rows: models.map(model => {
|
|
115
|
+
const row = pickerRow(model, room);
|
|
116
|
+
return { ...row, model: model.id, focus: model.id === focusFirst, dim: model.id !== focusFirst };
|
|
117
|
+
}),
|
|
118
|
+
facts: current ? detailLines(current, room) : [],
|
|
119
|
+
cost: snapshot && current ? switchCost(snapshot, current, room) : [],
|
|
120
|
+
note,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/** Word-wrap to `width` cells; a word longer than the line is cut. */
|
|
124
|
+
function wrap(text, width) {
|
|
125
|
+
const room = Math.max(8, width);
|
|
126
|
+
const lines = [];
|
|
127
|
+
let line = '';
|
|
128
|
+
for (const word of text.split(/\s+/).filter(Boolean)) {
|
|
129
|
+
if (!line)
|
|
130
|
+
line = clip(word, room);
|
|
131
|
+
else if (Array.from(`${line} ${word}`).length <= room)
|
|
132
|
+
line = `${line} ${word}`;
|
|
133
|
+
else {
|
|
134
|
+
lines.push(line);
|
|
135
|
+
line = clip(word, room);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (line)
|
|
139
|
+
lines.push(line);
|
|
140
|
+
return lines;
|
|
141
|
+
}
|
|
142
|
+
/** What switching to this model costs, in words, before it happens. */
|
|
143
|
+
function switchCost(snapshot, model, width) {
|
|
144
|
+
const tokens = model.preview?.reprocessTokens ?? snapshot.lastInputTokens;
|
|
145
|
+
const fits = model.preview?.fits ?? null;
|
|
146
|
+
const first = tokens === null || tokens === undefined
|
|
147
|
+
? 'Switch cost: no request has been sent yet, so there is nothing to reprocess.'
|
|
148
|
+
: `Switch cost: about ${tokensLabel(tokens)} input tokens (${thousands(tokens)}) are reprocessed uncached on ${model.providerId}.`;
|
|
149
|
+
const second = fits === 'yes'
|
|
150
|
+
? `Fits the ${windowLabel(model.window)} window: yes.`
|
|
151
|
+
: fits === 'no'
|
|
152
|
+
? `Fits the ${windowLabel(model.window)} window: no. Older tool results will be trimmed to fit.`
|
|
153
|
+
: `Fits the ${windowLabel(model.window)} window: not known until a request has been sent.`;
|
|
154
|
+
return wrap(`${first} ${second}`, width);
|
|
155
|
+
}
|
|
156
|
+
/** When a model was last measured, as a person reads it: 3 hours ago, 12 days ago. Unknown when it never was. */
|
|
157
|
+
function certifiedLabel(certifiedAt, now = Date.now()) {
|
|
158
|
+
const at = typeof certifiedAt === 'string' ? Date.parse(certifiedAt) : NaN;
|
|
159
|
+
if (!Number.isFinite(at))
|
|
160
|
+
return null;
|
|
161
|
+
const age = Math.max(0, now - at);
|
|
162
|
+
if (age < 3_600_000)
|
|
163
|
+
return 'measured under an hour ago';
|
|
164
|
+
const hours = Math.floor(age / 3_600_000);
|
|
165
|
+
if (hours < 48)
|
|
166
|
+
return `measured ${hours} hour${hours === 1 ? '' : 's'} ago`;
|
|
167
|
+
const days = Math.floor(hours / 24);
|
|
168
|
+
return `measured ${days} day${days === 1 ? '' : 's'} ago`;
|
|
169
|
+
}
|
|
170
|
+
/** The highlighted model's facts: one line when they fit, two when they do not. */
|
|
171
|
+
function detailLines(model, width, now = Date.now()) {
|
|
172
|
+
const measured = certifiedLabel(model.certifiedAt, now);
|
|
173
|
+
const grade = measured ? `grade ${gradeLabel(model.grade)}, ${measured}` : `grade ${gradeLabel(model.grade)}`;
|
|
174
|
+
const facts = [model.providerId, model.protocol ?? '?', grade, windowLabel(model.window), sourceLabel(model)];
|
|
175
|
+
const one = facts.join(` ${exports.MID} `);
|
|
176
|
+
if (Array.from(one).length <= width)
|
|
177
|
+
return [one];
|
|
178
|
+
return [facts.slice(0, 2).join(` ${exports.MID} `), facts.slice(2).join(` ${exports.MID} `)];
|
|
179
|
+
}
|
|
180
|
+
function statusLine(snapshot) {
|
|
181
|
+
if (!snapshot || !snapshot.activeModel)
|
|
182
|
+
return undefined;
|
|
183
|
+
const model = snapshot.models.find(m => m.id === snapshot.activeModel);
|
|
184
|
+
const parts = [snapshot.activeModel, model?.providerId, `window ${windowLabel(model?.window)}`];
|
|
185
|
+
return parts.filter(Boolean).join(` ${exports.MID} `);
|
|
186
|
+
}
|
|
187
|
+
/** Lower-case, punctuation to single spaces: the same ask reads the same however it is spaced. */
|
|
188
|
+
function normalizeQuestion(text) {
|
|
189
|
+
return text.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
|
|
190
|
+
}
|
|
191
|
+
const STOP = new Set(['the', 'and', 'for', 'with', 'that', 'this', 'are', 'should', 'you', 'your', 'use', 'using']);
|
|
192
|
+
function keywords(normalized) {
|
|
193
|
+
return new Set(normalized.split(' ').filter(word => word.length > 2 && !STOP.has(word)));
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* The answer this session already gave to the same question, or null.
|
|
197
|
+
* Two rules, both exact: the same words, or the same significant words in another order.
|
|
198
|
+
* A near miss is no match: a wrong answer given silently is worse than a question asked twice.
|
|
199
|
+
*/
|
|
200
|
+
function findAnswer(entries, question) {
|
|
201
|
+
const target = normalizeQuestion(question);
|
|
202
|
+
if (target.length < 4)
|
|
203
|
+
return null;
|
|
204
|
+
const usable = entries.filter(entry => entry.answer && entry.answer.trim());
|
|
205
|
+
const exact = usable.find(entry => normalizeQuestion(entry.question) === target);
|
|
206
|
+
if (exact)
|
|
207
|
+
return { question: exact.question, answer: exact.answer };
|
|
208
|
+
const wanted = keywords(target);
|
|
209
|
+
if (wanted.size < 2)
|
|
210
|
+
return null;
|
|
211
|
+
const same = usable.find(entry => {
|
|
212
|
+
const have = keywords(normalizeQuestion(entry.question));
|
|
213
|
+
return have.size === wanted.size && [...wanted].every(word => have.has(word));
|
|
214
|
+
});
|
|
215
|
+
return same ? { question: same.question, answer: same.answer } : null;
|
|
216
|
+
}
|
|
217
|
+
exports.RECORD_NOTE = "[FLAUDE] Answered from the project's own records by a second vendor, so the user was not asked. If the record turns out not to apply to this task, say so before relying on it.";
|
|
218
|
+
/**
|
|
219
|
+
* The answer a second vendor read in the project's records, with its place, or null when there is none.
|
|
220
|
+
* The place travels with the answer, so the model can say where it came from and check it.
|
|
221
|
+
*/
|
|
222
|
+
function appliedAnswer(reply) {
|
|
223
|
+
const applied = reply?.applied;
|
|
224
|
+
if (!applied || typeof applied.answer !== 'string' || !applied.answer.trim())
|
|
225
|
+
return null;
|
|
226
|
+
const file = typeof applied.file === 'string' && applied.file.trim() ? applied.file.trim() : null;
|
|
227
|
+
const line = typeof applied.line === 'number' && applied.line > 0 ? `:${applied.line}` : '';
|
|
228
|
+
const where = file ? ` (${file}${line})` : '';
|
|
229
|
+
return `${redact(clip(applied.answer.trim(), 400))}${where}`;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* What the model is told when the project's own records may already answer its question.
|
|
233
|
+
* Null when they hold nothing, so the question goes to the user as it was.
|
|
234
|
+
* The records are put in front of the model; whether they answer the question is the model's to judge,
|
|
235
|
+
* and the same question asked again is shown to the user.
|
|
236
|
+
*/
|
|
237
|
+
function preanswerNote(question, reply) {
|
|
238
|
+
const passages = (reply?.passages ?? []).filter(p => p && typeof p.file === 'string' && typeof p.text === 'string' && p.text.trim());
|
|
239
|
+
const environment = (reply?.environment ?? []).filter(e => typeof e === 'string' && e.trim());
|
|
240
|
+
if (!passages.length && !environment.length)
|
|
241
|
+
return null;
|
|
242
|
+
return [
|
|
243
|
+
"[FLAUDE] The user was not asked. Before a question reaches them, the project's own records are checked, and they hold this:",
|
|
244
|
+
`Question: ${redact(question)}`,
|
|
245
|
+
...passages.slice(0, 3).map(p => `${p.file}:${p.line} ${redact(clip(p.text, 400))}`),
|
|
246
|
+
...environment.slice(0, 2).map(e => `environment ${redact(clip(e, 400))}`),
|
|
247
|
+
'If these answer the question, do not ask it: continue with what they say, and mention in one line which record you took it from.',
|
|
248
|
+
'Ask again only if they truly leave the question open. The same question asked a second time is shown to the user.',
|
|
249
|
+
].join('\n');
|
|
250
|
+
}
|
|
251
|
+
const USER_ONLY = [
|
|
252
|
+
{ name: 'payment', re: /\b(pay|payment|paying|purchase|buy|buying|billing|charge|charged|spend|spending|budget|credit card|subscription|price|cost)\b/i },
|
|
253
|
+
{ name: 'publication', re: /\b(publish|publishing|release to|deploy|deploying|push|pushes|pushing|public|publicly|share (with|publicly)|visibility|send (to|the)|post (it|this)|notify|email|invite)\b/i },
|
|
254
|
+
{ name: 'destruction', re: /\b(delete|deleting|remove|removal|destroy|drop|wipe|overwrite|erase|purge|quarantine|force[- ]push|reset --hard|irreversible|cannot be undone|permanently)\b/i },
|
|
255
|
+
{ name: 'authorisation', re: /\b(authori[sz]e|authori[sz]ation|approve|approval|permission|credential|credentials|secret|secrets|password|api key|login|sign in|authenticate)\b/i },
|
|
256
|
+
{ name: 'personal preference', re: /\b(prefer|preference|favo(u)?rite|taste|do you want|would you like|are you sure|are you comfortable|how do you feel|what name|call it)\b/i },
|
|
257
|
+
];
|
|
258
|
+
/** Why a question is the user's alone to answer, or null when a steward may answer it from the record. */
|
|
259
|
+
function userOnlyQuestion(question) {
|
|
260
|
+
for (const rule of USER_ONLY)
|
|
261
|
+
if (rule.re.test(question))
|
|
262
|
+
return { userOnly: true, name: rule.name };
|
|
263
|
+
return { userOnly: false };
|
|
264
|
+
}
|
|
265
|
+
const SECRET_PATTERNS = [
|
|
266
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,
|
|
267
|
+
/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\b/g,
|
|
268
|
+
/\bsk-[A-Za-z0-9_-]{12,}\b/g,
|
|
269
|
+
/\b[0-9a-fA-F]{32}\.[A-Za-z0-9]{10,}\b/g,
|
|
270
|
+
/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|xox[baprs]-[A-Za-z0-9-]{10,}|AKIA[0-9A-Z]{16}|AIza[0-9A-Za-z_-]{30,})\b/g,
|
|
271
|
+
/\bbearer\s+[A-Za-z0-9._~+/-]{12,}/gi,
|
|
272
|
+
];
|
|
273
|
+
/** Anything that carries a credential to a screen, a log or a state value passes through here. */
|
|
274
|
+
function redact(text, secret) {
|
|
275
|
+
let out = String(text ?? '');
|
|
276
|
+
for (const pattern of SECRET_PATTERNS)
|
|
277
|
+
out = out.replace(pattern, exports.REDACTED);
|
|
278
|
+
out = out.replace(/\b(api[_-]?key|auth[_-]?token|access[_-]?token|secret|password|passwd|lease[_-]?token|token|key)(\s*[=:]\s*)(["']?)([^\s"',;}\]]{6,})\3/gi, (_whole, name, sep, _quote, value) => {
|
|
279
|
+
const bare = value.replace(/[.,;]+$/, '');
|
|
280
|
+
const already = bare.startsWith('[redacted') || /^(redacted|null|none|true|false|undefined|\$\w+|<[^>]+>|\[[^\]]+\])$/.test(bare);
|
|
281
|
+
return already ? `${name}${sep}${value}` : `${name}${sep}${exports.REDACTED}`;
|
|
282
|
+
});
|
|
283
|
+
// The key that was typed goes last, whole: nothing it produced can then be half-matched.
|
|
284
|
+
return secret && secret.length >= 4 ? out.split(secret).join(exports.REDACTED) : out;
|
|
285
|
+
}
|
|
286
|
+
function emptyForm() {
|
|
287
|
+
return { url: '', id: '', name: '', protocol: 'auto', models: '', auth: 'none', brokerServer: '', consumerId: 'flaude', context: '', numCtx: '' };
|
|
288
|
+
}
|
|
289
|
+
function idleRun() {
|
|
290
|
+
return { phase: 'idle', title: '', steps: [], grade: null, lines: [], at: 0 };
|
|
291
|
+
}
|
|
292
|
+
/** A provider id the person did not give: the broker's server, Ollama, or the host. */
|
|
293
|
+
function suggestId(url) {
|
|
294
|
+
const match = /^https?:\/\/[^/]+\/proxy\/([^/]+)/i.exec(url.trim());
|
|
295
|
+
if (match?.[1])
|
|
296
|
+
return match[1].toLowerCase();
|
|
297
|
+
if (/ollama|:11434/i.test(url))
|
|
298
|
+
return 'ollama';
|
|
299
|
+
const host = /^https?:\/\/([^/:?#]+)/i.exec(url.trim());
|
|
300
|
+
return (host?.[1] ?? '').toLowerCase().replace(/[^a-z0-9_.-]+/g, '-');
|
|
301
|
+
}
|
|
302
|
+
function inferProtocol(url) {
|
|
303
|
+
const text = url.toLowerCase();
|
|
304
|
+
if (/ollama|:11434\b/.test(text))
|
|
305
|
+
return 'ollama';
|
|
306
|
+
if (/anthropic/.test(text))
|
|
307
|
+
return 'anthropic';
|
|
308
|
+
return 'openai';
|
|
309
|
+
}
|
|
310
|
+
/** A comma, space or newline separated list, trimmed, without repeats, in the order written. */
|
|
311
|
+
function parseList(text) {
|
|
312
|
+
const out = [];
|
|
313
|
+
for (const item of text.split(/[\s,]+/)) {
|
|
314
|
+
const clean = item.trim();
|
|
315
|
+
if (clean && !out.includes(clean))
|
|
316
|
+
out.push(clean);
|
|
317
|
+
}
|
|
318
|
+
return out;
|
|
319
|
+
}
|
|
320
|
+
function wholeNumber(text) {
|
|
321
|
+
if (!text.trim())
|
|
322
|
+
return null;
|
|
323
|
+
return /^\d+$/.test(text.trim()) && Number(text.trim()) > 0 ? Number(text.trim()) : false;
|
|
324
|
+
}
|
|
325
|
+
/** Shown when key authentication is chosen and the Key field is empty. The key itself never enters the form. */
|
|
326
|
+
exports.KEY_NEEDED = {
|
|
327
|
+
field: 'form',
|
|
328
|
+
problem: 'Key authentication is chosen and the Key field is empty.',
|
|
329
|
+
fix: 'Paste the key into the Key field. It is used for the request and then dropped.',
|
|
330
|
+
};
|
|
331
|
+
/** What stands in the way, field by field, each with the next thing to do. Empty when ready. */
|
|
332
|
+
function validateForm(form, purpose) {
|
|
333
|
+
const problems = [];
|
|
334
|
+
const url = form.url.trim();
|
|
335
|
+
if (!url)
|
|
336
|
+
problems.push({ field: 'url', problem: 'The endpoint address is missing.', fix: 'Give the base URL, for example http://127.0.0.1:11434/v1.' });
|
|
337
|
+
else if (!/^https?:\/\/\S+$/i.test(url))
|
|
338
|
+
problems.push({ field: 'url', problem: 'The address does not start with http:// or https://.', fix: 'Give the full base URL of the provider.' });
|
|
339
|
+
const id = form.id.trim();
|
|
340
|
+
if (id && !/^[A-Za-z0-9][A-Za-z0-9_.-]*$/.test(id))
|
|
341
|
+
problems.push({ field: 'id', problem: `"${clip(id, 24)}" cannot be a provider id.`, fix: 'Use letters, digits, dots, dashes or underscores, starting with a letter or digit.' });
|
|
342
|
+
const protocol = form.protocol === 'auto' ? inferProtocol(url) : form.protocol;
|
|
343
|
+
if (form.protocol !== 'auto' && !['anthropic', 'openai', 'ollama'].includes(form.protocol)) {
|
|
344
|
+
problems.push({ field: 'protocol', problem: `"${clip(form.protocol, 24)}" is not a protocol.`, fix: 'Choose auto, anthropic, openai or ollama.' });
|
|
345
|
+
}
|
|
346
|
+
if (form.auth === 'broker' && !form.brokerServer.trim()) {
|
|
347
|
+
problems.push({ field: 'brokerServer', problem: 'The broker server is missing.', fix: 'Name the server the broker leases for, for example deepseek, openai or zai-glm.' });
|
|
348
|
+
}
|
|
349
|
+
if (wholeNumber(form.context) === false)
|
|
350
|
+
problems.push({ field: 'context', problem: `"${clip(form.context, 16)}" is not a token count.`, fix: 'Give a whole number of tokens, or leave it empty to measure.' });
|
|
351
|
+
if (wholeNumber(form.numCtx) === false)
|
|
352
|
+
problems.push({ field: 'numCtx', problem: `"${clip(form.numCtx, 16)}" is not a token count.`, fix: 'Give the context the local server should hold open, for example 65536.' });
|
|
353
|
+
if (protocol === 'ollama' && url && !/\/v\d+\/?$/.test(url)) {
|
|
354
|
+
problems.push({ field: 'url', problem: 'Ollama answers on its OpenAI-shaped path.', fix: 'End the address with /v1, for example http://127.0.0.1:11434/v1.' });
|
|
355
|
+
}
|
|
356
|
+
if (purpose === 'save' && parseList(form.models).length === 0) {
|
|
357
|
+
problems.push({ field: 'models', problem: 'No model is named.', fix: 'Type the model names the vendor uses, or press Discover to list them.' });
|
|
358
|
+
}
|
|
359
|
+
return problems;
|
|
360
|
+
}
|
|
361
|
+
/** The body of `POST /flaude/add`. The key is not in it: the caller adds it to that one request. */
|
|
362
|
+
function importRequest(form) {
|
|
363
|
+
const url = form.url.trim().replace(/\/+$/, '');
|
|
364
|
+
const context = wholeNumber(form.context);
|
|
365
|
+
const numCtx = wholeNumber(form.numCtx);
|
|
366
|
+
return {
|
|
367
|
+
id: form.id.trim() || suggestId(url),
|
|
368
|
+
name: form.name.trim() || undefined,
|
|
369
|
+
url,
|
|
370
|
+
protocol: form.protocol === 'auto' ? inferProtocol(url) : form.protocol,
|
|
371
|
+
models: parseList(form.models),
|
|
372
|
+
auth: form.auth,
|
|
373
|
+
brokerServer: form.auth === 'broker' ? form.brokerServer.trim() || undefined : undefined,
|
|
374
|
+
consumerId: form.auth === 'broker' ? form.consumerId.trim() || 'flaude' : undefined,
|
|
375
|
+
context: typeof context === 'number' ? context : undefined,
|
|
376
|
+
numCtx: typeof numCtx === 'number' ? numCtx : undefined,
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
/** A failure in words, with the next thing to do. The text is redacted before it is shown. */
|
|
380
|
+
function explainFailure(error, secret) {
|
|
381
|
+
const message = redact(error.message || '', secret).trim();
|
|
382
|
+
const status = error.status ?? 0;
|
|
383
|
+
if (status === -1) {
|
|
384
|
+
return { title: message, next: 'The router is running but did not answer in time, or failed on its side. Try again; if it persists, read the session log with: flaude-admin log -n 20' };
|
|
385
|
+
}
|
|
386
|
+
if (status === 0) {
|
|
387
|
+
return { title: 'No live FLAUDE session answered on this machine.', next: 'Start Claude Code through the flaude launcher: it starts this session’s router. Check with: flaude-admin doctor' };
|
|
388
|
+
}
|
|
389
|
+
if (status === 403)
|
|
390
|
+
return { title: 'This session’s router refused the control token.', next: 'The router restarted under the same session. Reopen this pane; the token is read again each time.' };
|
|
391
|
+
if (status === 404)
|
|
392
|
+
return { title: message || 'The running router has no such route.', next: 'Update FLAUDE, or do the same from a shell with: flaude-admin add …' };
|
|
393
|
+
if (status === 503)
|
|
394
|
+
return { title: message || 'The session cannot run this.', next: message || 'Run it from a shell with: flaude-admin test <model>' };
|
|
395
|
+
return { title: message || `The router answered HTTP ${status}.`, next: status >= 500 ? 'Look at the session log with: flaude-admin log -n 20' : 'Correct what the message names and try again.' };
|
|
396
|
+
}
|
|
397
|
+
/** The certification's own lines, each a step with its verdict. */
|
|
398
|
+
function parseCertReport(report) {
|
|
399
|
+
const steps = [];
|
|
400
|
+
let grade = typeof report?.grade === 'string' ? report.grade : null;
|
|
401
|
+
let note = null;
|
|
402
|
+
for (const raw of report?.lines ?? []) {
|
|
403
|
+
const line = String(raw).trimEnd();
|
|
404
|
+
const step = /^(PASS|FAIL|weak)\s{2,}(\S.*?)(?:\s{2,}(\S.*))?$/.exec(line.trim());
|
|
405
|
+
if (step && step[1] && step[2]) {
|
|
406
|
+
steps.push({ name: step[2].trim(), ok: step[1] === 'PASS' ? true : step[1] === 'FAIL' ? false : null, detail: (step[3] ?? '').trim() });
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
const graded = /^Grade\s+([ABC])\b/.exec(line.trim());
|
|
410
|
+
if (graded) {
|
|
411
|
+
grade = graded[1] ?? grade;
|
|
412
|
+
steps.push({ name: 'grade', ok: true, detail: line.trim().replace(/^Grade\s+[ABC]\s*[—-]\s*/, '') });
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (/^Certifying\b/.test(line.trim()))
|
|
416
|
+
continue;
|
|
417
|
+
if (line.trim())
|
|
418
|
+
note = line.trim();
|
|
419
|
+
}
|
|
420
|
+
return { steps, grade, note };
|
|
421
|
+
}
|