공개 문서
learn/canonical/knot/install-knot-wiki.sh.md
아래는 learn/canonical/knot/install-knot-wiki.sh.md 와 동일한 원문입니다. Markdown과 HTML 변환 결과를 각각 복사할 수 있습니다.
공개 문서 원문 (Markdown)
# tools/knot/install-knot-wiki.sh
> Hub reference copy — MAS 정본: `tools/knot/install-knot-wiki.sh`
```bash
#!/usr/bin/env bash
# Install knot knowledge wiki scaffold (vendor-neutral markdown vault).
# Upstream: https://github.com/netwaif/knot — upstream calls it "vault"; local LAB folder: knot-wiki
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
SCAFFOLD="$ROOT/tools/knot/scaffold"
TARGET="${1:-$ROOT/knot-wiki}"
usage() {
cat <<EOF
Usage: install-knot-wiki.sh [TARGET_DIR]
Install knot wiki scaffold (default: \$ROOT/knot-wiki — LAB).
Sets KNOT_WIKI in tools/knot/env.example for shell hook.
Options via env:
KNOT_SKIP_GIT=1 skip git init on new vault
Examples:
bash tools/knot/install-knot-wiki.sh
bash tools/knot/install-knot-wiki.sh ~/Desktop/MultiAgentSystem/knot-wiki
source tools/knot/env.example
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
if [[ ! -d "$SCAFFOLD" ]]; then
echo "[FAIL] scaffold missing: $SCAFFOLD" >&2
exit 1
fi
if [[ -e "$TARGET" && -n "$(ls -A "$TARGET" 2>/dev/null)" ]]; then
echo "[FAIL] target not empty: $TARGET" >&2
echo " use empty dir or omit existing wiki" >&2
exit 1
fi
mkdir -p "$TARGET"
if command -v rsync >/dev/null 2>&1; then
rsync -a "$SCAFFOLD/" "$TARGET/"
else
cp -a "$SCAFFOLD/." "$TARGET/"
fi
if [[ "${KNOT_SKIP_GIT:-0}" != "1" ]] && [[ ! -d "$TARGET/.git" ]]; then
git -C "$TARGET" init -q
git -C "$TARGET" add -A
git -C "$TARGET" commit -q -m "chore: knot wiki scaffold from MultiAgentSystem tools/knot"
echo "[OK] git init + initial commit"
fi
ENV_EXAMPLE="$ROOT/tools/knot/env.example"
mkdir -p "$(dirname "$ENV_EXAMPLE")"
cat > "$ENV_EXAMPLE" <<EOF
# Source in shell: export KNOT_WIKI="$TARGET"
export KNOT_WIKI="$TARGET"
# Runner: claude (default) | codex | agy | gemini
export KNOT_RUNNER=claude
EOF
LINT_PY="$TARGET/ops/scripts/lint.py"
[[ -f "$LINT_PY" ]] || LINT_PY="$TARGET/scripts/lint.py"
if python3 "$LINT_PY" "$TARGET" >/dev/null 2>&1; then
echo "[OK] lint.py PASS (empty wiki)"
else
echo "[WARN] lint.py reported issues — run: python3 $LINT_PY" >&2
fi
echo
echo "== knot wiki installed =="
echo " KNOT_WIKI=$TARGET"
echo " ingest: bash tools/knot/run-knot.sh ingest"
echo " query: bash tools/knot/run-knot.sh query \"질문\""
echo " lint: bash tools/knot/run-knot.sh lint"
echo " docs: docs/KNOT-HARNESS-INTEGRATION.md"
```
공개 문서 변환 코드 (HTML)
<h1>tools/knot/install-knot-wiki.sh</h1>
<blockquote>
<p>Hub reference copy — MAS 정본: <code>tools/knot/install-knot-wiki.sh</code></p>
</blockquote>
<pre><code class="language-bash">#!/usr/bin/env bash
# Install knot knowledge wiki scaffold (vendor-neutral markdown vault).
# Upstream: https://github.com/netwaif/knot — upstream calls it "vault"; local LAB folder: knot-wiki
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
SCAFFOLD="$ROOT/tools/knot/scaffold"
TARGET="${1:-$ROOT/knot-wiki}"
usage() {
cat <<EOF
Usage: install-knot-wiki.sh [TARGET_DIR]
Install knot wiki scaffold (default: \$ROOT/knot-wiki — LAB).
Sets KNOT_WIKI in tools/knot/env.example for shell hook.
Options via env:
KNOT_SKIP_GIT=1 skip git init on new vault
Examples:
bash tools/knot/install-knot-wiki.sh
bash tools/knot/install-knot-wiki.sh ~/Desktop/MultiAgentSystem/knot-wiki
source tools/knot/env.example
EOF
}
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
usage
exit 0
fi
if [[ ! -d "$SCAFFOLD" ]]; then
echo "[FAIL] scaffold missing: $SCAFFOLD" >&2
exit 1
fi
if [[ -e "$TARGET" && -n "$(ls -A "$TARGET" 2>/dev/null)" ]]; then
echo "[FAIL] target not empty: $TARGET" >&2
echo " use empty dir or omit existing wiki" >&2
exit 1
fi
mkdir -p "$TARGET"
if command -v rsync >/dev/null 2>&1; then
rsync -a "$SCAFFOLD/" "$TARGET/"
else
cp -a "$SCAFFOLD/." "$TARGET/"
fi
if [[ "${KNOT_SKIP_GIT:-0}" != "1" ]] && [[ ! -d "$TARGET/.git" ]]; then
git -C "$TARGET" init -q
git -C "$TARGET" add -A
git -C "$TARGET" commit -q -m "chore: knot wiki scaffold from MultiAgentSystem tools/knot"
echo "[OK] git init + initial commit"
fi
ENV_EXAMPLE="$ROOT/tools/knot/env.example"
mkdir -p "$(dirname "$ENV_EXAMPLE")"
cat > "$ENV_EXAMPLE" <<EOF
# Source in shell: export KNOT_WIKI="$TARGET"
export KNOT_WIKI="$TARGET"
# Runner: claude (default) | codex | agy | gemini
export KNOT_RUNNER=claude
EOF
LINT_PY="$TARGET/ops/scripts/lint.py"
[[ -f "$LINT_PY" ]] || LINT_PY="$TARGET/scripts/lint.py"
if python3 "$LINT_PY" "$TARGET" >/dev/null 2>&1; then
echo "[OK] lint.py PASS (empty wiki)"
else
echo "[WARN] lint.py reported issues — run: python3 $LINT_PY" >&2
fi
echo
echo "== knot wiki installed =="
echo " KNOT_WIKI=$TARGET"
echo " ingest: bash tools/knot/run-knot.sh ingest"
echo " query: bash tools/knot/run-knot.sh query \"질문\""
echo " lint: bash tools/knot/run-knot.sh lint"
echo " docs: docs/KNOT-HARNESS-INTEGRATION.md"
</code></pre>