Skip to content

feat(skills): add schedule, notes, and settings skills - #117

Merged
setkyar merged 2 commits into
ygncode:mainfrom
setkyar:feat/pi-web-skills-schedule
Sep 16, 2026
Merged

setkyar merged 2 commits into
ygncode:mainfrom
setkyar:feat/pi-web-skills-schedule

Conversation

@setkyar

@setkyar setkyar commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

What

Ship three pi skills so a session can talk to pi-web:

  • /skill:pi-web-schedule — create/list/pause/run schedules
  • /skill:pi-web-notes — read/append/replace the project scratchpad
  • /skill:pi-web-settings — get/set theme, language, auto-title, etc.

They go through pi-web-ctl, which calls the existing HTTP APIs (never SQLite). install.sh / install.ps1 copy the CLI to ~/.pi/agent/bin/pi-web-ctl.

Why

People already say things like “add a schedule at 2am Singapore time” or “write this in the notes.” Those surfaces existed in the UI only. Skills let the agent do the same thing from a session, in the terminal or the web UI.

How

  • CLI discovers 127.0.0.1:{port} from pi-web-state.json and sends X-Pi-Token (never ?token=, which 302s past the handler).
  • Schedule flags (--daily --hour 2 --timezone sg) compile to cron; aliases like sg resolve to IANA names.
  • Notes default to append (POST /api/scratchpad mode=append) so the UI debounce cannot clobber a GET-then-replace.
  • Settings use friendly aliases (theme, language, auto-title). Theme/fonts apply live; language reloads open tabs, same as the Settings picker.
  • RPC workers and /api/models oneshots no longer inherit pi-web’s checkout cwd. That was loading this repo’s .pi/extensions on top of the installed package and crashing on duplicate pi_web_ask_user_question. Extensions still load.

Tests

  • .pi/skills/common/test_pi_web.py — discovery, auth header, cron/tz, notes append, settings aliases
  • Go: schedule/scratchpad/settings SSE, scratchpad append
  • Frontend: slash-adjacent SSE helpers, scratchpad dirty-aware apply, settings-live locale reload

make test includes pi-web-ctl-test.

Try

pi-web-ctl schedule list
pi-web-ctl notes append --text "hello"
pi-web-ctl settings set theme dark

In a session, type /pi- and pick /skill:pi-web-schedule, /skill:pi-web-notes, or /skill:pi-web-settings.

Sessions can manage pi-web schedules, the project scratchpad, and
settings in natural language via /skill:pi-web-* and pi-web-ctl,
calling the existing HTTP APIs instead of writing SQLite.
The three new subscriptions (schedules, scratchpad, settings) were
byte-identical 57-line modules differing only in the event name, and each
opened its own EventSource to /events?id=__all__. A session tab already
holds the per-session stream, so a session page took three connections and
two tabs hit the browser's six-per-host HTTP/1.1 cap, stalling fetches and
saves.

createAppEvents takes the event name and shares one EventSource per topic
with a listener registry, closing it when the last subscriber leaves.

Also skip the textarea write in applyRemote when the content already
matches: our own debounced save echoes back over SSE, and reassigning
value moves the caret for no reason.
@setkyar

setkyar commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Review pass on this branch, plus one follow-up commit (5f0af8c).

Fixed here

  • The three SSE helpers (schedules-events.js, scratchpad-events.js, settings-events.js) were byte-identical apart from the event name, and each opened its own EventSource to /events?id=__all__. A session tab already holds the per-session stream, so it went to three connections — two tabs would hit the browser's six-per-host HTTP/1.1 cap and stall fetches and saves. Replaced with web/src/shared/app-events.js: createAppEvents({ event }) multiplexes named events onto one stream per topic and closes it when the last subscriber leaves.
  • applyRemote now skips the textarea write when content already matches. Our own debounced save echoes back over SSE, and reassigning value moves the caret for no reason.

Verified, no change needed

  • read_token's ~/.config/pi-web/env matches where setup_env writes PI_WEB_TOKEN (install.sh:383-400), and X-Pi-Token is the header internal/auth/auth.go:263 accepts — so the CLI works under the hardened-auth/Tailscale path.
  • The worker cwd change is safe: CreateSessionFileWithSettings writes the cwd header before the worker starts (internal/sessions/session.go:844), so workerDir resolves the project dir and never silently falls back to /tmp for a real session.
  • _schedule_input covers exactly the nine scheduleInput fields, so a CLI update cannot blank a field the caller did not pass.

