nightshift
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 11 Nov 2026.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/orwa-mahmoud/nightshift with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/orwa-mahmoud/nightshift'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/orwa-mahmoud--nightshift)HTML
<a href="/listings/orwa-mahmoud--nightshift"><img src="/api/listings/orwa-mahmoud--nightshift/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
Codex and ChatGPT
[Install Nightshift from the official OpenAI Plugin Directory](https://chatgpt.com/plugins/plugins_6a7c58f65d708191b3a705a8625baffe).
For local Codex development, install the same package from its marketplace:
codex plugin marketplace add orwa-mahmoud/nightshift codex plugin add nightshift@nightshift
Open the project you want Nightshift to change in Codex, or connect Codex to its GitHub repository. A Git repository or a persistent local folder works. A disposable ChatGPT scratch conversation cannot preserve project changes, so Setup redirects you to Codex before writing run state.
Claude Code
Run inside Claude Code:
/plugin marketplace add orwa-mahmoud/nightshift /plugin install nightshift
Cursor
Open **Customize → Add → From GitHub Repository**, paste `https://github.com/orwa-mahmoud/nightshift`, choose a scope, and select **Import**. Then select Nightshift from the imported marketplace to install it. The [Cursor Directory listing](https://cursor.directory/plugins/nightshift) is for discovery; installation happens inside Cursor. Read the host-specific [recovery and CLI limitations](docs/how-it-works.md#recovery) before starting a shift.
Platforms
macOS and Linux use the bundled Bash runtime. Native Windows uses bundled PowerShell, with no Git Bash or WSL required. For WSL, keep the host, plugin, repository, and watchman in one Linux distribution. See [Native Windows](docs/windows.md#native-windows) and [Remote environments](docs/remote-environments.md#remote-ssh-and-devcontainers) for platform details.
<a id="run-a-first-shift"></a>
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
.claude-plugin/marketplace.json · Manifest · 50 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- {
- "name": "nightshift",
- "owner": {
- "name": "Orwa Mahmoud",
- "url": "https://github.com/orwa-mahmoud"
- },
- "metadata": {
- "description": "Home of nightshift: accountable Claude Code and Codex coding shifts with persistent state, enforced boundaries, recovery, and evidence-backed product evolution."
- },
- "plugins": [
- {
- "name": "nightshift",
- "source": "./plugins/nightshift",
- "strict": true,
- "displayName": "nightshift",
- "description": "Keep long Claude Code runs on task: enforce the punch list, park questions, recover crashes, run product or quality shifts until done, and leave a receipt for every item with its tokens and time.",
- "category": "workflow",
- "tags": [
- "autonomous",
- "overnight",
- "unattended",
- "punch-list",
- "guardrails",
- "hooks",
- "crash-recovery",
- "agent-harness",
- "product-evolution"
- ],
- "keywords": [
- "claude-code",
- "plugin",
- "agent-harness",
- "autonomous-agents",
- "ai-agents",
- "hooks",
- "crash-recovery",
- "session-resume",
- "api-error-500",
- "product-evolution"
- ],
- "author": {
- "name": "Orwa Mahmoud",
- "url": "https://github.com/orwa-mahmoud"
- },
- "homepage": "https://nightshift.orwamahmoud.com/",
- "repository": "https://github.com/orwa-mahmoud/nightshift",
- "license": "MIT"
- }
- ]
- }
README.md · README · 141 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- <div align="center">
- # <img src="plugins/nightshift/assets/nightshift-logo.png" alt="" width="56" align="absmiddle"> nightshift
- Nightshift is a plugin for **Claude Code, Codex, and Cursor**.
- [](https://chatgpt.com/plugins/plugins_6a7c58f65d708191b3a705a8625baffe)
- [](https://hol.org/registry/plugins/orwa-mahmoud%2Fnightshift)
- <a href="https://trendshift.io/repositories/95784"><img src="https://trendshift.io/api/badge/trendshift/repositories/95784/daily?language=Shell" alt="Trendshift #10 Repository of the Day in Shell" width="250" height="55"></a>
- </div>
- <table>
- <tr>
- <td width="33%" valign="top">
- <p align="center"><strong><a href="#plan">Plan</a></strong></p>
- <p>Take your plan further. Before the first write, bring the <strong>hard questions</strong> into the <strong>plan room</strong>. <strong>Compare approaches</strong>, <strong>set the boundaries</strong>, and <strong>choose the evidence</strong> for each task. Record decisions and a <strong>clear definition of done</strong> so your agent carries the agreed plan into execution.</p>
- </td>
- <td width="33%" valign="top">
- <p align="center"><strong><a href="#execute">Execute</a></strong></p>
- <p>Step away while Nightshift keeps your agent on the job. You choose when to start. It <strong>keeps your agent working</strong> through the <strong>punch list</strong> until <strong>every item is checked off</strong>. Decisions don’t block progress. The agent picks a default answer and records it in the <strong>parking lot</strong> for you to review.</p>
- </td>
- <td width="33%" valign="top">
- <p align="center"><strong><a href="#review">Review</a></strong></p>
- <p>Get reviewable results, not a marathon chat. <strong>Each item gets its own receipt.</strong> See what the agent <strong>delivered</strong>, what it <strong>tried and rejected</strong>, and which <strong>checks ran</strong>, alongside <strong>evidence</strong>, <strong>duration</strong>, and <strong>token usage</strong>. Decisions come back with <strong>the default chosen and why</strong>.</p>
- </td>
- </tr>
- </table>
- [](docs/assets/finished-shift-receipts.png)
- ## Shipped with Nightshift
- **Nightshift built Nightshift.** Its initial shift produced the plugin’s clock-out gate, hooks, and commands. The build record pairs the original punch list with the commits. A later Codex shift completed **11 maintenance items** on one branch, with **one commit per item**, and shipped in **v0.9.2**. [Original build and commits](examples/self-build.md) · [Maintenance receipts](examples/codex-hardening-shift.md) · [Merged PR #53](https://github.com/orwa-mahmoud/nightshift/pull/53)
- **Two agents worked the same plan.** When the Claude Code session ran out of allowance, the maintainer stopped it. **Ten minutes later**, Cursor resumed on the same branch with the same punch list. The shift spanned **45 elapsed hours**. After review and further fixes, the maintainer merged **67 commits** and closed **57 issues**. [Handoff timeline](examples/adapttable-continuity.md) · [Merged PR #353](https://github.com/orwa-mahmoud/adapttable/pull/353)
- For a smaller run, follow the **nine-item shift** that shipped inline editing and row grouping in **AdaptTable v1.2.0**. [Overnight punch list](examples/adapttable-overnight.md) · [Merged PR #75](https://github.com/orwa-mahmoud/adapttable/pull/75)
- ## Install
- It installs as a **native plugin**, with no separate app, service, or API key. It runs on **macOS, Linux, and Windows**, in any project on your disk: a **Git repository**, or a plain folder for work that isn't code, such as a research report.
- ### Claude Code
- ```text
- /plugin marketplace add orwa-mahmoud/nightshift
- /plugin install nightshift@nightshift
- ```
- ### Codex
- ```sh
- codex plugin marketplace add orwa-mahmoud/nightshift
- codex plugin add nightshift@nightshift
- ```
- Then review and trust its hooks, with `/hooks` in the CLI or, in the Codex app, the **Review hooks** button (the hook icon in the message box) or **Settings → Hooks**.
- ### Cursor
- Open **Customize → Add → From GitHub Repository**, paste `https://github.com/orwa-mahmoud/nightshift`, select **Import**, and install Nightshift from the imported marketplace.
- [Installation and host support](docs/install.md#install)
- ## Your first shift
- Open the project you want to work on and run `/nightshift:setup`. Answer a few questions to set your preferences. [What Setup asks](docs/setup.md)
- ### Plan
- Enter the **plan room** with `/nightshift:plan`, continue one of your **plans** or start a new one with a name, and describe what you want **in your own words**: a feature, a refactor, a bug, a whole backlog, or GitHub issues you stage with `/nightshift:import-issues`. Your project code stays **read-only** while the room is open, so the agent can't jump into implementing while you're still brainstorming. It reads the relevant code, tests, and history, explains what **each approach buys you**, and turns what you agree on into **punch list** items.
- When you enter the room, the agent asks you once, up front:
- - **Which plan:** continue one of your plans, or start a new one and name it.
- - **How to brainstorm:** whether you want an **edge-case pass** for the cases each item can meet, a **pre-mortem** on how the plan could fail, an **ordering and risk check**, or **research** on the open questions.
- - **Whether to suggest evidence:** proof that fits each item, picked from the **evidence catalog**, such as **screenshots at named widths** for a layout change, **before-and-after figures** for a speed-up, or **a sample request and the schema diff** for an API change. If you want it, you also choose whether a missing file is **hard-checked**, holding the item open until it exists, **only reported** on the receipt, or not checked at all.
- Pick any or none. What you pick is applied as each item takes shape; with none, these never come up again unless you ask. Every suggestion is yours to keep, edit, or drop. As the list nears completion, Nightshift estimates **working time** and **token usage** from your past receipts. For an item likely to get stuck, the agent offers a **budget** in working time, tokens, or both, and says why. At the **soft limit** the agent is told to finish the item. At the **hard limit** it can only commit the **work in progress**, write the **receipt**, and move on to the next item. [Item budgets](docs/item-budgets.md)
- Each plan is its own file, a complete punch list with its own contract and checks, so plans never mix. Each item is written to it as soon as you agree with it, and edited in place as the discussion moves. The **plan record** keeps **decisions, rejected options, and open questions**, so a new day or a closed tab picks up exactly where you stopped. [Inside the plan room](docs/plan-room.md)
- ### Execute
- When you’re ready, run `/nightshift:start`. If the punch list has open items, the agent works those. If it is empty, Start offers your **plans** by name, and any staged items, and runs the one you pick. Prepare several plans, then run them one after another.
- A shift runs one of **two ways**:
- - **Work a list.** The agent takes the agreed items one by one and the shift ends at the last tick. A deadline is optional and only caps it.
- - **Work toward a goal until quitting time.** Run `/nightshift:hunt`, give it a goal and the hours, and the agent keeps working in complete units until the deadline. At quitting time it finishes the unit in hand and starts no new one.
- You don't need a **backlog** to start. Nightshift ships **32 ready-made shifts**: **four open-ended** ones, coverage hunt, defect hunt, product evolution, and your own objective, plus **28 finite** ones such as dependency upgrades, vulnerability sweeps, flaky-test repair, accessibility repair, documentation drift, and release readiness. Pick entries yourself or let **Hunt** choose them for your goal, and review the composed shift first or run it directly. `/nightshift:quality` surveys tests, accessibility, dependencies, and other **quality debt**, and you choose what to **fix now** or **draft for later**. [Ready-made shifts](docs/shift-modes.md#ready-made-shifts) · [Shift modes](docs/shift-modes.md)
- While the shift runs, `/nightshift:status` shows the open item, the deadline, parked decisions, snags, and whether the watchman is on duty. Decisions go in the **parking lot** with the default the agent used and its reason. Use `/nightshift:stop` to pause and keep unfinished items open. `/nightshift:doctor` diagnoses the workspace and changes nothing. [Preparing for an unattended shift](docs/first-night-checklist.md)
- ### Review
- Open the **morning receipt** to see how the shift ended, which changes to inspect first, which **decisions** need your attention, and what the whole shift cost: **working time**, **paused time**, and **tokens**. Follow an item to see what the agent **delivered**, what it **tried and rejected**, which **checks ran**, any checks it couldn’t run, and the **time and tokens that item took**, session by session. Both come from the host’s own records, never the agent’s estimate. [Example receipts](examples/receipts.md) · [Reading the morning receipt](docs/morning-receipt.md) · [How usage is measured](docs/receipts.md#token-usage-is-measured-by-the-runtime)
- You choose the **evidence** and judge the result. For a layout change, open the screenshot and check the interaction yourself. For a performance change, compare the before-and-after measurements. If you require a named file, the **gate** checks that it exists. [Evidence options](docs/evidence.md)
- Run `/nightshift:archive` to file the shift into its own folder, with its **receipts** and **evidence**. Open items and unanswered decisions stay in the live files for the next shift. [Archive and continue](docs/archive.md)
- ## What else Nightshift handles
- | What you want to do | How Nightshift handles it |
- | --- | --- |
- | [Finish an agreed list](docs/how-it-works.md#the-work-contract) | The **punch list** lives on disk, so it survives **compaction** and new sessions. If the agent tries to stop with work still open, the **clock-out gate** sends it back to the list. |
- | [Switch agents mid-shift](examples/adapttable-continuity.md) | The whole shift lives on disk, so moving between **Claude Code, Codex, and Cursor**, in any order, is just `/nightshift:stop` in one and `/nightshift:start` in the other. The new agent reads the **punch list**, **receipts**, **parked decisions**, **snag log**, and **shift log** and carries on, with nothing to re-explain. |
- | [Keep the agent inside your rules](docs/how-it-works.md#mechanical-gates-and-owner-rules) | Deny **commands**, **protected paths**, **secret patterns**, or commits under the wrong **identity**. Hooks enforce them in **every permission mode**, fully unattended included. |
- | [Keep your checkout untouched](docs/knobs.md#shift-worktrees) | With `shift.isolation` set to `worktree`, each shift gets its own **worktree and branch**. Your checkout, index, and uncommitted edits stay as you left them. |
- | [Recover an interrupted shift](docs/how-it-works.md#recovery) | A **watchman outside the session** monitors the shift and **resumes interrupted work**. If Claude’s API starts returning **500 errors overnight**, the watchman retries recovery and resumes the shift when the service responds again. **You can stay asleep.** It also handles crashes, stalls, and usage limits using your host’s recovery signals, carrying on from the **punch list and saved progress**. |
- | [Start at a fixed time](docs/commands.md#start-at-a-fixed-time) | `/nightshift:schedule` checks that work is queued and that permissions won't stall a **headless run**, then prints the **launchd, cron, systemd, or Task Scheduler** entry. It registers nothing itself. |
- ## Make it yours
- Write your own **receipt templates**, **morning summaries**, and **evidence instructions**, with the headings, wording, and layout you want. Add, replace, or remove **checks**. Create **shifts**, **evidence entries**, and **edge-case packs** for the way you work. The shipped templates are starting points you can change.
- Open `/nightshift:customize` to see **every setting, template, and catalog entry** on one screen, or edit the files directly. Keep a workflow with one project or put it in your **personal catalog** to use across repositories. An entry with the same name as a shipped one replaces it. [Settings and catalogs](docs/knobs.md#catalogs) · [Create your own catalog entry](docs/add-to-a-catalog.md#only-for-you)
- ## Contributing
- - **Share a workflow that works for you.** Turn a recurring task into a shift others can use, whether it works on a Git repository or a folder of research, documents, or other deliverables. Share the idea or contribute the Markdown entry. [Shift ideas and contributions · #21](https://github.com/orwa-mahmoud/nightshift/issues/21)
- - **Share how you judge the work.** A screenshot, benchmark, recording, or another artifact can help someone review a change. Contribute your way of capturing it as an evidence entry. [Evidence ideas and contributions · #219](https://github.com/orwa-mahmoud/nightshift/issues/219)
- - **Share your checks and edge cases.** Bring the commands that catch problems in your stack, or the cases you always test before shipping. Add a gate stack or an edge-case pack. [Checks and edge cases · #220](https://github.com/orwa-mahmoud/nightshift/issues/220)
- - **Share what your shift delivered.** Link the requested work, the result, and what you found in review. Successful runs, interrupted shifts, and things you had to fix all help. [Run receipts · #22](https://github.com/orwa-mahmoud/nightshift/issues/22)
- - **Build an improvement to Nightshift.** Have an idea that makes Nightshift more useful? Build it and open a pull request, or propose the enhancement for discussion. [Contribute a change](CONTRIBUTING.md) · [Propose an enhancement](https://github.com/orwa-mahmoud/nightshift/issues/new?template=feature_request.yml)
- [Contribution guide](CONTRIBUTING.md) · [Where to contribute code](docs/contribution-map.md)
- If Nightshift is useful to you, [star the repository](https://github.com/orwa-mahmoud/nightshift) to help other developers discover it.
- ## Documentation
- [Documentation index](docs/README.md#documentation) · [Website](https://nightshift.orwamahmoud.com/) · [Command reference](docs/commands.md) · [Troubleshooting](docs/troubleshooting.md) · [Remote SSH and devcontainers](docs/remote-environments.md)
- ## License
- [MIT](LICENSE) © [Orwa Mahmoud](https://orwamahmoud.com)
plugins/nightshift/hooks/codex/hooks.json · Bundled script · 61 lines · 5 findings marked
- {
- "description": "nightshift guards for Codex: the PreToolUse hardhat, the Stop clock-out gate, SessionEnd, the PostToolUse pulse, and the UserPromptSubmit plan-room exit.",
- "hooks": {
- "PreToolUse": [
- {
- "matcher": "*",
- "hooks": [
- {
- "type": "command",
- "command": "\"${PLUGIN_ROOT}/hooks/codex/hardhat.sh\"",
- "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAGgAYQByAGQAaABhAHQALgBwAHMAMQAnACkAIAAtAEgAbwBzAHQATgBhAG0AZQAgAGMAbwBkAGUAeAA7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUA"
- Dismissed after review: Runs code it decodes (base64, hex, character codes, reversed text or a compressed blob), which hides what runs from a reader
- Line 11 on GitHub
- }
- ]
- }
- ],
- "PostToolUse": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "\"${PLUGIN_ROOT}/hooks/codex/pulse.sh\"",
- "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHAAdQBsAHMAZQAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
- Dismissed after review: Runs code it decodes (base64, hex, character codes, reversed text or a compressed blob), which hides what runs from a reader
- Line 22 on GitHub
- }
- ]
- }
- ],
- "SessionEnd": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "\"${PLUGIN_ROOT}/hooks/codex/session-end.sh\"",
- "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHMAZQBzAHMAaQBvAG4ALQBlAG4AZAAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
- Dismissed after review: Runs code it decodes (base64, hex, character codes, reversed text or a compressed blob), which hides what runs from a reader
- Line 33 on GitHub
- }
- ]
- }
- ],
- "UserPromptSubmit": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "\"${PLUGIN_ROOT}/hooks/codex/prompt-submit.sh\"",
- "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHAAcgBvAG0AcAB0AC0AcwB1AGIAbQBpAHQALgBwAHMAMQAnACkAIAAtAEgAbwBzAHQATgBhAG0AZQAgAGMAbwBkAGUAeAA7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUA"
- Dismissed after review: Runs code it decodes (base64, hex, character codes, reversed text or a compressed blob), which hides what runs from a reader
- Line 44 on GitHub
- }
- ]
- }
- ],
- "Stop": [
- {
- "hooks": [
- {
- "type": "command",
- "command": "\"${PLUGIN_ROOT}/hooks/codex/clock-out-gate.sh\"",
- "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAGMAbABvAGMAawAtAG8AdQB0AC0AZwBhAHQAZQAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
- Dismissed after review: Runs code it decodes (base64, hex, character codes, reversed text or a compressed blob), which hides what runs from a reader
- Line 55 on GitHub
- }
- ]
- }
- ]
- }
- }
plugins/nightshift/runtime/windows/schedule.ps1 · Bundled script · 423 lines · 1 finding marked
- param(
- [string]$Project = [Environment]::CurrentDirectory,
- [string]$At = '',
- [string]$Agent = 'claude -p',
- [string]$Prompt = '/nightshift:start',
- [switch]$List,
- [switch]$Remove,
- [switch]$Preflight,
- [switch]$AsJson
- )
- Set-StrictMode -Version 2.0
- $ErrorActionPreference = 'Stop'
- $pluginRoot = Resolve-Path (Join-Path $PSScriptRoot '../..')
- Import-Module (Join-Path $pluginRoot 'lib/Nightshift.psm1') -Force -DisableNameChecking
- # 0 ok - 1 unusable receipts path - 2 malformed work-mode - 3 unset artifact proposal
- function Test-NSScheduleArtifactReceipts {
- param([Parameter(Mandatory = $true)][string]$Workspace)
- try {
- $mode = Get-NSWorkMode $Workspace
- }
- catch {
- return 2
- }
- $modeRecord = Get-NSLayoutPath (Join-Path $Workspace '.nightshift') 'work-mode'
- if (-not (Test-Path -LiteralPath $modeRecord -PathType Leaf)) {
- try {
- if ((Get-NSProposedWorkMode $Workspace) -eq 'artifact') {
- return 3
- }
- }
- catch {
- }
- }
- if ($mode -eq 'artifact') {
- $recv = Get-NSReceiptsDir $Workspace
- if ((Test-NSPathEntry $recv) -and -not (Test-NSUsableReceiptsDir $Workspace)) {
- return 1
- }
- }
- return 0
- }
- function Escape-NSSingleQuoted {
- param([Parameter(Mandatory = $true)][string]$Value)
- return $Value.Replace("'", "''")
- }
- function Escape-NSXml {
- param([AllowEmptyString()][string]$Value)
- return [Security.SecurityElement]::Escape($Value)
- }
- function Get-NSProjectHash {
- param([Parameter(Mandatory = $true)][string]$Value)
- $sha = [Security.Cryptography.SHA256]::Create()
- try {
- $bytes = [Text.Encoding]::UTF8.GetBytes($Value.ToUpperInvariant())
- $hash = $sha.ComputeHash($bytes)
- }
- finally {
- $sha.Dispose()
- }
- return (($hash[0..5] | ForEach-Object { $_.ToString('x2') }) -join '')
- }
- function Get-NSTask {
- param([Parameter(Mandatory = $true)][string]$Name)
- try {
- return Get-ScheduledTask -TaskName $Name -ErrorAction Stop
- }
- catch {
- return $null
- }
- }
- $hostPath = Resolve-NSCanonicalPath $Project
- $workspace = Resolve-NSWorkspaceRoot $hostPath
- $ns = Join-Path $workspace '.nightshift'
- if (-not (Test-Path -LiteralPath $ns -PathType Container)) {
- throw "schedule: no .nightshift at $workspace - run Setup first (/nightshift:setup on Claude Code; ask Nightshift to set up on Codex)"
- }
- $stateKind = Get-NSStateKind $workspace
- if ($stateKind -in @('malformed', 'future')) {
- throw ('schedule: ' + (Get-NSStateRefuseMessage $stateKind))
- }
- $baseName = (Split-Path -Leaf $workspace) -replace '[^A-Za-z0-9]+', '-'
- $baseName = $baseName.Trim('-')
- if ([string]::IsNullOrEmpty($baseName)) {
- $baseName = 'project'
- }
- $id = "$baseName-$(Get-NSProjectHash $workspace)"
- $taskName = "Nightshift-$id"
- $taskPath = '\'
- $log = Get-NSLayoutPath $ns 'scheduled-log'
- if ($List) {
- $task = Get-NSTask $taskName
- if ($null -eq $task) {
- "Nothing registered for $workspace"
- }
- else {
- "Registered for ${workspace}:"
- " task: $taskPath$taskName"
- " state: $($task.State)"
- }
- exit 0
- }
- if ($Remove) {
- if ($null -eq (Get-NSTask $taskName)) {
- "Nothing registered for $workspace"
- exit 0
- }
- "To unregister:"
- ''
- " Unregister-ScheduledTask -TaskPath '$taskPath' -TaskName '$taskName' -Confirm:`$false"
- exit 0
- }
- $timeText = if ($Preflight -and [string]::IsNullOrEmpty($At)) { '04:05' } else { $At }
- if ($timeText -notmatch '^(?<hour>[01][0-9]|2[0-3]):(?<minute>[0-5][0-9])$') {
- throw "schedule: -At needs a 24-hour HH:mm value, got '$timeText'"
- }
- $hour = [int]$Matches.hour
- $minute = [int]$Matches.minute
- $start = (Get-Date).Date.AddHours($hour).AddMinutes($minute)
- if ($start -le (Get-Date)) {
- $start = $start.AddDays(1)
- }
- $quotedWorkspace = Escape-NSSingleQuoted $workspace
- $quotedPrompt = Escape-NSSingleQuoted $Prompt
- $quotedLog = Escape-NSSingleQuoted $log
- $runScript = "& { Set-Location -LiteralPath '$quotedWorkspace'; $Agent '$quotedPrompt' *>> '$quotedLog' }"
- $encodedCommand = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($runScript))
- # The task runs as the account that registers it. Off Windows the identity API does not exist, and
- # the environment's domain and user name stand in so the preflight and the printed task still render.
- if (Test-NSWindows) {
- $identity = [Security.Principal.WindowsIdentity]::GetCurrent().Name
- }
- else {
- $identity = [Environment]::UserDomainName + '\' + [Environment]::UserName
- }
- $xml = @"
- <?xml version="1.0" encoding="UTF-16"?>
- <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
- <RegistrationInfo>
- <Description>Start the Nightshift punch list for $(Escape-NSXml $workspace)</Description>
- <URI>$(Escape-NSXml "$taskPath$taskName")</URI>
- </RegistrationInfo>
- <Triggers>
- <CalendarTrigger>
- <StartBoundary>$($start.ToString('yyyy-MM-ddTHH:mm:ss'))</StartBoundary>
- <Enabled>true</Enabled>
- <ScheduleByDay><DaysInterval>1</DaysInterval></ScheduleByDay>
- </CalendarTrigger>
- </Triggers>
- <Principals>
- <Principal id="Author">
- <UserId>$(Escape-NSXml $identity)</UserId>
- <LogonType>InteractiveToken</LogonType>
- <RunLevel>LeastPrivilege</RunLevel>
- </Principal>
- </Principals>
- <Settings>
- <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
- <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>
- <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>
- <AllowHardTerminate>true</AllowHardTerminate>
- <StartWhenAvailable>true</StartWhenAvailable>
- <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
- <IdleSettings>
- <StopOnIdleEnd>false</StopOnIdleEnd>
- <RestartOnIdle>false</RestartOnIdle>
- </IdleSettings>
- <AllowStartOnDemand>true</AllowStartOnDemand>
- <Enabled>true</Enabled>
- <Hidden>false</Hidden>
- Note: Usual in code (tag names in paths and patterns): Contains a <hidden> block, a common wrapper for instructions hidden in a tool description
- Line 183 on GitHub
- <RunOnlyIfIdle>false</RunOnlyIfIdle>
- <WakeToRun>false</WakeToRun>
- <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
- </Settings>
- <Actions Context="Author">
- <Exec>
- <Command>powershell.exe</Command>
- <Arguments>-NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand $encodedCommand</Arguments>
- <WorkingDirectory>$(Escape-NSXml $workspace)</WorkingDirectory>
- </Exec>
- </Actions>
- </Task>
- "@
- try {
- $null = [xml]$xml
- }
- catch {
- throw 'schedule: generated Task Scheduler XML is invalid'
- }
- $xmlBase64 = [Convert]::ToBase64String([Text.Encoding]::Unicode.GetBytes($xml))
- $registerCommand = "`$xml = [Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('$xmlBase64')); Register-ScheduledTask -TaskPath '$taskPath' -TaskName '$taskName' -Xml `$xml"
- if ($Preflight) {
- $failures = New-Object Collections.Generic.List[string]
- "Nightshift schedule preflight"
- "Host: $hostPath"
- "Workspace: $workspace"
- try {
- $target = Resolve-NSWorkTarget $workspace
- "Work: $target"
- }
- catch {
- 'Work: unresolved (workspace itself will be the working directory)'
- $failures.Add('work target could not be resolved')
- 'FAIL work target could not be resolved - a scheduled start will refuse to arm'
- }
- $recvRc = Test-NSScheduleArtifactReceipts $workspace
- if ($recvRc -eq 1) {
- $failures.Add('artifact receipts path is not a usable directory')
- 'FAIL artifact receipts path is not a usable directory - a scheduled start will refuse to arm'
- }
- elseif ($recvRc -eq 2) {
- $failures.Add('work-mode is malformed')
- 'FAIL work-mode is malformed'
- }
- elseif ($recvRc -eq 3) {
- $failures.Add('work mode is unset; Setup would propose artifact')
- 'FAIL work mode is unset; Setup would propose artifact - a scheduled start will refuse to arm'
- }
- $rules = Get-NSRulesObject $workspace
- if ($null -eq $rules) {
- $failures.Add('rules.json is unreadable or is not a JSON object')
- 'FAIL rules.json is unreadable or is not a JSON object'
- }
- else {
- $watch = Get-NSRule $workspace 'watchMinutes'
- if ($watch -notmatch '^[0-9]+$') {
- $failures.Add('watchMinutes is missing or invalid')
- 'FAIL watchMinutes is missing or invalid'
- }
- else {
- "OK rules.json (watchMinutes $watch)"
- if ([int]$watch -gt 0) {
- $retrySpacing = Get-NSRule $workspace 'watchRetrySeconds' ([string]$env:NIGHTSHIFT_WATCH_RETRY)
- $revivalPrompt = Expand-NSInjectedPaths $workspace (Get-NSRule $workspace 'revivalPrompt' ([string]$env:NIGHTSHIFT_REVIVAL_PROMPT))
- $freshPrompt = Expand-NSInjectedPaths $workspace (Get-NSRule $workspace 'freshRevivalPrompt' ([string]$env:NIGHTSHIFT_FRESH_PROMPT))
- if ([string]::IsNullOrEmpty($retrySpacing)) {
- $failures.Add('watchRetrySeconds is empty')
- 'FAIL watchRetrySeconds is empty - watchman will refuse to arm'
- }
- if ([string]::IsNullOrEmpty($revivalPrompt)) {
- $failures.Add('revivalPrompt is empty')
- 'FAIL revivalPrompt is empty - watchman will refuse to arm'
- }
- if ([string]::IsNullOrEmpty($freshPrompt)) {
- $failures.Add('freshRevivalPrompt is empty')
- 'FAIL freshRevivalPrompt is empty - watchman will refuse to arm'
- }
- }
- }
- }
- $counts = Get-NSBoxCounts (Get-NSLayoutPath $ns 'punch-list')
- if ($counts.Open -eq 0) {
- $failures.Add('punch list has no open items')
- 'FAIL punch list has no open items - a scheduled start promotes nothing'
- $orders = Get-NSOpenBoxesInFile (Get-NSLayoutPath $ns 'work-orders')
- if ($orders -gt 0) {
- "NOTE $orders parked Hunt work order(s) - start will not promote them"
- }
- $drafts = Get-NSOpenDrafts (Get-NSLayoutPath $ns 'drafting-table')
- if ($drafts -gt 0) {
- "NOTE $drafts drafting-table item(s) - start will not promote them"
- }
- }
- else {
- "OK punch list has $($counts.Open) open item(s)"
- }
- 'OK Task Scheduler XML parses'
- "OK task path $taskPath$taskName"
- "OK run log $log"
- $agentExecutable = ($Agent.Trim() -split '\s+')[0].Trim("'`"")
- if ($null -eq (Get-Command $agentExecutable -ErrorAction SilentlyContinue)) {
- "WARN selected agent $agentExecutable is not on PATH - the scheduled run cannot start on this machine"
- }
- else {
- "OK selected agent executable $agentExecutable"
- }
- ''
- 'Claude Code'
- $claudeCommand = Get-Command claude -ErrorAction SilentlyContinue
- if ($null -eq $claudeCommand) {
- 'WARN claude is not on PATH - a Claude scheduled run cannot start'
- }
- else {
- "OK binary $($claudeCommand.Source)"
- }
- $permissionGranted = $false
- $permissionFiles = @(
- (Join-Path $workspace '.claude/settings.local.json'),
- (Join-Path $workspace '.claude/settings.json'),
- (Join-Path $hostPath '.claude/settings.local.json'),
- (Join-Path $hostPath '.claude/settings.json')
- ) | Select-Object -Unique
- foreach ($permissionFile in $permissionFiles) {
- if (Test-Path -LiteralPath $permissionFile -PathType Leaf) {
- $settingsText = [IO.File]::ReadAllText($permissionFile)
- if ($settingsText -match 'bypassPermissions|allow') {
- $permissionGranted = $true
- break
- }
- }
- }
- if ($permissionGranted) {
- 'OK headless permissions look granted'
- }
- else {
- 'WARN no bypassPermissions/allow in .claude\settings*.json - a headless Claude run may stall'
- }
- ''
- 'Codex'
- $codexCommand = Get-Command codex -ErrorAction SilentlyContinue
- if ($null -eq $codexCommand) {
- 'WARN codex is not on PATH - a Codex scheduled run cannot start'
- }
- else {
- "OK binary $($codexCommand.Source)"
- }
- 'OK recommended agent: codex exec -s danger-full-access'
- if ($Agent -match '(?i)codex') {
- if ($Agent -match '(?i)danger-full-access|bypass') {
- 'OK -Agent carries a headless sandbox grant'
- }
- else {
- 'WARN -Agent names Codex without a headless grant; the run may stall on the first tool'
- }
- }
- if ($null -ne (Get-NSTask $taskName)) {
- 'WARN an entry is already registered for this project - generation will refuse a second one'
- }
- ''
- 'Task uses the current interactive user token, starts a missed run when that user is next logged in, and never wakes a sleeping or powered-off machine.'
- 'Preflight writes and registers nothing.'
- if ($failures.Count -gt 0) {
- exit 1
- }
- exit 0
- }
- if ($null -ne (Get-NSTask $taskName)) {
- 'Already registered for this project - nothing to install.'
- ''
- " task: $taskPath$taskName"
- ''
- 'Two entries would put two agents on one punch list. Remove the existing task first to replace it.'
- exit 3
- }
- $recvRc = Test-NSScheduleArtifactReceipts $workspace
- if ($recvRc -eq 1) {
- throw 'schedule: artifact receipts path is not a usable directory - a scheduled start will refuse to arm'
- }
- if ($recvRc -eq 2) {
- throw 'schedule: work-mode is malformed'
- }
- if ($recvRc -eq 3) {
- throw 'schedule: work mode is unset; Setup would propose artifact - a scheduled start will refuse to arm'
- }
- try {
- $null = Resolve-NSWorkTarget $workspace
- }
- catch {
- throw 'schedule: work target could not be resolved - a scheduled start will refuse to arm'
- }
- if ($AsJson) {
- [pscustomobject]@{
- project = $workspace
- taskPath = $taskPath
- taskName = $taskName
- start = $start.ToString('o')
- runScript = $runScript
- xml = $xml
- registerCommand = $registerCommand
- log = $log
- } | ConvertTo-Json -Depth 5
- exit 0
- }
- $counts = Get-NSBoxCounts (Get-NSLayoutPath $ns 'punch-list')
- if ($counts.Open -eq 0) {
- 'Note: the punch list has no open items. A scheduled start works the list it finds and'
- "promotes nothing, so queue the work before $timeText or the run will find nothing to do."
- $orders = Get-NSOpenBoxesInFile (Get-NSLayoutPath $ns 'work-orders')
- if ($orders -gt 0) {
- "Parked Hunt work orders: $orders (start will not promote them)."
- }
- $drafts = Get-NSOpenDrafts (Get-NSLayoutPath $ns 'drafting-table')
- if ($drafts -gt 0) {
- "Drafting-table items: $drafts (start will not promote them)."
- }
- ''
- }
- "Scheduled start for $workspace at $timeText"
- ''
- "Task: $taskPath$taskName"
- ''
- 'Run this PowerShell command to register it:'
- ''
- " $registerCommand"
- ''
- 'Generated Task Scheduler XML:'
- ''
- $xml
- ''
- 'The task runs only in the current user session. StartWhenAvailable catches a missed time after login, but Nightshift does not wake or power on the machine.'
- "Check it: & '$PSCommandPath' -Project '$quotedWorkspace' -List"
- "Output of each run lands in $log"
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.