muonroi-cli 1.6.6 → 1.7.0
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/dist/src/generated/version.d.ts +1 -1
- package/dist/src/generated/version.js +1 -1
- package/dist/src/orchestrator/message-processor.js +1 -1
- package/dist/src/orchestrator/prompts.js +16 -2
- package/dist/src/orchestrator/stream-runner.js +50 -3
- package/dist/src/orchestrator/subagent-compactor.d.ts +1 -1
- package/dist/src/orchestrator/subagent-compactor.js +1 -1
- package/dist/src/pil/__tests__/layer4-gsd.test.js +40 -23
- package/dist/src/pil/__tests__/llm-classify.test.js +40 -3
- package/dist/src/pil/layer1-intent.js +10 -1
- package/dist/src/pil/layer1-intent.test.js +18 -0
- package/dist/src/pil/layer4-gsd.js +43 -19
- package/dist/src/pil/llm-classify.d.ts +36 -0
- package/dist/src/pil/llm-classify.js +84 -18
- package/dist/src/pil/types.d.ts +27 -2
- package/dist/src/{gsd → playbook}/__tests__/directives.test.js +34 -58
- package/dist/src/playbook/complexity.d.ts +17 -0
- package/dist/src/playbook/complexity.js +18 -0
- package/dist/src/{gsd → playbook}/directives.d.ts +20 -13
- package/dist/src/playbook/directives.js +149 -0
- package/dist/src/providers/__tests__/reasoning-roundtrip.test.js +70 -1
- package/dist/src/providers/strategies/deepseek.strategy.js +5 -22
- package/dist/src/providers/strategies/siliconflow.strategy.js +5 -0
- package/dist/src/providers/strategies/thinking-mode.d.ts +35 -0
- package/dist/src/providers/strategies/thinking-mode.js +73 -0
- package/dist/src/tools/registry.js +47 -47
- package/package.json +1 -1
- package/dist/src/gsd/__tests__/complexity.test.d.ts +0 -1
- package/dist/src/gsd/__tests__/complexity.test.js +0 -0
- package/dist/src/gsd/complexity.d.ts +0 -28
- package/dist/src/gsd/complexity.js +0 -103
- package/dist/src/gsd/directives.js +0 -154
- /package/dist/src/{gsd → playbook}/__tests__/directives.test.d.ts +0 -0
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* src/gsd/directives.ts
|
|
3
|
-
*
|
|
4
|
-
* Builds the system-prompt directive block injected by layer4-gsd. The directive
|
|
5
|
-
* is what actually changes the agent's behaviour: it lists the GSD-style steps
|
|
6
|
-
* the agent must take before touching code.
|
|
7
|
-
*
|
|
8
|
-
* Three tiers:
|
|
9
|
-
* - heavy: full discuss → research → verify → plan → impl → verify flow,
|
|
10
|
-
* with mandatory AskUserQuestion + parallel Agent dispatch.
|
|
11
|
-
* - standard: GSD-quick mindset — short plan, then implement, then verify.
|
|
12
|
-
* - quick: minimal hint, run inline.
|
|
13
|
-
*
|
|
14
|
-
* All directive text is English. The agent is responsible for translating
|
|
15
|
-
* user-facing prompts into the user's language at render time.
|
|
16
|
-
*/
|
|
17
|
-
const HEADER = "[gsd-native]";
|
|
18
|
-
/**
|
|
19
|
-
* High-precision predicate: is this turn about the Muonroi ECOSYSTEM (where the
|
|
20
|
-
* muonroi-docs MCP is the right source), as opposed to muonroi-cli internals?
|
|
21
|
-
* Deliberately TIGHTER than smart-filter's hasEcosystemSignal — that one keeps
|
|
22
|
-
* the server (over-keeping costs only tokens), but a behavioural "call docs
|
|
23
|
-
* FIRST" nudge must not fire on every "muonroi" mention or it misdirects
|
|
24
|
-
* CLI-internals questions toward .NET package docs. EN + VI.
|
|
25
|
-
*/
|
|
26
|
-
const ECOSYSTEM_SCOPE_RE = /\becosystem\b|hệ\s*sinh\s*thái|he\s*sinh\s*thai|building[-\s]?block|open[-\s]?core|rule\s*engine|decision\s*table|\bnuget\b/i;
|
|
27
|
-
export function mentionsEcosystemScope(message) {
|
|
28
|
-
return ECOSYSTEM_SCOPE_RE.test(message);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Appended to any directive when the turn is ecosystem-scoped. Phrased
|
|
32
|
-
* conditionally ("if … available") so it is harmless when muonroi-docs is not
|
|
33
|
-
* configured — the model simply finds no such tool and falls back to local files.
|
|
34
|
-
*/
|
|
35
|
-
export const ECOSYSTEM_DOCS_NUDGE = [
|
|
36
|
-
`${HEADER} ECOSYSTEM SCOPE — this turn concerns the Muonroi ecosystem (platform overview, BB/.NET packages, building-block, open-core boundary, setup).`,
|
|
37
|
-
"If the muonroi-docs MCP is available, it is the AUTHORITATIVE source — call it FIRST (docs_search / setup_guide / bb_recipe_list / bb_package_describe), THEN ground with local files. Do NOT characterize the ecosystem from local repo files alone.",
|
|
38
|
-
].join("\n");
|
|
39
|
-
/**
|
|
40
|
-
* Appended to any directive when the user's reply language is non-English.
|
|
41
|
-
* The base system prompt's "reply in user's language" rule normally suffices,
|
|
42
|
-
* but `concise` / `FIX-FIRST` / GSD-debug directive bodies stack on top of it
|
|
43
|
-
* with strong "be terse / code over prose" language that crowds the rule out
|
|
44
|
-
* — observed live (storyflow_ui 22661c8de9f2). This NUDGE re-anchors the rule
|
|
45
|
-
* inside the directive itself so brevity preferences cannot override it.
|
|
46
|
-
*/
|
|
47
|
-
export function buildLanguageNudge(lang) {
|
|
48
|
-
return [
|
|
49
|
-
`${HEADER} LANGUAGE — the user wrote in ${lang}. Reply in ${lang}.`,
|
|
50
|
-
"This rule OVERRIDES any brevity / concise / code-over-prose directive: terseness is fine, but the response language stays the user's.",
|
|
51
|
-
].join("\n");
|
|
52
|
-
}
|
|
53
|
-
function renderGrayAreas(qs) {
|
|
54
|
-
if (qs.length === 0)
|
|
55
|
-
return " (no gray areas detected — confirm the request is fully specified before proceeding)";
|
|
56
|
-
return qs
|
|
57
|
-
.map((q, idx) => {
|
|
58
|
-
const opts = q.options.map((o, i) => `${i === 0 ? "[recommended]" : "[alt]"} ${o}`).join(" / ");
|
|
59
|
-
return ` ${idx + 1}. (${q.dimension}) ${q.question}\n options: ${opts}`;
|
|
60
|
-
})
|
|
61
|
-
.join("\n");
|
|
62
|
-
}
|
|
63
|
-
function buildHeavy(input) {
|
|
64
|
-
const grayBlock = renderGrayAreas(input.grayAreas);
|
|
65
|
-
return [
|
|
66
|
-
`${HEADER} HEAVY task detected (score=${input.complexity.score}, signals=${input.complexity.signals.map((s) => s.tag).join(",") || "none"}).`,
|
|
67
|
-
"MANDATORY flow before any implementation:",
|
|
68
|
-
" 1. DISCUSS — call AskUserQuestion with the gray areas below. Each question MUST include the recommended default first so the user can accept by selecting it.",
|
|
69
|
-
" Localize question text into the user's language (the language of their last message). Keep options labels English unless they refer to natural-language content.",
|
|
70
|
-
" 2. RESEARCH + VERIFY — once the user answers, dispatch two Agent calls IN PARALLEL in a single message:",
|
|
71
|
-
" (a) a research agent to gather codebase / external facts needed for the task,",
|
|
72
|
-
" (b) a verify agent to enumerate acceptance criteria and risks.",
|
|
73
|
-
" Wait for both before planning.",
|
|
74
|
-
" 3. PLAN — produce a short numbered plan grounded in the research + verify outputs. Confirm the plan with the user only if it diverges from their stated intent.",
|
|
75
|
-
" 4. IMPLEMENT — execute the plan in atomic steps. Prefer parallel Agent dispatch when steps are independent.",
|
|
76
|
-
" 5. VERIFY — run tests / lints / type checks. Report evidence (command + exit code) before claiming done.",
|
|
77
|
-
"Gray areas to clarify in step 1:",
|
|
78
|
-
grayBlock,
|
|
79
|
-
"Do NOT skip steps. Do NOT begin implementation until step 1 is answered.",
|
|
80
|
-
].join("\n");
|
|
81
|
-
}
|
|
82
|
-
function buildStandard(input) {
|
|
83
|
-
const phaseHint = input.phase ? ` (detected phase: ${input.phase})` : "";
|
|
84
|
-
// Debug-phase variant: tighten exploration budget. Session 7d56a049e1e3
|
|
85
|
-
// ran 109 tool calls (58 bash + 33 read_file + 16 grep + 2 mcp) over 6
|
|
86
|
-
// minutes WITHOUT a single edit_file / write_file — agent over-researched
|
|
87
|
-
// the CI failure instead of attempting a fix. Add an explicit exploration
|
|
88
|
-
// cap and require committing to a hypothesis early.
|
|
89
|
-
if (input.phase === "debug") {
|
|
90
|
-
return [
|
|
91
|
-
`${HEADER} DEBUG task${phaseHint} — apply GSD-quick mindset, FIX-FIRST.`,
|
|
92
|
-
"Flow:",
|
|
93
|
-
" 1. State a 2-3 line hypothesis (what is failing, your best guess of why) BEFORE reading more than 3 files.",
|
|
94
|
-
" 2. Apply the smallest plausible fix with edit_file / write_file. Do NOT keep exploring — commit to a hypothesis, ship the diff, iterate on failure.",
|
|
95
|
-
" 3. Verify the fix (rerun the failing command / test) and report evidence.",
|
|
96
|
-
"Hard limits — exceed only if a tool result genuinely contradicts your hypothesis:",
|
|
97
|
-
" - ≤ 8 read_file calls before first edit_file",
|
|
98
|
-
" - ≤ 5 grep calls before first edit_file",
|
|
99
|
-
" - ≤ 10 bash log-fetching calls (gh run view, cat log, etc.) before first edit_file",
|
|
100
|
-
"If hard limits are blown and you still have no fix, STOP and report what you tried + why you're stuck. Do NOT keep searching.",
|
|
101
|
-
].join("\n");
|
|
102
|
-
}
|
|
103
|
-
return [
|
|
104
|
-
`${HEADER} STANDARD task${phaseHint} — apply GSD-quick mindset.`,
|
|
105
|
-
"Flow:",
|
|
106
|
-
" 1. State a 2-3 line plan in your reply.",
|
|
107
|
-
" 2. Implement directly with the appropriate tools.",
|
|
108
|
-
" 3. Verify (tests / type-check / quick smoke) and report evidence.",
|
|
109
|
-
"Skip the discuss/research subagent dance unless a real ambiguity blocks step 1.",
|
|
110
|
-
].join("\n");
|
|
111
|
-
}
|
|
112
|
-
function buildQuestion() {
|
|
113
|
-
// Informational / question / meta-analysis turns. The deliverable is the
|
|
114
|
-
// answer itself — there is no code to implement or test. Keep the agent's
|
|
115
|
-
// process OUT of the reply: a human asked, a human reads the result.
|
|
116
|
-
return [
|
|
117
|
-
`${HEADER} QUESTION / explanatory request — no code change is being asked for.`,
|
|
118
|
-
"Answer it directly and completely, written for the HUMAN who asked:",
|
|
119
|
-
" 1. Investigate only as needed — read/grep the specific files that ground your answer this turn.",
|
|
120
|
-
" 2. Lead with the answer. Use clear prose + structure (headings, bullets). Where a claim rests on the code, cite a concise file:line inline.",
|
|
121
|
-
" 3. Do NOT output an implementation plan, do NOT narrate your own process or restate these instructions, and do NOT name internal layers / contract rules / tools as if the reader were the agent.",
|
|
122
|
-
"There is no implement/verify step — the answer is the deliverable.",
|
|
123
|
-
].join("\n");
|
|
124
|
-
}
|
|
125
|
-
function buildQuick(input) {
|
|
126
|
-
const phaseHint = input.phase ? ` phase=${input.phase}` : "";
|
|
127
|
-
return `${HEADER} QUICK task${phaseHint} — handle inline. No plan, no subagents. Make the smallest correct change and report.`;
|
|
128
|
-
}
|
|
129
|
-
export function buildDirective(input) {
|
|
130
|
-
// Informational/meta prompts answer a human — never apply the
|
|
131
|
-
// implement/verify scaffold (it agent-ifies the reply), regardless of tier.
|
|
132
|
-
const base = input.informational
|
|
133
|
-
? { text: buildQuestion(), tier: input.complexity.tier, blocking: false }
|
|
134
|
-
: input.complexity.tier === "heavy"
|
|
135
|
-
? { text: buildHeavy(input), tier: "heavy", blocking: true }
|
|
136
|
-
: input.complexity.tier === "standard"
|
|
137
|
-
? { text: buildStandard(input), tier: "standard", blocking: false }
|
|
138
|
-
: { text: buildQuick(input), tier: "quick", blocking: false };
|
|
139
|
-
// Ecosystem-scoped turns get a docs-first nudge regardless of tier (question
|
|
140
|
-
// OR task): muonroi-docs is the authoritative source and must not be skipped
|
|
141
|
-
// in favour of guessing from local files (session 41ccfeb2ceee turn 1).
|
|
142
|
-
let text = base.text;
|
|
143
|
-
if (input.ecosystem) {
|
|
144
|
-
text = `${text}\n${ECOSYSTEM_DOCS_NUDGE}`;
|
|
145
|
-
}
|
|
146
|
-
// Language nudge: re-anchor the "reply in user's language" rule INSIDE the
|
|
147
|
-
// directive when the user wrote in a non-English language, so layered
|
|
148
|
-
// brevity/concise directives can't drown it (storyflow_ui 22661c8de9f2).
|
|
149
|
-
if (input.replyLanguage) {
|
|
150
|
-
text = `${text}\n${buildLanguageNudge(input.replyLanguage)}`;
|
|
151
|
-
}
|
|
152
|
-
return { ...base, text };
|
|
153
|
-
}
|
|
154
|
-
//# sourceMappingURL=directives.js.map
|
|
File without changes
|