A.N. Creation skill: office-save. Working state lives only on this computer. Drive holds published human documents. The steps below are the office rule the office-save skill carries out. Scripts live in an-office-files/files/: an-office-files/files/publish.py, an-office-files/files/render.py, an-office-files/files/record-export.py, an-office-files/files/move-project.py, an-office-files/files/rename-company.py, an-office-files/files/restore-project.py, an-office-files/files/new-id.py, an-office-files/files/office-check.py. Do not look in a build folder. ON THIS COMPUTER 1. Write the working file in place. Before a major change, copy it into History/ as " YYMMDD-HHMM": a new copy, then update the original in place. Write that copy, or cp without -p, then chmod u+w. Never cp -p. The History stamp comes from `TZ= date +%y%m%d-%H%M` in the owner's Timezone (the Timezone line). Never `date -u` and never a UTC stamp in a name or in plan.md. Never move, rename or replace the original. 2. Check the write with `test -f` and the file's mtime. Then read the file back and compare sha256. If the file is missing or the hash does not match, say so in one plain line and do not call it saved. 3. Every save rewrites the office.txt line "Working on:" in the same save. 4. Only after the write, the `test -f` / mtime check, and a successful read-back, set office.txt "Last saved" from `date` in the owner's Timezone: YYYY-MM-DD HH:MM, , read back OK. Never a future time. Never say "I've saved it" before that check. A read-back to the owner is at most 3 lines. 5. Run `python3 an-office-files/files/office-check.py `. Report its result. Say "I've saved it" only after the write and this check both pass. On FAIL, fix the listed items and run it again, or report the failing lines. Do not say "I've saved it" on FAIL. PUBLISH Human documents only, from a locked template, via an-office-files/files/publish.py (an-office-files/files/render.py beside it). A template that says "Renders as: Google Doc" (or is plain text) uploads as text/markdown or text/plain with disableConversionToGoogleType true. A template that says "Renders as: Google Sheet", including "2 tabs: Path, Calendar", is an .xlsx with one sheet per tab. Upload that .xlsx with convertToGoogleFormat true (disableConversionToGoogleType false) so Drive makes one Google Sheet. Do not upload that document as markdown. An empty list renders as "none found, checked " and does not stop the publish. Never type CSV rows or payload fields by hand. drive-ids.csv uses one header everywhere: doc,file_id,kind,date,status. status is current, moved, or superseded when the schema's drive_ids_status enum lists it. 1. create_file the new version in the same Drive folder with the same title. 2. read_file_content it back into /tmp, then delete that scratch file. Do not leave it in the office. 3. Move the previous copy into that folder's History/ with update_file (parentId). Never trash_file. 4. The first publish appends its own row and nothing else: doc,,file,,current. kind is file. status is current. Do not put History/ on that row. A later publish appends doc,,file,,current and does not edit the old row in place. Set the old row's status to superseded only when the schema's drive_ids_status enum lists superseded, and change no other cell on that row. Otherwise leave the old row unchanged. 5. Say "published" only after the read-back succeeds, in that same turn, before the next question. Otherwise say it was not published. On a failed read-back, leave the previous copy where it is. The first publish of a doc is steps 1, 2, 4 (the new current row only), and 5. If a required field was never written, an-office-files/files/publish.py prints "not published" and the missing fields and does not upload. A value recorded as "not yet known" is a value. An empty list is not a missing field. Never trash_file. Never read_file or list_folder on Drive for working state. BACKUP office.txt Backup: weekly (the default; on unless the owner switches it to daily or off). Record it as "Routine: backup, weekly, late evening". an-office-files/files/record-export.py writes project-YYYY-MM-DD.json (or -YYYY-MM-DD.json) into /Backups/ and never overwrites. That JSON is the backup, excluding record/ and the library (library.txt, library-*.txt, sops/). Upload only that file as a new file in the Drive publish folder's Backups/. Never upload record/ or the library there. read_file_content it back. Tell the owner "Saved this week's backup copy of your project to Drive." only after that upload succeeds and read_file_content matches. If the upload fails, say plainly it was not saved to Drive (the local copy is kept). "Export the project" runs the same thing on demand. At setup, when Backup is not off, run this first backup and read_file_content it back before saying the backup is set. GITHUB (only when office.txt says "Home: GitHub") Your own clone, pull --rebase, one commit, push, then a gh read-back. Never force-push main. "Last saved" uses the commit, and only after the gh read-back matches. If the push fails, say so plainly; never report the work as saved.