loki-mode 7.72.0 → 7.73.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/README.md +1 -1
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/lib/git-pr-advisory.sh +112 -0
- package/autonomy/loki +404 -1
- package/autonomy/run.sh +416 -28
- package/autonomy/verify.sh +7 -1
- package/dashboard/__init__.py +1 -1
- package/docs/BRANCH-LIFECYCLE-PLAN.md +354 -0
- package/docs/DEPLOY-PLAN.md +302 -0
- package/docs/INSTALLATION.md +2 -2
- package/loki-ts/dist/loki.js +2 -2
- package/mcp/__init__.py +1 -1
- package/package.json +1 -1
- package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
package/README.md
CHANGED
|
@@ -444,7 +444,7 @@ See [benchmarks/](benchmarks/) for methodology.
|
|
|
444
444
|
| Area | What Works | What Doesn't (Yet) |
|
|
445
445
|
|------|-----------|---------------------|
|
|
446
446
|
| **Code Gen** | Full-stack apps from PRDs | Complex domain logic may need human review |
|
|
447
|
-
| **Deploy** | Generates configs, Dockerfiles, CI/CD | Does not deploy -- human runs deploy
|
|
447
|
+
| **Deploy** | Generates configs, Dockerfiles, CI/CD; `loki deploy` prints the exact deploy command | Does not deploy -- human runs the printed deploy command (Loki never runs a cloud CLI or git push) |
|
|
448
448
|
| **Testing** | 8 automated quality gates | Test quality depends on AI assertions |
|
|
449
449
|
| **Providers** | 5 providers with auto-failover | Non-Claude providers lack parallel agents |
|
|
450
450
|
| **Dashboard** | Real-time single-machine monitoring | No multi-node clustering |
|
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: loki-mode
|
|
|
3
3
|
description: Autonomous spec-driven build system with a built-in trust layer. It does not call work done until it is verified (RARV-C closure loop, 8 quality gates, completion council, verified-completion evidence gate). Triggers on "Loki Mode". Takes a spec (PRD, GitHub issue, OpenAPI doc, etc.) to deployed product with minimal human intervention. Provider-agnostic. Requires --dangerously-skip-permissions flag.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Loki Mode v7.
|
|
6
|
+
# Loki Mode v7.73.0
|
|
7
7
|
|
|
8
8
|
**You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
|
|
9
9
|
|
|
@@ -406,4 +406,4 @@ See `CHANGELOG.md` entries [7.5.7], [7.5.8], [7.5.13] for the per-fix list and r
|
|
|
406
406
|
|
|
407
407
|
---
|
|
408
408
|
|
|
409
|
-
**v7.
|
|
409
|
+
**v7.73.0 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
7.
|
|
1
|
+
7.73.0
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# git-pr-advisory.sh -- shared, PRINT-ONLY pull-request advisory helper.
|
|
3
|
+
#
|
|
4
|
+
# LOAD-BEARING INVARIANT: every function here is pure and print-only. It NEVER
|
|
5
|
+
# runs `git push`, NEVER runs `gh pr create`, NEVER mutates the repo. It only
|
|
6
|
+
# prints the commands a user would run, plus a best-effort clipboard copy of the
|
|
7
|
+
# push line. This is the single source of truth sourced by BOTH autonomy/run.sh
|
|
8
|
+
# (LOCK A3 create_session_pr) and autonomy/loki (cmd_deploy) so the two surfaces
|
|
9
|
+
# print byte-identical, correct commands and cannot drift.
|
|
10
|
+
#
|
|
11
|
+
# set -e SAFE: this lib may be sourced under `set -uo pipefail` (run.sh) AND
|
|
12
|
+
# `set -euo pipefail` (loki). Every fallible command ends with `|| true` or sits
|
|
13
|
+
# in a guarded `if`; no bare `((..))`; every var defaulted with `${VAR:-}`;
|
|
14
|
+
# every optional tool is `command -v`-guarded. All print paths `return 0` so a
|
|
15
|
+
# sourced call cannot abort the caller under set -e.
|
|
16
|
+
|
|
17
|
+
# Double-source guard.
|
|
18
|
+
[ -n "${_GIT_PR_ADVISORY_SH:-}" ] && return 0
|
|
19
|
+
_GIT_PR_ADVISORY_SH=1
|
|
20
|
+
|
|
21
|
+
# _git_pr_advisory_origin_url [dir]
|
|
22
|
+
# Echoes the origin remote URL, or empty string if none. Best-effort, never errors.
|
|
23
|
+
_git_pr_advisory_origin_url() {
|
|
24
|
+
local dir="${1:-.}"
|
|
25
|
+
local url=""
|
|
26
|
+
command -v git >/dev/null 2>&1 || { printf '%s' ""; return 0; }
|
|
27
|
+
url="$(git -C "$dir" remote get-url origin 2>/dev/null || true)"
|
|
28
|
+
if [ -z "$url" ]; then
|
|
29
|
+
url="$(git -C "$dir" config --get remote.origin.url 2>/dev/null || true)"
|
|
30
|
+
fi
|
|
31
|
+
printf '%s' "${url:-}"
|
|
32
|
+
return 0
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# _git_pr_advisory_compare_url <origin_url> <base> <head>
|
|
36
|
+
# Echoes a GitHub compare URL, or empty if the origin URL is not a parseable
|
|
37
|
+
# github.com remote. Handles both ssh (git@github.com:owner/repo.git) and https
|
|
38
|
+
# (https://github.com/owner/repo[.git]) forms. Non-github hosts -> empty.
|
|
39
|
+
_git_pr_advisory_compare_url() {
|
|
40
|
+
local origin_url="${1:-}"
|
|
41
|
+
local base="${2:-}"
|
|
42
|
+
local head="${3:-}"
|
|
43
|
+
[ -n "$origin_url" ] || { printf '%s' ""; return 0; }
|
|
44
|
+
[ -n "$base" ] || { printf '%s' ""; return 0; }
|
|
45
|
+
[ -n "$head" ] || { printf '%s' ""; return 0; }
|
|
46
|
+
|
|
47
|
+
# Only github.com remotes yield a compare URL. Do not fabricate for other hosts.
|
|
48
|
+
case "$origin_url" in
|
|
49
|
+
*github.com[:/]*) : ;;
|
|
50
|
+
*) printf '%s' ""; return 0 ;;
|
|
51
|
+
esac
|
|
52
|
+
|
|
53
|
+
# Reuse the run.sh:2123-2133 idiom: extract owner/repo from ssh or https forms.
|
|
54
|
+
local repo=""
|
|
55
|
+
repo="$(printf '%s' "$origin_url" | sed -E 's/.*github\.com[:/]([^/]+\/[^/]+)(\.git)?$/\1/' 2>/dev/null || true)"
|
|
56
|
+
repo="${repo%.git}"
|
|
57
|
+
|
|
58
|
+
if [ -n "$repo" ] && [ "$repo" != "$origin_url" ] && [ "${repo#*/}" != "$repo" ]; then
|
|
59
|
+
printf '%s' "https://github.com/${repo}/compare/${base}...${head}?expand=1"
|
|
60
|
+
return 0
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
printf '%s' ""
|
|
64
|
+
return 0
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
# print_pr_advice <base_branch> <head_branch> [dir]
|
|
68
|
+
# Prints PR advice. PRINT-ONLY: never pushes, never creates a PR. Always return 0.
|
|
69
|
+
print_pr_advice() {
|
|
70
|
+
local base="${1:-main}"
|
|
71
|
+
local head="${2:-HEAD}"
|
|
72
|
+
local dir="${3:-.}"
|
|
73
|
+
|
|
74
|
+
printf '%s\n' "To open a pull request:"
|
|
75
|
+
printf '%s\n' " git push -u origin ${head}"
|
|
76
|
+
|
|
77
|
+
if command -v gh >/dev/null 2>&1; then
|
|
78
|
+
printf '%s\n' " gh pr create --base ${base} --head ${head} --title \"Loki Mode session changes\" --fill"
|
|
79
|
+
else
|
|
80
|
+
local origin_url="" compare_url=""
|
|
81
|
+
origin_url="$(_git_pr_advisory_origin_url "$dir")"
|
|
82
|
+
compare_url="$(_git_pr_advisory_compare_url "$origin_url" "$base" "$head")"
|
|
83
|
+
if [ -n "$compare_url" ]; then
|
|
84
|
+
printf '%s\n' " Open: ${compare_url}"
|
|
85
|
+
else
|
|
86
|
+
printf '%s\n' " Open a pull request for branch ${head} on your git host."
|
|
87
|
+
fi
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# Best-effort clipboard copy of the push line. TTY-gated, command-v guarded,
|
|
91
|
+
# never fatal. Print a note only if a copy tool actually ran.
|
|
92
|
+
if [ -t 1 ]; then
|
|
93
|
+
local push_line="git push -u origin ${head}"
|
|
94
|
+
local copied=""
|
|
95
|
+
if command -v pbcopy >/dev/null 2>&1; then
|
|
96
|
+
printf '%s' "$push_line" | pbcopy >/dev/null 2>&1 && copied="1" || true
|
|
97
|
+
elif command -v wl-copy >/dev/null 2>&1; then
|
|
98
|
+
printf '%s' "$push_line" | wl-copy >/dev/null 2>&1 && copied="1" || true
|
|
99
|
+
elif command -v xclip >/dev/null 2>&1; then
|
|
100
|
+
printf '%s' "$push_line" | xclip -selection clipboard >/dev/null 2>&1 && copied="1" || true
|
|
101
|
+
elif command -v xsel >/dev/null 2>&1; then
|
|
102
|
+
printf '%s' "$push_line" | xsel --clipboard --input >/dev/null 2>&1 && copied="1" || true
|
|
103
|
+
elif command -v clip >/dev/null 2>&1; then
|
|
104
|
+
printf '%s' "$push_line" | clip >/dev/null 2>&1 && copied="1" || true
|
|
105
|
+
fi
|
|
106
|
+
if [ -n "$copied" ]; then
|
|
107
|
+
printf '%s\n' " (push command copied to clipboard)"
|
|
108
|
+
fi
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
return 0
|
|
112
|
+
}
|
package/autonomy/loki
CHANGED
|
@@ -115,6 +115,16 @@ if [ -f "$_LOKI_SCRIPT_DIR/quickstart.sh" ]; then
|
|
|
115
115
|
source "$_LOKI_SCRIPT_DIR/quickstart.sh"
|
|
116
116
|
fi
|
|
117
117
|
|
|
118
|
+
# Shared PRINT-ONLY pull-request advisory (provides print_pr_advice and its
|
|
119
|
+
# origin/compare-URL helpers). Single source of truth sourced by BOTH this CLI
|
|
120
|
+
# (cmd_deploy CI/CD path) and autonomy/run.sh (create_session_pr) so the two
|
|
121
|
+
# surfaces print byte-identical, correct git push + PR commands and cannot drift.
|
|
122
|
+
# Self-guarded against double-source. Existence-guarded matching the pattern above.
|
|
123
|
+
if [ -f "$_LOKI_SCRIPT_DIR/lib/git-pr-advisory.sh" ]; then
|
|
124
|
+
# shellcheck source=autonomy/lib/git-pr-advisory.sh
|
|
125
|
+
source "$_LOKI_SCRIPT_DIR/lib/git-pr-advisory.sh"
|
|
126
|
+
fi
|
|
127
|
+
|
|
118
128
|
# Resolve the script's real path (handles symlinks)
|
|
119
129
|
resolve_script_path() {
|
|
120
130
|
local script="$1"
|
|
@@ -725,7 +735,7 @@ show_help() {
|
|
|
725
735
|
echo " version Show version"
|
|
726
736
|
echo " help Show this help ('loki help aliases' for old names)"
|
|
727
737
|
echo ""
|
|
728
|
-
echo "More commands (grill, spec, cleanup, init, watch, demo, web, api,"
|
|
738
|
+
echo "More commands (grill, spec, deploy, cleanup, init, watch, demo, web, api,"
|
|
729
739
|
echo "logs, github, import, council, proof, audit, compliance, agent, template,"
|
|
730
740
|
echo "magic, docs, wiki, ci, test, bench, secrets, telemetry, crash, worktree,"
|
|
731
741
|
echo "failover, monitor, remote, ...) are dispatchable and documented via"
|
|
@@ -5658,6 +5668,396 @@ cmd_preview() {
|
|
|
5658
5668
|
fi
|
|
5659
5669
|
}
|
|
5660
5670
|
|
|
5671
|
+
# =============================================================================
|
|
5672
|
+
# loki deploy -- ADVISORY / PRINT-ONLY deploy command (FEAT-DEPLOY).
|
|
5673
|
+
#
|
|
5674
|
+
# WHY ITS OWN COMMAND (not a preview flag): `loki preview` is "show me the local
|
|
5675
|
+
# app I already built and started" and is GATED on a running app (state.json
|
|
5676
|
+
# status=running, a live reachable port). `loki deploy` is conceptually distinct:
|
|
5677
|
+
# it is a STATIC, FILESYSTEM-ONLY advisory about the project's type and the user's
|
|
5678
|
+
# installed cloud CLI / CI-CD pipeline. It must work with nothing running and no
|
|
5679
|
+
# build started, so it has NO running-app precondition. Folding it into preview
|
|
5680
|
+
# would force preview's running-app gate onto a feature that must not have one.
|
|
5681
|
+
#
|
|
5682
|
+
# HARD INVARIANT (DEPLOY-PLAN LOCK 5 + BRANCH-LIFECYCLE LOCK B4): PRINT-ONLY.
|
|
5683
|
+
# cmd_deploy NEVER runs a cloud CLI (vercel/netlify/flyctl/wrangler) -- not even
|
|
5684
|
+
# `--version` -- and NEVER runs `git push` or `gh pr create`. Tool detection is
|
|
5685
|
+
# `command -v` ONLY. Loki advises; the human runs the printed command. This keeps
|
|
5686
|
+
# the README promise ("Does not deploy -- human runs deploy commands") literally
|
|
5687
|
+
# true. Only the clipboard tools (pbcopy/wl-copy/...) and `command -v` may run.
|
|
5688
|
+
#
|
|
5689
|
+
# This whole block is contiguous (helpers + cmd_deploy) so a test can extract it
|
|
5690
|
+
# by name anchor, mirroring tests/test-preview-public.sh.
|
|
5691
|
+
# =============================================================================
|
|
5692
|
+
|
|
5693
|
+
# _deploy_detect_type <dir>
|
|
5694
|
+
# Echoes the PRIMARY project-type label (one of: nextjs, static, docker, node,
|
|
5695
|
+
# python) or empty if none detected. Read-only file/dir existence + grep on
|
|
5696
|
+
# package.json. Always returns 0 (caller treats empty as "no project"). First
|
|
5697
|
+
# match wins for the primary label; cmd_deploy still offers multiple provider
|
|
5698
|
+
# options per type. set -e safe: every grep is `|| true`-guarded.
|
|
5699
|
+
_deploy_detect_type() {
|
|
5700
|
+
local dir="${1:-.}"
|
|
5701
|
+
local pkg="$dir/package.json"
|
|
5702
|
+
|
|
5703
|
+
# 1. Next.js -- source signal ("next" dep or a next.config.*), NOT the build
|
|
5704
|
+
# artifact (.next/standalone), since the build may not have run yet.
|
|
5705
|
+
if [ -f "$pkg" ] && grep -q '"next"' "$pkg" 2>/dev/null; then
|
|
5706
|
+
printf '%s' "nextjs"; return 0
|
|
5707
|
+
fi
|
|
5708
|
+
if [ -f "$dir/next.config.js" ] || [ -f "$dir/next.config.mjs" ] || [ -f "$dir/next.config.ts" ]; then
|
|
5709
|
+
printf '%s' "nextjs"; return 0
|
|
5710
|
+
fi
|
|
5711
|
+
|
|
5712
|
+
# 2. Static / SPA -- a built dist/ or build/ dir containing index.html, OR a
|
|
5713
|
+
# Vite / CRA source signal in package.json.
|
|
5714
|
+
if { [ -d "$dir/dist" ] && [ -f "$dir/dist/index.html" ]; } || \
|
|
5715
|
+
{ [ -d "$dir/build" ] && [ -f "$dir/build/index.html" ]; }; then
|
|
5716
|
+
printf '%s' "static"; return 0
|
|
5717
|
+
fi
|
|
5718
|
+
if [ -f "$pkg" ] && { grep -q '"vite"' "$pkg" 2>/dev/null || grep -q '"react-scripts"' "$pkg" 2>/dev/null; }; then
|
|
5719
|
+
printf '%s' "static"; return 0
|
|
5720
|
+
fi
|
|
5721
|
+
|
|
5722
|
+
# 3. Dockerfile / containerized server.
|
|
5723
|
+
if [ -f "$dir/Dockerfile" ]; then
|
|
5724
|
+
printf '%s' "docker"; return 0
|
|
5725
|
+
fi
|
|
5726
|
+
|
|
5727
|
+
# 4. Generic Node server -- package.json with a start (or dev) script.
|
|
5728
|
+
if [ -f "$pkg" ] && { grep -q '"start"' "$pkg" 2>/dev/null || grep -q '"dev"' "$pkg" 2>/dev/null; }; then
|
|
5729
|
+
printf '%s' "node"; return 0
|
|
5730
|
+
fi
|
|
5731
|
+
|
|
5732
|
+
# 5. Python.
|
|
5733
|
+
if [ -f "$dir/requirements.txt" ] || [ -f "$dir/pyproject.toml" ]; then
|
|
5734
|
+
printf '%s' "python"; return 0
|
|
5735
|
+
fi
|
|
5736
|
+
|
|
5737
|
+
printf '%s' ""
|
|
5738
|
+
return 0
|
|
5739
|
+
}
|
|
5740
|
+
|
|
5741
|
+
# _deploy_options_for_type <type>
|
|
5742
|
+
# Pure, DIR-BLIND helper: echoes the ordered candidate rows for a project type,
|
|
5743
|
+
# one per line, as `provider|cli|command|docs`. Idiomatic provider first per
|
|
5744
|
+
# DEPLOY-PLAN LOCK 2. Lists the FULL ordered candidate set for the type
|
|
5745
|
+
# UNCONDITIONALLY (no dir awareness, no CLI-installed filtering -- cmd_deploy does
|
|
5746
|
+
# the `command -v` filtering). The command strings are the EXACT canonical forms
|
|
5747
|
+
# from DEPLOY-PLAN LOCK 3 (a wrong flag is worse than no feature; do not
|
|
5748
|
+
# paraphrase). Project-dependent dirs stay as `<...>` placeholders the user fills.
|
|
5749
|
+
# Note: the Fly CLI binary is `flyctl` but the canonical deploy verb is
|
|
5750
|
+
# `fly deploy` -- "fly" not "flyctl" here is CORRECT, intentional, not a typo.
|
|
5751
|
+
_deploy_options_for_type() {
|
|
5752
|
+
local type="${1:-}"
|
|
5753
|
+
case "$type" in
|
|
5754
|
+
nextjs)
|
|
5755
|
+
printf '%s\n' "Vercel|vercel|vercel --prod|https://vercel.com/docs/cli"
|
|
5756
|
+
printf '%s\n' "Netlify|netlify|netlify deploy --prod|https://docs.netlify.com/cli/get-started/"
|
|
5757
|
+
# fly not flyctl - correct: binary is flyctl, deploy verb is `fly deploy`.
|
|
5758
|
+
printf '%s\n' "Fly.io|flyctl|fly deploy|https://fly.io/docs/flyctl/install/"
|
|
5759
|
+
;;
|
|
5760
|
+
static)
|
|
5761
|
+
printf '%s\n' "Netlify|netlify|netlify deploy --prod --dir=<build-output>|https://docs.netlify.com/cli/get-started/"
|
|
5762
|
+
printf '%s\n' "Cloudflare Pages|wrangler|wrangler pages deploy <build-output>|https://developers.cloudflare.com/workers/wrangler/install-and-update/"
|
|
5763
|
+
printf '%s\n' "Vercel|vercel|vercel --prod|https://vercel.com/docs/cli"
|
|
5764
|
+
;;
|
|
5765
|
+
docker)
|
|
5766
|
+
# fly not flyctl - correct (see note above).
|
|
5767
|
+
printf '%s\n' "Fly.io|flyctl|fly deploy|https://fly.io/docs/flyctl/install/"
|
|
5768
|
+
printf '%s\n' "Cloudflare|wrangler|wrangler deploy|https://developers.cloudflare.com/workers/wrangler/install-and-update/"
|
|
5769
|
+
;;
|
|
5770
|
+
node)
|
|
5771
|
+
# fly not flyctl - correct (see note above).
|
|
5772
|
+
printf '%s\n' "Fly.io|flyctl|fly deploy|https://fly.io/docs/flyctl/install/"
|
|
5773
|
+
printf '%s\n' "Vercel|vercel|vercel --prod|https://vercel.com/docs/cli"
|
|
5774
|
+
;;
|
|
5775
|
+
python)
|
|
5776
|
+
# fly not flyctl - correct (see note above).
|
|
5777
|
+
printf '%s\n' "Fly.io|flyctl|fly deploy|https://fly.io/docs/flyctl/install/"
|
|
5778
|
+
;;
|
|
5779
|
+
esac
|
|
5780
|
+
return 0
|
|
5781
|
+
}
|
|
5782
|
+
|
|
5783
|
+
# _deploy_detect_cicd <dir>
|
|
5784
|
+
# Returns 0 + echoes the detected CI/CD system name(s) (space-separated) if ANY
|
|
5785
|
+
# pipeline config exists (BRANCH-LIFECYCLE LOCK B1); returns 1 + echoes nothing
|
|
5786
|
+
# if none. Read-only file existence only. The `[ -e "$f" ]` guard inside the glob
|
|
5787
|
+
# loop makes the no-match literal-glob case set -e safe (an unmatched glob expands
|
|
5788
|
+
# to the literal pattern, which `[ -e ]` then rejects without aborting).
|
|
5789
|
+
_deploy_detect_cicd() {
|
|
5790
|
+
local dir="${1:-.}"
|
|
5791
|
+
local found=""
|
|
5792
|
+
local systems=""
|
|
5793
|
+
|
|
5794
|
+
# GitHub Actions: any .yml or .yaml under .github/workflows/.
|
|
5795
|
+
local f
|
|
5796
|
+
for f in "$dir"/.github/workflows/*.yml "$dir"/.github/workflows/*.yaml; do
|
|
5797
|
+
if [ -e "$f" ]; then found=1; systems="${systems} GitHub-Actions"; break; fi
|
|
5798
|
+
done
|
|
5799
|
+
|
|
5800
|
+
[ -f "$dir/.gitlab-ci.yml" ] && { found=1; systems="${systems} GitLab-CI"; }
|
|
5801
|
+
[ -f "$dir/Jenkinsfile" ] && { found=1; systems="${systems} Jenkins"; }
|
|
5802
|
+
[ -f "$dir/.circleci/config.yml" ] && { found=1; systems="${systems} CircleCI"; }
|
|
5803
|
+
[ -f "$dir/azure-pipelines.yml" ] && { found=1; systems="${systems} Azure-Pipelines"; }
|
|
5804
|
+
[ -f "$dir/bitbucket-pipelines.yml" ] && { found=1; systems="${systems} Bitbucket-Pipelines"; }
|
|
5805
|
+
|
|
5806
|
+
if [ -n "$found" ]; then
|
|
5807
|
+
# Trim the leading space and echo the names.
|
|
5808
|
+
printf '%s' "${systems# }"
|
|
5809
|
+
return 0
|
|
5810
|
+
fi
|
|
5811
|
+
printf '%s' ""
|
|
5812
|
+
return 1
|
|
5813
|
+
}
|
|
5814
|
+
|
|
5815
|
+
# _deploy_copy_clipboard <cmd>
|
|
5816
|
+
# Best-effort clipboard copy of a SINGLE command (DEPLOY-PLAN LOCK 4). TTY-gated,
|
|
5817
|
+
# command-v guarded, ALWAYS returns 0 and never fatal. Echoes a confirmation note
|
|
5818
|
+
# only if a copy tool actually ran. These clipboard tools ARE allowed to run; only
|
|
5819
|
+
# the four cloud CLIs are forbidden.
|
|
5820
|
+
_deploy_copy_clipboard() {
|
|
5821
|
+
local cmd="${1:-}"
|
|
5822
|
+
[ -n "$cmd" ] || return 0
|
|
5823
|
+
[ -t 1 ] || return 0
|
|
5824
|
+
local copied=""
|
|
5825
|
+
if command -v pbcopy >/dev/null 2>&1; then
|
|
5826
|
+
printf '%s' "$cmd" | pbcopy >/dev/null 2>&1 && copied="1" || true
|
|
5827
|
+
elif command -v wl-copy >/dev/null 2>&1; then
|
|
5828
|
+
printf '%s' "$cmd" | wl-copy >/dev/null 2>&1 && copied="1" || true
|
|
5829
|
+
elif command -v xclip >/dev/null 2>&1; then
|
|
5830
|
+
printf '%s' "$cmd" | xclip -selection clipboard >/dev/null 2>&1 && copied="1" || true
|
|
5831
|
+
elif command -v xsel >/dev/null 2>&1; then
|
|
5832
|
+
printf '%s' "$cmd" | xsel --clipboard --input >/dev/null 2>&1 && copied="1" || true
|
|
5833
|
+
elif command -v clip >/dev/null 2>&1; then
|
|
5834
|
+
printf '%s' "$cmd" | clip >/dev/null 2>&1 && copied="1" || true
|
|
5835
|
+
fi
|
|
5836
|
+
if [ -n "$copied" ]; then
|
|
5837
|
+
printf '%s\n' " (copied to clipboard: ${cmd})"
|
|
5838
|
+
fi
|
|
5839
|
+
return 0
|
|
5840
|
+
}
|
|
5841
|
+
|
|
5842
|
+
# _deploy_print_install_hint <type>
|
|
5843
|
+
# Honest install hints (brew + official URL) for the candidate providers of a
|
|
5844
|
+
# type. NEVER fabricates success, NEVER downloads a binary. Mirrors the
|
|
5845
|
+
# tunnel-missing / gh-missing block. Caller redirects to stderr.
|
|
5846
|
+
_deploy_print_install_hint() {
|
|
5847
|
+
local type="${1:-}"
|
|
5848
|
+
echo "No deploy CLI found for this ${type} project."
|
|
5849
|
+
echo "Loki never accesses your cloud account or runs deploy for you -- you run"
|
|
5850
|
+
echo "the printed command. Install one of the following, then re-run 'loki deploy':"
|
|
5851
|
+
echo ""
|
|
5852
|
+
local options provider cli command docs
|
|
5853
|
+
options="$(_deploy_options_for_type "$type")"
|
|
5854
|
+
while IFS='|' read -r provider cli command docs; do
|
|
5855
|
+
[ -n "$provider" ] || continue
|
|
5856
|
+
case "$cli" in
|
|
5857
|
+
vercel) echo " Vercel: brew install vercel | ${docs}" ;;
|
|
5858
|
+
netlify) echo " Netlify: brew install netlify-cli | ${docs}" ;;
|
|
5859
|
+
flyctl) echo " Fly.io: brew install flyctl | ${docs}" ;;
|
|
5860
|
+
wrangler) echo " Cloudflare: npm i -g wrangler | ${docs}" ;;
|
|
5861
|
+
*) echo " ${provider}: ${docs}" ;;
|
|
5862
|
+
esac
|
|
5863
|
+
done <<EOF
|
|
5864
|
+
$options
|
|
5865
|
+
EOF
|
|
5866
|
+
return 0
|
|
5867
|
+
}
|
|
5868
|
+
|
|
5869
|
+
# _deploy_print_cloud_options <dir> <type> <do_clip> <hint_on_none>
|
|
5870
|
+
# Prints every installed (project-type x CLI) option block, idiomatic first.
|
|
5871
|
+
# Best-effort copies the FIRST installed command when do_clip=true. Returns 0 if
|
|
5872
|
+
# at least one CLI was printed. If NONE installed: when hint_on_none=true, prints
|
|
5873
|
+
# the honest install hint (to stderr) and returns 1; when false (pipeline path,
|
|
5874
|
+
# where cloud is secondary), prints nothing and returns 1 silently.
|
|
5875
|
+
_deploy_print_cloud_options() {
|
|
5876
|
+
local dir="${1:-.}"
|
|
5877
|
+
local type="${2:-}"
|
|
5878
|
+
local do_clip="${3:-true}"
|
|
5879
|
+
local hint_on_none="${4:-true}"
|
|
5880
|
+
|
|
5881
|
+
local options=""
|
|
5882
|
+
options="$(_deploy_options_for_type "$type")"
|
|
5883
|
+
|
|
5884
|
+
local printed=false
|
|
5885
|
+
local first_cmd=""
|
|
5886
|
+
local provider cli command docs
|
|
5887
|
+
while IFS='|' read -r provider cli command docs; do
|
|
5888
|
+
[ -n "$cli" ] || continue
|
|
5889
|
+
if command -v "$cli" >/dev/null 2>&1; then
|
|
5890
|
+
if [ "$printed" != true ]; then
|
|
5891
|
+
echo -e "${BOLD}Detected ${type} project. Deploy options (run one yourself):${NC}"
|
|
5892
|
+
echo ""
|
|
5893
|
+
printed=true
|
|
5894
|
+
fi
|
|
5895
|
+
echo " ${provider}:"
|
|
5896
|
+
echo " ${command}"
|
|
5897
|
+
echo " docs: ${docs}"
|
|
5898
|
+
echo ""
|
|
5899
|
+
if [ -z "$first_cmd" ]; then
|
|
5900
|
+
first_cmd="$command"
|
|
5901
|
+
fi
|
|
5902
|
+
fi
|
|
5903
|
+
done <<EOF
|
|
5904
|
+
$options
|
|
5905
|
+
EOF
|
|
5906
|
+
|
|
5907
|
+
if [ "$printed" = true ]; then
|
|
5908
|
+
echo "Loki does not deploy for you. Review, then run the command yourself."
|
|
5909
|
+
if [ "$do_clip" = true ] && [ -n "$first_cmd" ]; then
|
|
5910
|
+
_deploy_copy_clipboard "$first_cmd"
|
|
5911
|
+
fi
|
|
5912
|
+
return 0
|
|
5913
|
+
fi
|
|
5914
|
+
|
|
5915
|
+
# No installed CLI for this type.
|
|
5916
|
+
if [ "$hint_on_none" = true ]; then
|
|
5917
|
+
_deploy_print_install_hint "$type" >&2
|
|
5918
|
+
return 1
|
|
5919
|
+
fi
|
|
5920
|
+
return 1
|
|
5921
|
+
}
|
|
5922
|
+
|
|
5923
|
+
# cmd_deploy [--dir <path>] [--no-clip] [--help]
|
|
5924
|
+
# Advisory orchestration: detect project type + CI/CD pipeline + installed cloud
|
|
5925
|
+
# CLIs, then PRINT the canonical deploy command(s). PRINT-ONLY (see block header).
|
|
5926
|
+
# Placed LAST in the contiguous deploy block (all helpers above it) so the SDET
|
|
5927
|
+
# can extract from the first helper def to the close of cmd_deploy and capture the
|
|
5928
|
+
# whole self-contained unit (mirrors test-preview-public.sh, where cmd_preview is
|
|
5929
|
+
# the terminal function).
|
|
5930
|
+
cmd_deploy() {
|
|
5931
|
+
local dir="${TARGET_DIR:-.}"
|
|
5932
|
+
local do_clip=true
|
|
5933
|
+
|
|
5934
|
+
# Arg parse (mirror cmd_preview: lenient on unknown args -> no behavior drift).
|
|
5935
|
+
while [ $# -gt 0 ]; do
|
|
5936
|
+
case "${1:-}" in
|
|
5937
|
+
--help|-h|help)
|
|
5938
|
+
echo -e "${BOLD}Loki Mode -- advisory deploy command (print-only)${NC}"
|
|
5939
|
+
echo ""
|
|
5940
|
+
echo "Usage: loki deploy [--dir <path>] [--no-clip]"
|
|
5941
|
+
echo ""
|
|
5942
|
+
echo "Detects your project type and your installed cloud CLI (and any"
|
|
5943
|
+
echo "CI/CD pipeline), then PRINTS the exact deploy command for YOU to run."
|
|
5944
|
+
echo "It is advisory only: it NEVER deploys, NEVER runs a cloud CLI (not"
|
|
5945
|
+
echo "even --version), and NEVER runs 'git push'. Loki does not access your"
|
|
5946
|
+
echo "cloud account. You run the printed command. Detection is read-only."
|
|
5947
|
+
echo ""
|
|
5948
|
+
echo "If a CI/CD pipeline (GitHub Actions, GitLab CI, Jenkins, CircleCI,"
|
|
5949
|
+
echo "Azure Pipelines, Bitbucket) is detected, the primary advice is the"
|
|
5950
|
+
echo "git push + pull-request path, because your pipeline deploys on merge."
|
|
5951
|
+
echo ""
|
|
5952
|
+
echo "Options:"
|
|
5953
|
+
echo " --dir <path> Project directory to scan (default: current dir)"
|
|
5954
|
+
echo " --no-clip Do not copy the idiomatic command to the clipboard"
|
|
5955
|
+
echo " --help, -h Show this help and exit"
|
|
5956
|
+
return 0
|
|
5957
|
+
;;
|
|
5958
|
+
--dir)
|
|
5959
|
+
dir="${2:-.}"
|
|
5960
|
+
# Guard the value-consuming shift: if --dir is the LAST arg (no
|
|
5961
|
+
# value), an unguarded shift plus the loop's trailing shift would
|
|
5962
|
+
# underflow and abort under set -e. Consume a value only if present.
|
|
5963
|
+
[ $# -ge 2 ] && shift
|
|
5964
|
+
;;
|
|
5965
|
+
--no-clip)
|
|
5966
|
+
do_clip=false
|
|
5967
|
+
;;
|
|
5968
|
+
esac
|
|
5969
|
+
shift
|
|
5970
|
+
done
|
|
5971
|
+
|
|
5972
|
+
# Resolve to '.' if the chosen dir does not exist (honest, no crash).
|
|
5973
|
+
[ -d "$dir" ] || dir="."
|
|
5974
|
+
|
|
5975
|
+
# Detect CI/CD pipeline FIRST (BRANCH-LIFECYCLE LOCK B3 precedence).
|
|
5976
|
+
local cicd=""
|
|
5977
|
+
cicd="$(_deploy_detect_cicd "$dir" || true)"
|
|
5978
|
+
local has_pipeline=false
|
|
5979
|
+
[ -n "$cicd" ] && has_pipeline=true
|
|
5980
|
+
|
|
5981
|
+
# Detect project type (filesystem-only; LOCK 6 -- not gated on a running app).
|
|
5982
|
+
local type=""
|
|
5983
|
+
type="$(_deploy_detect_type "$dir")"
|
|
5984
|
+
|
|
5985
|
+
# ---- Pipeline path (LOCK B3): git push + PR advised FIRST, cloud secondary.
|
|
5986
|
+
if [ "$has_pipeline" = true ]; then
|
|
5987
|
+
echo -e "${BOLD}CI/CD pipeline detected (${cicd})${NC}"
|
|
5988
|
+
echo "Your pipeline deploys on push/merge, so the primary deploy path is"
|
|
5989
|
+
echo "commit + push + pull request:"
|
|
5990
|
+
echo ""
|
|
5991
|
+
|
|
5992
|
+
# Derive base/head for the PR advice. set -e safe: every git call is
|
|
5993
|
+
# 2>/dev/null with a fallback so a non-zero git never aborts the shell.
|
|
5994
|
+
local head="" base=""
|
|
5995
|
+
head="$(git -C "$dir" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")"
|
|
5996
|
+
[ -n "$head" ] || head="HEAD"
|
|
5997
|
+
case "$head" in
|
|
5998
|
+
loki/*)
|
|
5999
|
+
# On a loki branch: prefer the persisted base, else origin default.
|
|
6000
|
+
if [ -s "$dir/.loki/state/base-branch.txt" ]; then
|
|
6001
|
+
base="$(head -n1 "$dir/.loki/state/base-branch.txt" 2>/dev/null || echo "")"
|
|
6002
|
+
fi
|
|
6003
|
+
;;
|
|
6004
|
+
esac
|
|
6005
|
+
if [ -z "$base" ]; then
|
|
6006
|
+
# Best-effort: origin's default branch (e.g. origin/main -> main).
|
|
6007
|
+
local origin_head=""
|
|
6008
|
+
origin_head="$(git -C "$dir" symbolic-ref refs/remotes/origin/HEAD 2>/dev/null || echo "")"
|
|
6009
|
+
if [ -n "$origin_head" ]; then
|
|
6010
|
+
base="${origin_head##*/}"
|
|
6011
|
+
fi
|
|
6012
|
+
fi
|
|
6013
|
+
|
|
6014
|
+
if [ -n "$base" ] && declare -F print_pr_advice >/dev/null 2>&1; then
|
|
6015
|
+
print_pr_advice "$base" "$head" "$dir"
|
|
6016
|
+
elif declare -F print_pr_advice >/dev/null 2>&1; then
|
|
6017
|
+
echo " Could not determine the PR base branch automatically."
|
|
6018
|
+
echo " Set your PR base manually when opening the pull request for: ${head}"
|
|
6019
|
+
print_pr_advice "manually-set-base" "$head" "$dir"
|
|
6020
|
+
else
|
|
6021
|
+
echo " git push -u origin ${head}"
|
|
6022
|
+
echo " Open a pull request for ${head} (set the base branch manually)."
|
|
6023
|
+
fi
|
|
6024
|
+
echo ""
|
|
6025
|
+
|
|
6026
|
+
# Cloud CLI options are SECONDARY when a pipeline exists. Print them if a
|
|
6027
|
+
# project type + installed CLI match, but never fail the command on their
|
|
6028
|
+
# absence (the git/PR advice above is the real deliverable here).
|
|
6029
|
+
if [ -n "$type" ]; then
|
|
6030
|
+
# Pass do_clip=false here: in the pipeline path the git push line is
|
|
6031
|
+
# the PRIMARY advice (LOCK B3) and print_pr_advice already copied it to
|
|
6032
|
+
# the clipboard, so the secondary cloud command must NOT overwrite it.
|
|
6033
|
+
local printed_any=false
|
|
6034
|
+
_deploy_print_cloud_options "$dir" "$type" "false" "false" && printed_any=true || true
|
|
6035
|
+
if [ "$printed_any" != true ]; then
|
|
6036
|
+
: # No installed cloud CLI; the pipeline path already advised. Fine.
|
|
6037
|
+
fi
|
|
6038
|
+
fi
|
|
6039
|
+
return 0
|
|
6040
|
+
fi
|
|
6041
|
+
|
|
6042
|
+
# ---- No-pipeline path: cloud-CLI advisory exactly per DEPLOY-PLAN.md.
|
|
6043
|
+
# Honest failure: no project type detected.
|
|
6044
|
+
if [ -z "$type" ]; then
|
|
6045
|
+
{
|
|
6046
|
+
echo "No deployable project detected in: ${dir}"
|
|
6047
|
+
echo "Looked for: package.json (Next.js/Vite/CRA/Node), Dockerfile,"
|
|
6048
|
+
echo "dist/ or build/ with index.html, requirements.txt, pyproject.toml."
|
|
6049
|
+
echo "Run 'loki deploy --dir <path>' to point at your project directory."
|
|
6050
|
+
} >&2
|
|
6051
|
+
return 1
|
|
6052
|
+
fi
|
|
6053
|
+
|
|
6054
|
+
# Print cloud options; clipboard the idiomatic one. Returns non-zero (with an
|
|
6055
|
+
# honest install hint) when NO matching CLI is installed.
|
|
6056
|
+
local rc=0
|
|
6057
|
+
_deploy_print_cloud_options "$dir" "$type" "$do_clip" "true" || rc=$?
|
|
6058
|
+
return $rc
|
|
6059
|
+
}
|
|
6060
|
+
|
|
5661
6061
|
# Import GitHub issues
|
|
5662
6062
|
cmd_import() {
|
|
5663
6063
|
# v7.6.2 B-13 fix: --help must print help, not start an import.
|
|
@@ -14966,6 +15366,9 @@ main() {
|
|
|
14966
15366
|
preview)
|
|
14967
15367
|
cmd_preview "$@"
|
|
14968
15368
|
;;
|
|
15369
|
+
deploy)
|
|
15370
|
+
cmd_deploy "$@"
|
|
15371
|
+
;;
|
|
14969
15372
|
open)
|
|
14970
15373
|
# CLI consolidation (Phase A): 'open' is a deprecated alias of 'preview'.
|
|
14971
15374
|
_deprecated_alias open preview "$@"
|