mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-14 01:50:39 +09:00
feat(routines): add workspace-aware routine runs
Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
parent
36376968af
commit
909e8cd4c8
38 changed files with 15468 additions and 250 deletions
|
|
@ -31,20 +31,41 @@ source_env_path="$(dirname "$source_config_path")/.env"
|
|||
|
||||
mkdir -p "$paperclip_dir"
|
||||
|
||||
run_isolated_worktree_init() {
|
||||
run_paperclipai_command() {
|
||||
local command_args=("$@")
|
||||
if command -v pnpm >/dev/null 2>&1 && pnpm paperclipai --help >/dev/null 2>&1; then
|
||||
pnpm paperclipai worktree init --force --seed-mode minimal --name "$worktree_name" --from-config "$source_config_path"
|
||||
pnpm paperclipai "${command_args[@]}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
local base_cli_tsx_path="$base_cwd/cli/node_modules/tsx/dist/cli.mjs"
|
||||
local base_cli_entry_path="$base_cwd/cli/src/index.ts"
|
||||
if command -v node >/dev/null 2>&1 && [[ -f "$base_cli_tsx_path" ]] && [[ -f "$base_cli_entry_path" ]]; then
|
||||
node "$base_cli_tsx_path" "$base_cli_entry_path" "${command_args[@]}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if command -v paperclipai >/dev/null 2>&1; then
|
||||
paperclipai worktree init --force --seed-mode minimal --name "$worktree_name" --from-config "$source_config_path"
|
||||
paperclipai "${command_args[@]}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
run_isolated_worktree_init() {
|
||||
run_paperclipai_command \
|
||||
worktree \
|
||||
init \
|
||||
--force \
|
||||
--seed-mode \
|
||||
minimal \
|
||||
--name \
|
||||
"$worktree_name" \
|
||||
--from-config \
|
||||
"$source_config_path"
|
||||
}
|
||||
|
||||
write_fallback_worktree_config() {
|
||||
WORKTREE_NAME="$worktree_name" \
|
||||
BASE_CWD="$base_cwd" \
|
||||
|
|
@ -300,6 +321,20 @@ if ! run_isolated_worktree_init; then
|
|||
write_fallback_worktree_config
|
||||
fi
|
||||
|
||||
disable_seeded_routines() {
|
||||
local company_id="${PAPERCLIP_COMPANY_ID:-}"
|
||||
if [[ -z "$company_id" ]]; then
|
||||
echo "PAPERCLIP_COMPANY_ID not set; skipping routine disable post-step." >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
if ! run_paperclipai_command routines disable-all --config "$worktree_config_path" --company-id "$company_id"; then
|
||||
echo "paperclipai CLI not available in this workspace; skipping routine disable post-step." >&2
|
||||
fi
|
||||
}
|
||||
|
||||
disable_seeded_routines
|
||||
|
||||
while IFS= read -r relative_path; do
|
||||
[[ -n "$relative_path" ]] || continue
|
||||
source_path="$base_cwd/$relative_path"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue