diff options
| author | Danilo M. <danix@danix.xyz> | 2026-10-19 11:49:06 +0200 |
|---|---|---|
| committer | Danilo M. <danix@danix.xyz> | 2026-10-19 11:49:06 +0200 |
| commit | a150177a95ab576532559a1d8bf97d1cb17086e4 (patch) | |
| tree | b9631753be42c909963f443f5a4ed76e2f1bd4bc /examples/tools/test-project.sh | |
| parent | 18a589cb4ad8f42e5190318fd1b912abf017ea0d (diff) | |
| download | desktop-assistant-a150177a95ab576532559a1d8bf97d1cb17086e4.tar.gz desktop-assistant-a150177a95ab576532559a1d8bf97d1cb17086e4.zip | |
project tool: start a new project and open an agent on it
project.sh makes a folder in ~/Programming/GIT with AGENTS.md, CLAUDE.md,
README.md and LICENSE (GPLv2 only, GPLv2+, GPLv3 or MIT, texts shipped in
licenses/), commits it signed, and opens Claude Code or opencode in a
kitty tab, or a new window when no kitty listens. The tool description
asks the model to confirm before calling. Check: test-project.sh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'examples/tools/test-project.sh')
| -rwxr-xr-x | examples/tools/test-project.sh | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/examples/tools/test-project.sh b/examples/tools/test-project.sh new file mode 100755 index 0000000..5702618 --- /dev/null +++ b/examples/tools/test-project.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# desktop-assistant tool check: project.sh against a scratch projects dir. +# Copyright (C) 2026 Danilo M. <danix@danix.xyz> +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 as published +# by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# test-project.sh: projects go to a throwaway PROJECTS_DIR and KITTY=true, +# so no tab opens. Commits are really signed: a cold PIN cache asks once. +# Prints "ok" or one FAIL line per broken case. + +set -u +here=$(dirname "$0") +PROJECTS_DIR=$(mktemp -d) +KITTY=true +export PROJECTS_DIR KITTY +trap 'rm -rf "$PROJECTS_DIR"' EXIT +fail=0 +check() { [ "$2" = "$3" ] || { echo "FAIL $1: got '$2', want '$3'"; fail=1; }; } +p=$PROJECTS_DIR/demo +year=$(date +%Y) + +out=$("$here/project.sh" demo "" "A demo project." "") +case "$out" in + "created $p (GPLv2 only), committed "*", opened claude in a kitty "*) ;; + *) echo "FAIL output: $out"; fail=1 ;; +esac +check "files" "$(cd "$p" && ls)" "$(printf '%s\n' AGENTS.md CLAUDE.md LICENSE README.md)" +check "signed" "$(git -C "$p" log --format=%G?)" "G" +check "branch" "$(git -C "$p" branch --show-current)" "master" +check "clean" "$(git -C "$p" status --porcelain)" "" +cmp -s "$p/LICENSE" "$here/licenses/gpl-2.0.txt"; check "license text" "$?" "0" +check "claude" "$(tail -1 "$p/CLAUDE.md")" "@AGENTS.md" +grep -qF '`demo`: A demo project.' "$p/AGENTS.md"; check "agents" "$?" "0" +grep -qF 'GPLv2 only. See [LICENSE]' "$p/README.md"; check "readme license" "$?" "0" +grep -qF '## Development Approach' "$p/README.md"; check "readme ai" "$?" "0" + +out=$("$here/project.sh" m mit "MIT one." opencode) +case "$out" in *", opened opencode in a kitty "*) ;; *) echo "FAIL opencode: $out"; fail=1 ;; esac +check "mit" "$(grep -c "Copyright (c) $year Danilo M. <danix@danix.xyz>" "$PROJECTS_DIR/m/LICENSE")" "1" + +for bad in Foo ../x "" .x; do + "$here/project.sh" "$bad" "" "x." >/dev/null 2>&1; check "name '$bad'" "$?" "1" +done +"$here/project.sh" demo "" "x." >/dev/null 2>&1; check "exists" "$?" "1" +"$here/project.sh" n bsd "x." >/dev/null 2>&1; check "license" "$?" "1" +"$here/project.sh" n "" "" >/dev/null 2>&1; check "no description" "$?" "1" +"$here/project.sh" n "" "x." vim >/dev/null 2>&1; check "agent" "$?" "1" +check "nothing else made" "$(ls "$PROJECTS_DIR" | tr '\n' ' ')" "demo m " +[ $fail = 0 ] && echo "ok" +exit $fail |