Deferred — translations

user-docs/en/{README,install,personal-assistant}.md changed, so AGENTS.md wants scripts/build_userdocs.py re-run. Doing it here means 104 pi calls that rewrite all 13 languages × 7 docs + hero, including files this PR never touched — that turns a skills PR into a docs-rewrite PR. Leaving it for a docs-only regen PR, same as the Windows rollout (#94).

Notes, not blocking

  • _url_has_token_query can never fire: every path is hardcoded and quote() encodes =.
  • clamp_int silently coerces --hour 99 to 23 rather than erroring.
  • schedule update NAME --weekly without --hour resets the time to 09:00 (the flag default).
  • sessionHeaderCWD duplicates the unexported sessions.readSessionCWD; worth exporting one if a third caller shows up.
  • The scratchpad SSE project match is exact-string, so it no-ops under path aliasing (/tmp vs /private/tmp) — degrades to no live update, which is fine.

make check green on the branch (lint, format, knip, vitest, build, go test ./..., install test, vet), including the new pi-web-ctl-test target.

@setkyar
setkyar merged commit 0328d06 into ygncode:main Sep 16, 2026
3 checks passed
setkyar added a commit that referenced this pull request Sep 18, 2026
Regenerate es, fr, de, zh, ja, id, ms, vi, th, fil, my, km, and lo for
install, keyboard-shortcuts, llm-debug, and roadmap. This also picks up
English drift from #117 that the locale files had missed.

build_userdocs.py gains a --docs filter so only changed guides are
re-translated, instead of all seven docs plus hero for every language
(52 pi calls instead of 104). Hero translation still only runs for a
full rebuild.
setkyar added a commit that referenced this pull request Sep 18, 2026
The 13 locale README and personal-assistant files still predated the
skills / pi-web-ctl additions from #117. Regenerate both docs for every
locale so the whole translation set matches the English source.
setkyar added a commit that referenced this pull request Sep 19, 2026
* docs: align guides with the current code and fill gaps

Architecture docs:
- Describe the Svelte SPA as the only live frontend; drop the nonexistent
  /login/LoginPage route (auth is the Go-rendered token prompt) and add
  /schedules everywhere routes are listed.
- backend.md: add internal/chatqueue + chat_queue*.go/request.go to the
  package layout, list all eleven SQLite tables, add /api/chat/queue, and
  sync the Server/Manager struct snapshots.
- CSS is inlined into the SPA shell; pwa.go no longer serves /theme.css,
  /index.css, /menu.css, /palette.css. Only /custom-themes.css is routed.
- Running-status recent-activity window is 800 ms, not 3 s.
- Tailscale Serve only runs when PI_WEB_TOKEN is set; server startup also
  launches the schedule loop and chat-queue drainer outside dev mode.
- chat returns 202 {"status":"queued"}; existing session files get three
  append paths (rename, auto-title, labels).
- Mention-autocomplete helpers live under components/session/chat/.
- Custom themes are picked in Settings -> Appearance (the header theme
  toggle is gone); index the design-system + metrics docs.

User docs:
- Roadmap: move shipped steering/queue, scheduler, display defaults, and
  git diff out of Next up/Planned.
- Keyboard shortcuts: document Cmd/Ctrl+/ (help) and Cmd/Ctrl+, (settings).
- llm-debug: /pi-web status is a pi command, not a binary subcommand.
- install: ?token= sets a cookie and is redirected away, so it does not
  linger in the address bar or history.

* docs(i18n): rebuild translations for the guides this PR changed

Regenerate es, fr, de, zh, ja, id, ms, vi, th, fil, my, km, and lo for
install, keyboard-shortcuts, llm-debug, and roadmap. This also picks up
English drift from #117 that the locale files had missed.

build_userdocs.py gains a --docs filter so only changed guides are
re-translated, instead of all seven docs plus hero for every language
(52 pi calls instead of 104). Hero translation still only runs for a
full rebuild.

* docs(i18n): catch up README and personal-assistant translations

The 13 locale README and personal-assistant files still predated the
skills / pi-web-ctl additions from #117. Regenerate both docs for every
locale so the whole translation set matches the English source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant