Create, replace and delete local files
Review and apply local file and folder changes with complete authoring plans.
Use Altifigence CLI 0.1.9 on Linux to review local file changes and apply the complete plan to the same project.
Create files and folders
Use an absolute path to your local project. This example uses $HOME/alti-projects/demo-project. Run the commands as your ordinary user. Keep other writers paused while you review and apply a plan.
set -euo pipefail
PROJECT="$(cd "$HOME/alti-projects/demo-project" && pwd -P)"
WORK="$(mktemp -d)"
cat > "$WORK/create.json" <<'JSON'
[
{"kind":"create-directory","path":"notes"},
{"kind":"create","path":"notes/review.txt","content":"First review\n"}
]
JSON
alti ide workspace file-plan --project "$PROJECT" \
--request "$WORK/create.json" > "$WORK/create.plan.json"Require exit status 0, then read the complete plan:
cat "$WORK/create.plan.json"The plan has schema altifigence.workspace-authoring-plan.v1. Review its changes, observations and request, and retain the whole document. The planned paths are relative to the project.
Apply the saved plan:
alti ide workspace file-apply --project "$PROJECT" \
--request "$WORK/create.plan.json" > "$WORK/create.receipt.json"
jq '{schema, outcome}' "$WORK/create.receipt.json"After exit status 0, the selected receipt fields are:
{
"schema": "altifigence.workspace-file-receipt.v1",
"outcome": "committed"
}Replace a file
Read the current file and use its SHA-256 in the replacement request. These examples use jq to prepare the JSON.
alti ide workspace read --project "$PROJECT" notes/review.txt \
> "$WORK/current.json"
jq '[{kind:"replace",path:"notes/review.txt",
expected_sha256:.sha256,content:"Second review\n"}]' \
"$WORK/current.json" > "$WORK/replace.json"
alti ide workspace file-plan --project "$PROJECT" \
--request "$WORK/replace.json" > "$WORK/replace.plan.json"
cat "$WORK/replace.plan.json"Review the replacement, then apply it:
alti ide workspace file-apply --project "$PROJECT" \
--request "$WORK/replace.plan.json" > "$WORK/replace.receipt.json"
jq '{schema, outcome}' "$WORK/replace.receipt.json"Require exit status 0 and outcome equal to committed.
Delete a file
Read the file again to get its current digest, then prepare a deletion:
alti ide workspace read --project "$PROJECT" notes/review.txt \
> "$WORK/current.json"
jq '[{kind:"delete",path:"notes/review.txt",expected_sha256:.sha256}]' \
"$WORK/current.json" > "$WORK/delete.json"
alti ide workspace file-plan --project "$PROJECT" \
--request "$WORK/delete.json" > "$WORK/delete.plan.json"
cat "$WORK/delete.plan.json"Review the deletion, then apply it:
alti ide workspace file-apply --project "$PROJECT" \
--request "$WORK/delete.plan.json" > "$WORK/delete.receipt.json"
jq '{schema, outcome}' "$WORK/delete.receipt.json"Require exit status 0 and outcome equal to committed.
Recover from a changed file
If the command reports workspace file precondition changed: notes/review.txt, read the file again. Review its current content, prepare the intended replacement or deletion with the new sha256, and generate and review a new plan before applying it.
If it reports authoring plan changed or is stale; generate and review a new plan, regenerate the plan for the same project and review it before applying it.
Save native plans with the commands shown above. A plan saved with global --json is inside the execution receipt's stdout string. Pass the complete native plan to file-apply.