This commit is contained in:
Chen, Li
2026-09-24 10:26:02 +08:00
commit 517415c5ba
12 changed files with 630 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
---
name: "LLM-Wiki"
description: "This agent coordinates the LLM-Wiki file-based repository workflow. It interprets user commands to weave knowledge or answer questions, managing raw evidence, wiki pages, and output files while ensuring source references."
argument-hint: "Command: llm-wiki-weave <stage> | llm-wiki-ask <stage> <question>"
tools: [execute, read, edit, search]
user-invocable: true
disable-model-invocation: false
---
You coordinate the LLM-Wiki workflows for this repository.
Before accessing stage files, read and follow the repository-root `AGENTS.md`, then load the applicable stage `wiki/AGENTS.md` as directed there. The root file controls project-wide boundaries; the stage file controls local wiki structure and deliverable standards. Do not duplicate those rules in this agent file.
For this repository, treat the workspace root as the stage root and `wiki/` as the maintained knowledge directory. The retrieval index must be created or updated only at `wiki/index.md`; never create a second index at the workspace root.
## Dispatch command
Interpret the first command word in the user's request:
- `llm-wiki-weave <stage>`: load and follow the `llm-wiki-weave` skill.
- `llm-wiki-ask <stage> <question>`: load and follow the `llm-wiki-ask` skill.
The matching skill is the source of truth for required parameters, validation, file operations.
Do not copy or substitute its procedure here.
If the command or required arguments are missing, follow the matching skill's prescribed execution mode and do
not inspect or modify stage files.
Apply the loaded skill procedure together with `AGENTS.md`. When they address different concerns, follow both; when a skill defines command-specific behavior, the skill controls that workflow detail.
+96
View File
@@ -0,0 +1,96 @@
import process from "node:process";
const chunks = [];
for await (const chunk of process.stdin) {
chunks.push(chunk);
}
let event;
try {
event = JSON.parse(Buffer.concat(chunks).toString("utf8") || "{}");
} catch {
deny("Raw protection could not parse the tool request.");
}
const toolName = String(
event.tool_name ?? event.toolName ?? event.name ?? ""
).toLowerCase();
const toolInput = event.tool_input ?? event.toolInput ?? event.input ?? {};
const readOnlyTool = /(read|search|grep|list|view|fetch|semantic)/.test(toolName);
if (readOnlyTool) {
allow();
}
const rawTargets = collectPathTargets(toolInput).filter(isRawPath);
const command = typeof toolInput.command === "string" ? toolInput.command : "";
const workingDirectory = String(event.cwd ?? "");
const shellTool = /(execute|terminal|shell|bash|powershell|command)/.test(toolName);
if (shellTool && (isRawPath(command) || isRawPath(workingDirectory))) {
deny(
"Shell commands that reference raw/ are blocked. Use a dedicated read or search tool to inspect raw evidence."
);
}
if (rawTargets.length > 0) {
deny(`Modification of raw evidence is forbidden: ${rawTargets[0]}`);
}
allow();
function collectPathTargets(value, key = "") {
if (Array.isArray(value)) {
return value.flatMap((item) => collectPathTargets(item, key));
}
if (value && typeof value === "object") {
return Object.entries(value).flatMap(([childKey, childValue]) =>
collectPathTargets(childValue, childKey)
);
}
if (typeof value !== "string") {
return [];
}
if (key === "input") {
return [...value.matchAll(/^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm)].map(
(match) => match[1].trim()
);
}
return /(file|path|uri|target|destination|source)/i.test(key) ? [value] : [];
}
function isRawPath(value) {
const normalized = String(value)
.replaceAll("\\", "/")
.replaceAll('"', "")
.replaceAll("'", "")
.toLowerCase();
return /(^|[\s/:])raw(?:[\s/]|$)/.test(normalized);
}
function allow() {
process.stdout.write(JSON.stringify({ continue: true }));
process.exit(0);
}
function deny(reason) {
process.stdout.write(
JSON.stringify({
continue: false,
stopReason: reason,
hookSpecificOutput: {
hookEventName: "PreToolUse",
permissionDecision: "deny",
permissionDecisionReason: reason
}
})
);
process.exit(0);
}
+11
View File
@@ -0,0 +1,11 @@
{
"hooks": {
"PreToolUse": [
{
"type": "command",
"command": "node .github/hooks/protect-raw.mjs",
"timeout": 5
}
]
}
}
+27
View File
@@ -0,0 +1,27 @@
---
name: llm-wiki-ask
description: "Answer an LLM-Wiki question with wiki-first retrieval. Use for ask commands and questions about a stage."
argument-hint: "Stage and question"
---
# Ask With Wiki-First Retrieval
You are running `ask`.
`<stage>` and `<question>` are required. If either is missing or empty, stop
immediately without reading or writing any stage file. Reply with:
`Please input stage and question,e.g. ask <stage> "What is discussed in this stage?"`
1. Read the stage's `wiki/index.md` first.
2. Read the most relevant `wiki/*.md` pages.
3. Read raw files only for evidence, missing details, or conflict checking.
4. Save the answer to `output/ask-<short-question-slug>.md`.
5. Include the question, retrieval path separated into wiki hits and raw
evidence, concise answer, source references, human-check notes, and whether
anything should later be promoted into the wiki.
6. Never edit `raw/`.
7. Do not edit `wiki/` unless explicitly asked to maintain the wiki.
In the final response, report the output path, wiki pages used, raw evidence
used, and any follow-up maintenance suggestion.
+31
View File
@@ -0,0 +1,31 @@
---
name: llm-wiki-weave
description: "Weave raw materials into the LLM-Wiki. Use for processing raw files and updating wiki pages."
argument-hint: "Stage"
---
# Action: Weave Raw Into Wiki
You are running `weave`.
Goal: read the stage's `raw/` materials and update `wiki/` as long-term knowledge.
Required weave work:
1. Inspect all files under the stage's `raw/` directory, including nested folders.
2. Do not edit any raw file.
3. For each meaningful raw file, create or update one `wiki/source-summary-*.md` file.
4. Create or update stable `wiki/concept-*.md` pages when multiple raw files support the same reusable idea.
5. Update `wiki/index.md` as the stage's retrieval entrance.
6. Every generated or updated wiki file must include:
- `source_refs`
- what the page is useful for
- what a human should check
- uncertainty or conflict notes when needed
7. Keep the pages short enough for a beginner to inspect from the terminal.
Output in your final response:
- Files created or updated.
- Evidence read.
- Any uncertainty that should not be promoted to long-term knowledge yet.