@weave-os/router 0.2.24 → 0.2.26
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 +12 -8
- package/cc-statusline.sh +2 -2
- package/install.sh +195 -122
- package/package.json +1 -2
- package/pi-router/src/pricing.generated.ts +3 -3
- package/uninstall.sh +204 -28
- package/opencode-weave/README.md +0 -159
- package/opencode-weave/package.json +0 -20
- package/opencode-weave/src/classifier-thread.ts +0 -145
- package/opencode-weave/src/directives.ts +0 -72
- package/opencode-weave/src/index.ts +0 -799
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rewrite OpenCode user text so Weave Router prompt directives reach the
|
|
3
|
-
* same parser Codex and pi already hit. OpenCode is not a skill runner: `$rf`
|
|
4
|
-
* would otherwise go to the LLM. The router already accepts both `/name` and
|
|
5
|
-
* `$name` on the wire; rewriting `$…` to the leading-space `/…` form matches
|
|
6
|
-
* the Codex emit.sh contract and keeps aliases out of model context.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const FORCE_MODEL = /^(?:\$|\/)(?:force-model|fm)(?:\s+|$)/i
|
|
10
|
-
const UNFORCE_MODEL = /^(?:\$|\/)(?:unforce-model|ufm)\s*$/i
|
|
11
|
-
const ROUTER_FEEDBACK = /^(?:\$|\/)(?:router-feedback|rf)(?:\s|$)/i
|
|
12
|
-
const ROUTER_SESSION = /^(?:\$|\/)router-session\s*$/i
|
|
13
|
-
|
|
14
|
-
export type RouterDirective =
|
|
15
|
-
| { kind: "force-model"; model: string }
|
|
16
|
-
| { kind: "unforce-model" }
|
|
17
|
-
| { kind: "router-feedback"; payload: string }
|
|
18
|
-
| { kind: "router-session" }
|
|
19
|
-
|
|
20
|
-
export function parseRouterDirective(text: string): RouterDirective | undefined {
|
|
21
|
-
const line = text.trim()
|
|
22
|
-
if (!line) return undefined
|
|
23
|
-
|
|
24
|
-
if (UNFORCE_MODEL.test(line) || line === "$ufm" || line === "/ufm") {
|
|
25
|
-
return { kind: "unforce-model" }
|
|
26
|
-
}
|
|
27
|
-
if (ROUTER_SESSION.test(line)) {
|
|
28
|
-
return { kind: "router-session" }
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const force = line.match(/^(?:\$|\/)(?:force-model|fm)\s+(\S[\s\S]*)$/i)
|
|
32
|
-
if (force) {
|
|
33
|
-
const model = force[1].trim()
|
|
34
|
-
if (model) return { kind: "force-model", model }
|
|
35
|
-
return undefined
|
|
36
|
-
}
|
|
37
|
-
if (FORCE_MODEL.test(line)) return undefined
|
|
38
|
-
|
|
39
|
-
const feedback = line.match(/^(?:\$|\/)(?:router-feedback|rf)(?:\s+([\s\S]*))?$/i)
|
|
40
|
-
if (feedback && ROUTER_FEEDBACK.test(line)) {
|
|
41
|
-
return { kind: "router-feedback", payload: (feedback[1] ?? "").trim() }
|
|
42
|
-
}
|
|
43
|
-
return undefined
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function rewriteRouterDirective(text: string): string | undefined {
|
|
47
|
-
const directive = parseRouterDirective(text)
|
|
48
|
-
if (!directive) return undefined
|
|
49
|
-
switch (directive.kind) {
|
|
50
|
-
case "force-model":
|
|
51
|
-
return ` /force-model ${directive.model}`
|
|
52
|
-
case "unforce-model":
|
|
53
|
-
return " /unforce-model"
|
|
54
|
-
case "router-feedback":
|
|
55
|
-
return directive.payload ? ` /router-feedback ${directive.payload}` : " /router-feedback"
|
|
56
|
-
case "router-session":
|
|
57
|
-
return " /router-session"
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function rewriteDirectiveParts<T extends { type: string; text?: string }>(parts: T[]): boolean {
|
|
62
|
-
let rewritten = false
|
|
63
|
-
for (const part of parts) {
|
|
64
|
-
if (part.type !== "text" || typeof part.text !== "string") continue
|
|
65
|
-
const next = rewriteRouterDirective(part.text)
|
|
66
|
-
if (next === undefined) continue
|
|
67
|
-
part.text = next
|
|
68
|
-
rewritten = true
|
|
69
|
-
break
|
|
70
|
-
}
|
|
71
|
-
return rewritten
|
|
72
|
-
}
|