@telepath-computer/television 0.1.75 → 0.1.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -33251,15 +33251,18 @@ var require_websocket_server = __commonJS({
33251
33251
  var index_exports = {};
33252
33252
  __export(index_exports, {
33253
33253
  listVisibleCLICommandNames: () => listVisibleCLICommandNames,
33254
+ resolveBundledSkillsRoot: () => resolveBundledSkillsRoot,
33254
33255
  resolveBundledViewsPath: () => resolveBundledViewsPath,
33255
33256
  resolveCanonicalDir: () => resolveCanonicalDir,
33256
33257
  resolveStaticDir: () => resolveStaticDir,
33257
33258
  runCLI: () => runCLI
33258
33259
  });
33259
33260
  module.exports = __toCommonJS(index_exports);
33261
+ var import_node_child_process3 = require("node:child_process");
33260
33262
  var import_node_fs4 = require("node:fs");
33261
33263
  var import_node_os4 = __toESM(require("node:os"), 1);
33262
33264
  var import_node_path7 = __toESM(require("node:path"), 1);
33265
+ var import_node_module = require("node:module");
33263
33266
  var import_node_url = require("node:url");
33264
33267
 
33265
33268
  // ../../node_modules/commander/esm.mjs
@@ -50090,7 +50093,7 @@ function findCardIDInNode(node, artifactID) {
50090
50093
  var import_meta = {};
50091
50094
  var DAEMON_NAME = "com.television.server";
50092
50095
  var MAX_PORT = 65535;
50093
- var HELP_POINTER = "Run `tv help` to refresh the full skill content, including the validation rules and fix steps.";
50096
+ var HELP_POINTER = "Load/read the installed `television` skill. Start with `what-to-read.md`. If the skill is not installed, you can use `tv skills install` (interactive, not agent-friendly) or `tv skills show` (agent-friendly, prints bundled skill files directly). If this is artifact lifecycle work, read `artifact-workflow.md`. If this is HTML artifact work, also read `html-house-style.md` and the relevant `artifact-types/*.md` companion doc.";
50094
50097
  var CLIDirectiveError = class extends Error {
50095
50098
  name = "CLIDirectiveError";
50096
50099
  };
@@ -50112,9 +50115,16 @@ function createDirectiveError(message) {
50112
50115
  function getDevPackageDir() {
50113
50116
  return import_node_path7.default.resolve(import_node_path7.default.dirname((0, import_node_url.fileURLToPath)(import_meta.url)), "..");
50114
50117
  }
50118
+ function resolveSkillsBin() {
50119
+ if (typeof require === "function" && typeof require.resolve === "function") {
50120
+ return require.resolve("skills/bin/cli.mjs");
50121
+ }
50122
+ const localRequire = (0, import_node_module.createRequire)(import_node_path7.default.join(getDevPackageDir(), "package.json"));
50123
+ return localRequire.resolve("skills/bin/cli.mjs");
50124
+ }
50115
50125
  function readCLIVersion() {
50116
- if ("0.1.75".length > 0) {
50117
- return "0.1.75";
50126
+ if ("0.1.76".length > 0) {
50127
+ return "0.1.76";
50118
50128
  }
50119
50129
  const devPackageJsonPath = import_node_path7.default.join(getDevPackageDir(), "package.json");
50120
50130
  if (!(0, import_node_fs4.existsSync)(devPackageJsonPath)) {
@@ -50122,20 +50132,77 @@ function readCLIVersion() {
50122
50132
  }
50123
50133
  return JSON.parse((0, import_node_fs4.readFileSync)(devPackageJsonPath, "utf8")).version;
50124
50134
  }
50125
- function readWorkflowHelpText() {
50126
- if ('# Television\n\nTelevision is a persistent artifact screen for agents. Use it when the user\nshould be able to inspect, revisit, and refine a file-backed result instead of\nonly reading a chat reply.\n\nIf you lose context, run:\n\n```bash\ntv help\n```\n\nThat command prints this full skill as one blob. There is no topic-scoped help\nin the current implementation.\n\n## Mental model\n\n- A **screen** is a named viewer surface with a layout.\n- An **artifact** is a file-backed result that can exist independently of any\n screen. It can be unplaced, attached to one screen, or attached to multiple\n screens.\n- **Screen membership** is separate from artifact identity: attaching/detaching\n controls which screens show an artifact; deleting removes the artifact\n globally. The CLI create commands require `--screen` so in-progress artifacts\n are visible immediately.\n- An **internal artifact** is a Television-managed bundle. You create a pending\n bundle, edit files in that bundle, then commit it.\n- An **external artifact** is a pointer to an existing absolute file on disk.\n Television displays that file but does not own or delete it.\n- **Pending** means a create or edit is staged but not yet committed.\n- **Trash** means metadata and committed internal bundles moved out of the live\n tree. There is no restore workflow in the current scope.\n\nThe core workflow is:\n\n1. Decide whether the result should be internal or external.\n2. Decide whether the user should be taken to the new screen or artifact now, or whether the work should happen in the background.\n3. Create or stage the artifact with the CLI.\n4. For internal artifacts, edit files in the pending bundle.\n5. Commit when the validation rules are satisfied.\n\n## Focus model\n\nTelevision separates state changes from focus.\n\nThere are two kinds of focus:\n\n- **Screen focus** is persistent. It decides which screen the TV is currently showing.\n- **Artifact focus** is transient. It may switch screens first, then scroll the artifact into view and briefly highlight it.\n\nImportant consequence:\n\n- there is a persisted focused screen\n- there is **not** a persisted focused artifact\n\nState-change commands can optionally trigger focus, but they do not imply it.\n\nAgent-facing create and attach commands require an explicit focus decision:\n\n- `tv create-screen` requires exactly one of `--focus-screen` or `--no-focus`\n- `tv create-internal-artifact`, `tv create-external-artifact`, `tv create-url-artifact`, and `tv attach-artifact` require exactly one of `--focus-artifact` or `--no-focus`\n\nUse this decision rule:\n\n- use `--focus-screen` when the user likely wants to go to the new screen immediately\n- use `--focus-artifact` when the user likely wants to inspect the new artifact immediately\n- use `--no-focus` when the work should happen in the background while keeping the current screen and artifact context unchanged\n\nHeuristic examples:\n\n- use a focus flag for requests like "show me", "open it", "put it on screen", "take me there", or "let me review it"\n- treat user language like **active**, **current**, **showing**, **visible**, **switch to**, **change to**, **go to**, or **show me that** as focus intent for the relevant screen or artifact\n- requests like "switch to the other screen", "show me that artifact", or "change to that screen" should usually translate to `tv focus-screen` or `tv focus-artifact`\n- use `--no-focus` for requests like "set this up", "make it in the background", "prepare it", or "wire this in"\n- also use `--no-focus` when the user says things like "in the background", "while I do something else", "while I work on X", or otherwise signals that your work should proceed on a parallel thread decoupled from their main task\n\nDirect focus commands:\n\n- `tv focus-screen --id <screen-id>` sets persistent screen focus\n- `tv focus-artifact --id <artifact-id> [--screen <screen-id>]` sends a transient artifact-focus nudge\n- `tv focus-status` reports the current persistent screen focus and connected client count\n\nImportant communication rule:\n\n- when you use `--no-focus`, explicitly say what you did in chat so the user knows the work happened even though Television did not visibly change\n\nIf you forget these rules or the CLI rejects a command for missing focus intent, run `tv help` and reread this section before retrying.\n\n## User communication during multi-step workflows\n\nWhen you are doing a multi-step artifact workflow, keep the user informed as you\nprogress.\n\nRequired communication style:\n\n- verbalize key actions and decisions as they happen\n- keep the language concise\n- prefer short updates over long explanations\n- frame updates in the user\'s world and goals, not in the internal mechanics of the skill or CLI workflow\n- avoid technical workflow jargon unless the user explicitly asks for it\n- do not write reports, long paragraphs, or chatty summaries while the work is in progress\n- do not use lists unless the user explicitly asks for one\n- optimize for speed and token efficiency\n\nGood examples:\n\n- "Starting the artifact now."\n- "Reviewing the draft and source material."\n- "Updating the HTML and efficiently navigating the artifact creation flow."\n- "The artifact did not pass validation yet; fixing the draft notes and retrying."\n- "Finalizing the artifact now."\n- "Done."\n\nBad examples:\n\n- multi-paragraph progress reports\n- long retrospective narration during execution\n- verbose bullet lists for routine workflow steps\n\n## Internal versus external\n\nUse an **internal artifact** when:\n\n- the artifact is purpose-built for Television\n- Television should own the bundle structure\n- future agents should be able to maintain the result by reading bundle files\n- you need a staged create or staged edit workflow\n\nUse an **external artifact** when:\n\n- a real file already exists on disk\n- the user wants Television to display that existing file\n- you do not need a Television-managed bundle\n\nDecision rule:\n\n- If the result should be maintained as a Television-owned long-lived artifact,\n choose internal.\n- If the result is already a real file outside Television and should stay that\n way, choose external.\n\nSupported artifact types:\n\n- `text/markdown`\n- `text/html`\n\n## Internal bundle files\n\nEvery internal artifact bundle contains:\n\n- `artifact.md`\n- `data.json`\n- `memory.md`\n- `public/index.md` or `public/index.html`\n\nFresh pending bundles are intentionally minimal:\n\n- `artifact.md` is blank\n- `memory.md` is blank\n- `public/index.md` or `public/index.html` is blank\n- `data.json` is exactly `{}`\n\nThe scaffold is not commit-valid by itself. Learn the required structure from\nthis skill, not from placeholder content in the scaffold.\n\n### `artifact.md`\n\n`artifact.md` is the contract for the artifact. It explains what the artifact\nis for, what conceptual material it is based on, how it should render, and how\nlater agents should maintain it.\n\nBefore commit, `artifact.md` must be non-empty and contain all of these exact\nheadings:\n\n```md\n## User intent\n## Purpose\n## Data shape\n## Data sources\n## Rendering\n## Update workflow\n## Non-goals\n```\n\nWhat each section should capture:\n\n- `## User intent`: faithful restatement or quotation of what the user actually said they wanted; this is critical and should preserve the user\'s language as closely as practical, including requests, feedback, complaints, constraints, and guidance\n- `## Purpose`: what the artifact is trying to achieve\n- `## Data shape`: the conceptual shape you reasoned about while authoring; for markdown artifacts this will often just be `{}`\n- `## Data sources`: where the underlying facts, notes, or source material came from and how they were obtained\n- `## Rendering`: how `public/index.md` or `public/index.html` should present it\n- `## Update workflow`: how future agents should refresh or modify it\n- `## Non-goals`: what is intentionally excluded, especially application-like runtime behavior\n\n### `data.json`\n\n`data.json` is a **thinking artifact**, not a runtime payload.\n\nIts purpose is to help the model separate:\n\n- reasoning / planning / authoring structure\n- from final presentation in `public/index.md` or `public/index.html`\n\nUse it to capture the pure conceptual shape of what you are about to render.\nThis is an authoring aid for agents, not an application data layer.\n\nHard rules:\n\n- **Do not treat `data.json` as live runtime state.**\n- **Do not write HTML/JS that loads, depends on, or synchronizes against `data.json`.**\n- **Do not build application-like data-driven artifacts.**\n- **We do not support runtime data-backed artifacts at this time.**\n- Artifacts are static markdown or static HTML documents.\n- HTML artifacts may include JavaScript and extra assets under `public/`, but\n that JavaScript must stay presentation-oriented and self-contained, not\n driven by `data.json` as an application state container.\n\nFor `text/markdown` artifacts, leave `data.json` as exactly:\n\n```json\n{}\n```\n\nThere is usually little value in separating content from presentation for\nmarkdown artifacts, so prefer `{}` unless there is a very strong authoring\nreason not to.\n\nFor `text/html` artifacts, use `data.json` only when it helps you think clearly\nabout the material before rendering. It may describe the conceptual structure\nof the artifact, but it must not become a runtime contract.\n\nValidation rule:\n\n- `data.json` must exist and contain valid JSON\n\nThe current validator does not require the JSON value to be an object, but an\nobject is the normal choice.\n\n### `memory.md`\n\n`memory.md` is the working scratchpad for later agents. Record decisions,\nlimitations, data-retrieval notes, problems encountered, what changed, and what\nshould be watched during future edits.\n\nRequired validation anchors:\n\n- `memory.md` must contain `## Activity Log`\n- `memory.md` must contain at least one UTC timestamp in exact\n `YYYY-MM-DDTHH:MM:SSZ` format\n- at least one timestamp must be from the last 30 minutes when you commit\n\nThe minimum required heading is:\n\n```md\n## Activity Log\n```\n\nWhat to record beyond that is up to the artifact and the work performed.\n\n### `public/index.md` and `public/index.html`\n\nThis is the rendered entry file that Television serves.\n\n- Markdown artifacts use `public/index.md`\n- HTML artifacts use `public/index.html`\n- the entry file must match the artifact `type`\n- the entry file must be non-empty before commit\n\nFor HTML artifacts:\n\n- `public/index.html` is a full HTML document, not a body fragment\n- additional public assets may live under `public/`\n- keep paths relative to `public/`\n\n## Quality bar\n\nBuild artifacts that are durable, truthful, and maintainable by later agents.\n\nRequired quality standards:\n\n- be faithful to source data\n- do not invent or hallucinate missing facts\n- do not silently truncate a dataset and pretend it is complete\n- prefer truth over completeness when those goals conflict\n- make limitations, sampling, missing data, and freshness visible\n- keep rendering aligned with the reasoning captured in `artifact.md`, `data.json`, and `memory.md`\n- keep `data.json` as an authoring/thinking artifact rather than a runtime dependency\n- keep the artifact maintainable by a future agent reading only the bundle files\n\nAnti-patterns:\n\n- cursory or low-effort data collection\n- fake data added to make the artifact look complete\n- brittle one-off hacks that a later agent cannot reproduce\n- hidden dependencies that are not documented in `artifact.md` or `memory.md`\n- layout churn during simple data refreshes when the data model did not change\n\n## HTML house style\n\nHTML artifacts should feel intentional and readable inside Television tiles.\n\nTelevision provides a full base stylesheet for HTML artifacts. Only add custom\nCSS when you need something not covered by the built-in styles. Prefer the base\nstyles and theme tokens so artifacts stay visually coherent with the rest of\nTelevision.\n\nHouse-style guidance:\n\n- use semantic HTML first\n- keep the most important information near the top\n- design for small, medium, and large tile sizes\n- avoid horizontal overflow unless there is no reasonable alternative\n- make empty states and error states explicit\n- prefer the built-in HTML styling before inventing custom component chrome\n\n### Elements\n\nStandard elements already have sensible defaults, so you usually do not need to\nstyle from scratch:\n\n- headings (`h1`\u2013`h6`) \u2014 sized and weighted\n- `p`, `ul`, `ol` \u2014 readable defaults\n- `code` and `pre` \u2014 monospace, muted background\n- `blockquote` \u2014 left border, muted text\n- `table`, `th`, `td` \u2014 bordered, striped headers\n- `button` \u2014 styled with border and hover state; use `size="sm"` or `size="md"` when appropriate\n- `hr` \u2014 subtle border\n- `a` \u2014 inherits color by default\n\n### `.prose` class\n\nUse a `.prose` wrapper for document-style HTML where readable vertical rhythm is\nappropriate. Do not rely on `.prose` for dashboards, tables, control surfaces,\nor dense custom layouts.\n\n```html\n<div class="prose">\n <h1>Title</h1>\n <p>Some content with proper spacing between elements.</p>\n <ul>\n <li>Item one</li>\n <li>Item two</li>\n </ul>\n</div>\n```\n\n### CSS variables\n\nUse the existing Television tokens when they are available in the runtime.\nThese are the preferred way to stay aligned with the app theme.\n\nColors:\n- `--color-bg` \u2014 page background\n- `--color-bg-muted` \u2014 subtle background\n- `--color-surface` \u2014 card or panel background\n- `--color-text` \u2014 primary text\n- `--color-text-muted` \u2014 secondary or label text\n- `--color-border` \u2014 border color\n\nSpacing:\n- `--space-4`\n- `--space-8`\n- `--space-12`\n- `--space-16`\n- `--space-24`\n- `--space-32`\n\nFonts:\n- `--font-sans`\n- `--font-mono`\n\nText sizes:\n- `--text-sm`\n- `--text-base`\n- `--text-lg`\n- `--text-xl`\n\nRadius:\n- `--radius-4`\n- `--radius-8`\n\n## Workflows\n\n### Create new internal artifact\n\n1. Decide that the result should be an internal artifact.\n2. Start the pending bundle:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type text/markdown --title "Artifact title" --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type text/html --title "Artifact title" --no-focus\n```\n\n`--screen` is required for internal artifact creation so the artifact has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\n3. Read the returned pending path and edit files there.\n4. Write `artifact.md`.\n5. In `artifact.md`, capture the user\'s language faithfully in `## User intent` before doing the rest of the authoring work. Use direct quotes when helpful, or a close paraphrase when that is clearer, but keep it representative of what the user actually said they wanted.\n6. Think through the artifact in a pure way and write `data.json` only as an authoring aid.\n7. For markdown artifacts, leave `data.json` as `{}` unless there is a compelling authoring reason not to.\n8. Render `public/index.md` or `public/index.html`.\n9. Append a current timestamped activity entry in `memory.md`.\n10. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\n### Update internal artifact with fresh data\n\n1. Stage the edit:\n\n```bash\ntv edit-internal-artifact --id "<artifact-id>"\n```\n\n2. Read `artifact.md`, `data.json`, and `memory.md` before changing anything.\n3. Refresh the underlying facts or source material.\n4. Update `data.json` only if it helps clarify the authoring plan.\n5. For markdown artifacts, prefer to keep `data.json` as `{}`.\n6. Make the minimum rendering changes needed to keep the artifact correct.\n7. Record what changed in `memory.md`.\n8. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\nAvoid unnecessary layout or styling churn during data-only refreshes.\n\n### Modify internal artifact from user feedback\n\n1. Stage the edit:\n\n```bash\ntv edit-internal-artifact --id "<artifact-id>"\n```\n\n2. Read `artifact.md`, `data.json`, and `memory.md`.\n3. Update `artifact.md` if the user intent or non-goals changed.\n4. When the user has added feedback, complaints, corrections, or new guidance, update `## User intent` so it remains a faithful record of what the user actually wants now. Preserve the user\'s language as closely as practical, using direct quotes or close paraphrases.\n5. Update `data.json` only if it improves the authoring model of the artifact.\n6. For markdown artifacts, prefer to keep `data.json` as `{}`.\n7. Adjust `public/index.md` or `public/index.html` as narrowly as possible.\n8. Record the request, decision, and resulting change in `memory.md`.\n9. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\n### Abandon pending work\n\nIf the staged work should be discarded instead of committed:\n\n```bash\ntv abandon-pending-artifact --id "<artifact-id>"\n```\n\n### Create external artifact\n\nUse this when the file already exists on disk and Television should display it\nwithout owning a bundle:\n\n```bash\ntv create-external-artifact --screen "<screen-id>" --type text/markdown --title "Artifact title" --path /absolute/path/to/file.md --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-external-artifact --screen "<screen-id>" --type text/html --title "Artifact title" --path /absolute/path/to/file.html --no-focus\n```\n\n`--screen` is required for CLI creation so the file has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\nRules:\n\n- `--path` must be absolute\n- the file must already exist and be readable\n- the extension must match `type`\n- external artifacts do not use pending create, pending edit, commit, or abandon\n\n### Create URL artifact\n\nUse this when the artifact should display a live web page (an internal docs\npage, a dashboard, a third-party site) rather than content Television owns or a\nfile on disk:\n\n```bash\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com --no-focus\n```\n\n`--screen` is required for CLI creation so the page has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\nRules:\n\n- `--url` must be `http://` or `https://`\n- the type is always `text/html` \u2014 do not pass `--type`\n- URL artifacts are committed immediately on creation; they have no pending create, pending edit, commit, or abandon lifecycle\n- in the desktop app the page renders in a sandboxed `<webview>`; in the browser it renders in an `<iframe>`\n\n## CLI reference\n\nArtifact commands:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type <text/markdown|text/html> --title "Artifact title" (--focus-artifact|--no-focus)\ntv create-external-artifact --screen "<screen-id>" --type <text/markdown|text/html> --title "Artifact title" --path /absolute/path (--focus-artifact|--no-focus)\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com (--focus-artifact|--no-focus)\ntv edit-internal-artifact --id "<artifact-id>"\ntv commit-pending-artifact --id "<artifact-id>"\ntv abandon-pending-artifact --id "<artifact-id>"\ntv update-artifact --id "<artifact-id>" --title "New title"\ntv list-artifacts [--screen "<screen-id>"] [--unplaced]\ntv get-artifact --id "<artifact-id>"\ntv delete-artifact --id "<artifact-id>"\n```\n\nScreen commands:\n\n```bash\ntv create-screen --name "Screen name" (--focus-screen|--no-focus)\ntv list-screens\ntv get-screen --id "<screen-id>"\ntv remove-screen --id "<screen-id>"\n```\n\nScreen membership commands:\n\n```bash\ntv attach-artifact --id "<artifact-id>" --screen "<screen-id>" (--focus-artifact|--no-focus)\ntv detach-artifact --id "<artifact-id>" --screen "<screen-id>"\n```\n\nFocus commands:\n\n```bash\ntv focus-status\ntv focus-screen --id "<screen-id>"\ntv focus-artifact --id "<artifact-id>" [--screen "<screen-id>"]\n```\n\nServer commands:\n\n```bash\ntv status\ntv storage-path\ntv serve\ntv stop\n```\n\nCLI behavior notes:\n\n- `--screen` is required on CLI create commands so new artifacts get immediate screen membership; use `tv attach-artifact` and `tv detach-artifact` for later screen membership changes\n- `tv create-screen` requires exactly one of `--focus-screen` or `--no-focus`; `tv create-internal-artifact`, `tv create-external-artifact`, `tv create-url-artifact`, and `tv attach-artifact` require exactly one of `--focus-artifact` or `--no-focus`\n- workflow and mutation commands print plain text\n- read commands print JSON\n- `tv get-screen` includes artifact `kind` and `status`\n- `tv attach-artifact` appends a default-sized card to the right end of the strip; idempotent if the artifact is already on that screen\n- `tv detach-artifact` removes the card from a screen\'s layout; the artifact metadata is never touched, even on the last reference\n- `tv delete-artifact` is the way to globally remove an artifact (detaches from every screen, then trashes the bundle / forgets the external pointer / discards pending-create)\n- `tv list-artifacts` accepts `--screen <id>` to filter by screen membership and `--unplaced` to surface artifacts attached to no screen\n- `tv update-artifact` changes title metadata only\n- `tv focus-screen` sets which screen the GUI is focused on; the change is persisted and broadcast to connected clients\n- `tv focus-artifact` is a transient nudge: clients switch screens if needed, scroll the artifact\'s card into view, and play a brief highlight animation; pass `--screen <id>` to pin which screen, otherwise the server picks one (preferring the active screen when the artifact is there)\n- `tv focus-status` prints the active screen ID and the count of connected GUI clients\n- when the CLI reports an error, follow the directive to run `tv help`\n\n## Deferred or out of scope\n\nThese are not part of the current implementation:\n\n- `tv help <topic>`\n- restore-from-trash\n- pending-listing commands\n- attestation or nonce commands\n- stale pending cleanup or stale trash cleanup\n- markdown editor UI recovery\n- client-side pending presentation work\n- multi-section help output'.length > 0) {
50127
- return '# Television\n\nTelevision is a persistent artifact screen for agents. Use it when the user\nshould be able to inspect, revisit, and refine a file-backed result instead of\nonly reading a chat reply.\n\nIf you lose context, run:\n\n```bash\ntv help\n```\n\nThat command prints this full skill as one blob. There is no topic-scoped help\nin the current implementation.\n\n## Mental model\n\n- A **screen** is a named viewer surface with a layout.\n- An **artifact** is a file-backed result that can exist independently of any\n screen. It can be unplaced, attached to one screen, or attached to multiple\n screens.\n- **Screen membership** is separate from artifact identity: attaching/detaching\n controls which screens show an artifact; deleting removes the artifact\n globally. The CLI create commands require `--screen` so in-progress artifacts\n are visible immediately.\n- An **internal artifact** is a Television-managed bundle. You create a pending\n bundle, edit files in that bundle, then commit it.\n- An **external artifact** is a pointer to an existing absolute file on disk.\n Television displays that file but does not own or delete it.\n- **Pending** means a create or edit is staged but not yet committed.\n- **Trash** means metadata and committed internal bundles moved out of the live\n tree. There is no restore workflow in the current scope.\n\nThe core workflow is:\n\n1. Decide whether the result should be internal or external.\n2. Decide whether the user should be taken to the new screen or artifact now, or whether the work should happen in the background.\n3. Create or stage the artifact with the CLI.\n4. For internal artifacts, edit files in the pending bundle.\n5. Commit when the validation rules are satisfied.\n\n## Focus model\n\nTelevision separates state changes from focus.\n\nThere are two kinds of focus:\n\n- **Screen focus** is persistent. It decides which screen the TV is currently showing.\n- **Artifact focus** is transient. It may switch screens first, then scroll the artifact into view and briefly highlight it.\n\nImportant consequence:\n\n- there is a persisted focused screen\n- there is **not** a persisted focused artifact\n\nState-change commands can optionally trigger focus, but they do not imply it.\n\nAgent-facing create and attach commands require an explicit focus decision:\n\n- `tv create-screen` requires exactly one of `--focus-screen` or `--no-focus`\n- `tv create-internal-artifact`, `tv create-external-artifact`, `tv create-url-artifact`, and `tv attach-artifact` require exactly one of `--focus-artifact` or `--no-focus`\n\nUse this decision rule:\n\n- use `--focus-screen` when the user likely wants to go to the new screen immediately\n- use `--focus-artifact` when the user likely wants to inspect the new artifact immediately\n- use `--no-focus` when the work should happen in the background while keeping the current screen and artifact context unchanged\n\nHeuristic examples:\n\n- use a focus flag for requests like "show me", "open it", "put it on screen", "take me there", or "let me review it"\n- treat user language like **active**, **current**, **showing**, **visible**, **switch to**, **change to**, **go to**, or **show me that** as focus intent for the relevant screen or artifact\n- requests like "switch to the other screen", "show me that artifact", or "change to that screen" should usually translate to `tv focus-screen` or `tv focus-artifact`\n- use `--no-focus` for requests like "set this up", "make it in the background", "prepare it", or "wire this in"\n- also use `--no-focus` when the user says things like "in the background", "while I do something else", "while I work on X", or otherwise signals that your work should proceed on a parallel thread decoupled from their main task\n\nDirect focus commands:\n\n- `tv focus-screen --id <screen-id>` sets persistent screen focus\n- `tv focus-artifact --id <artifact-id> [--screen <screen-id>]` sends a transient artifact-focus nudge\n- `tv focus-status` reports the current persistent screen focus and connected client count\n\nImportant communication rule:\n\n- when you use `--no-focus`, explicitly say what you did in chat so the user knows the work happened even though Television did not visibly change\n\nIf you forget these rules or the CLI rejects a command for missing focus intent, run `tv help` and reread this section before retrying.\n\n## User communication during multi-step workflows\n\nWhen you are doing a multi-step artifact workflow, keep the user informed as you\nprogress.\n\nRequired communication style:\n\n- verbalize key actions and decisions as they happen\n- keep the language concise\n- prefer short updates over long explanations\n- frame updates in the user\'s world and goals, not in the internal mechanics of the skill or CLI workflow\n- avoid technical workflow jargon unless the user explicitly asks for it\n- do not write reports, long paragraphs, or chatty summaries while the work is in progress\n- do not use lists unless the user explicitly asks for one\n- optimize for speed and token efficiency\n\nGood examples:\n\n- "Starting the artifact now."\n- "Reviewing the draft and source material."\n- "Updating the HTML and efficiently navigating the artifact creation flow."\n- "The artifact did not pass validation yet; fixing the draft notes and retrying."\n- "Finalizing the artifact now."\n- "Done."\n\nBad examples:\n\n- multi-paragraph progress reports\n- long retrospective narration during execution\n- verbose bullet lists for routine workflow steps\n\n## Internal versus external\n\nUse an **internal artifact** when:\n\n- the artifact is purpose-built for Television\n- Television should own the bundle structure\n- future agents should be able to maintain the result by reading bundle files\n- you need a staged create or staged edit workflow\n\nUse an **external artifact** when:\n\n- a real file already exists on disk\n- the user wants Television to display that existing file\n- you do not need a Television-managed bundle\n\nDecision rule:\n\n- If the result should be maintained as a Television-owned long-lived artifact,\n choose internal.\n- If the result is already a real file outside Television and should stay that\n way, choose external.\n\nSupported artifact types:\n\n- `text/markdown`\n- `text/html`\n\n## Internal bundle files\n\nEvery internal artifact bundle contains:\n\n- `artifact.md`\n- `data.json`\n- `memory.md`\n- `public/index.md` or `public/index.html`\n\nFresh pending bundles are intentionally minimal:\n\n- `artifact.md` is blank\n- `memory.md` is blank\n- `public/index.md` or `public/index.html` is blank\n- `data.json` is exactly `{}`\n\nThe scaffold is not commit-valid by itself. Learn the required structure from\nthis skill, not from placeholder content in the scaffold.\n\n### `artifact.md`\n\n`artifact.md` is the contract for the artifact. It explains what the artifact\nis for, what conceptual material it is based on, how it should render, and how\nlater agents should maintain it.\n\nBefore commit, `artifact.md` must be non-empty and contain all of these exact\nheadings:\n\n```md\n## User intent\n## Purpose\n## Data shape\n## Data sources\n## Rendering\n## Update workflow\n## Non-goals\n```\n\nWhat each section should capture:\n\n- `## User intent`: faithful restatement or quotation of what the user actually said they wanted; this is critical and should preserve the user\'s language as closely as practical, including requests, feedback, complaints, constraints, and guidance\n- `## Purpose`: what the artifact is trying to achieve\n- `## Data shape`: the conceptual shape you reasoned about while authoring; for markdown artifacts this will often just be `{}`\n- `## Data sources`: where the underlying facts, notes, or source material came from and how they were obtained\n- `## Rendering`: how `public/index.md` or `public/index.html` should present it\n- `## Update workflow`: how future agents should refresh or modify it\n- `## Non-goals`: what is intentionally excluded, especially application-like runtime behavior\n\n### `data.json`\n\n`data.json` is a **thinking artifact**, not a runtime payload.\n\nIts purpose is to help the model separate:\n\n- reasoning / planning / authoring structure\n- from final presentation in `public/index.md` or `public/index.html`\n\nUse it to capture the pure conceptual shape of what you are about to render.\nThis is an authoring aid for agents, not an application data layer.\n\nHard rules:\n\n- **Do not treat `data.json` as live runtime state.**\n- **Do not write HTML/JS that loads, depends on, or synchronizes against `data.json`.**\n- **Do not build application-like data-driven artifacts.**\n- **We do not support runtime data-backed artifacts at this time.**\n- Artifacts are static markdown or static HTML documents.\n- HTML artifacts may include JavaScript and extra assets under `public/`, but\n that JavaScript must stay presentation-oriented and self-contained, not\n driven by `data.json` as an application state container.\n\nFor `text/markdown` artifacts, leave `data.json` as exactly:\n\n```json\n{}\n```\n\nThere is usually little value in separating content from presentation for\nmarkdown artifacts, so prefer `{}` unless there is a very strong authoring\nreason not to.\n\nFor `text/html` artifacts, use `data.json` only when it helps you think clearly\nabout the material before rendering. It may describe the conceptual structure\nof the artifact, but it must not become a runtime contract.\n\nValidation rule:\n\n- `data.json` must exist and contain valid JSON\n\nThe current validator does not require the JSON value to be an object, but an\nobject is the normal choice.\n\n### `memory.md`\n\n`memory.md` is the working scratchpad for later agents. Record decisions,\nlimitations, data-retrieval notes, problems encountered, what changed, and what\nshould be watched during future edits.\n\nRequired validation anchors:\n\n- `memory.md` must contain `## Activity Log`\n- `memory.md` must contain at least one UTC timestamp in exact\n `YYYY-MM-DDTHH:MM:SSZ` format\n- at least one timestamp must be from the last 30 minutes when you commit\n\nThe minimum required heading is:\n\n```md\n## Activity Log\n```\n\nWhat to record beyond that is up to the artifact and the work performed.\n\n### `public/index.md` and `public/index.html`\n\nThis is the rendered entry file that Television serves.\n\n- Markdown artifacts use `public/index.md`\n- HTML artifacts use `public/index.html`\n- the entry file must match the artifact `type`\n- the entry file must be non-empty before commit\n\nFor HTML artifacts:\n\n- `public/index.html` is a full HTML document, not a body fragment\n- additional public assets may live under `public/`\n- keep paths relative to `public/`\n\n## Quality bar\n\nBuild artifacts that are durable, truthful, and maintainable by later agents.\n\nRequired quality standards:\n\n- be faithful to source data\n- do not invent or hallucinate missing facts\n- do not silently truncate a dataset and pretend it is complete\n- prefer truth over completeness when those goals conflict\n- make limitations, sampling, missing data, and freshness visible\n- keep rendering aligned with the reasoning captured in `artifact.md`, `data.json`, and `memory.md`\n- keep `data.json` as an authoring/thinking artifact rather than a runtime dependency\n- keep the artifact maintainable by a future agent reading only the bundle files\n\nAnti-patterns:\n\n- cursory or low-effort data collection\n- fake data added to make the artifact look complete\n- brittle one-off hacks that a later agent cannot reproduce\n- hidden dependencies that are not documented in `artifact.md` or `memory.md`\n- layout churn during simple data refreshes when the data model did not change\n\n## HTML house style\n\nHTML artifacts should feel intentional and readable inside Television tiles.\n\nTelevision provides a full base stylesheet for HTML artifacts. Only add custom\nCSS when you need something not covered by the built-in styles. Prefer the base\nstyles and theme tokens so artifacts stay visually coherent with the rest of\nTelevision.\n\nHouse-style guidance:\n\n- use semantic HTML first\n- keep the most important information near the top\n- design for small, medium, and large tile sizes\n- avoid horizontal overflow unless there is no reasonable alternative\n- make empty states and error states explicit\n- prefer the built-in HTML styling before inventing custom component chrome\n\n### Elements\n\nStandard elements already have sensible defaults, so you usually do not need to\nstyle from scratch:\n\n- headings (`h1`\u2013`h6`) \u2014 sized and weighted\n- `p`, `ul`, `ol` \u2014 readable defaults\n- `code` and `pre` \u2014 monospace, muted background\n- `blockquote` \u2014 left border, muted text\n- `table`, `th`, `td` \u2014 bordered, striped headers\n- `button` \u2014 styled with border and hover state; use `size="sm"` or `size="md"` when appropriate\n- `hr` \u2014 subtle border\n- `a` \u2014 inherits color by default\n\n### `.prose` class\n\nUse a `.prose` wrapper for document-style HTML where readable vertical rhythm is\nappropriate. Do not rely on `.prose` for dashboards, tables, control surfaces,\nor dense custom layouts.\n\n```html\n<div class="prose">\n <h1>Title</h1>\n <p>Some content with proper spacing between elements.</p>\n <ul>\n <li>Item one</li>\n <li>Item two</li>\n </ul>\n</div>\n```\n\n### CSS variables\n\nUse the existing Television tokens when they are available in the runtime.\nThese are the preferred way to stay aligned with the app theme.\n\nColors:\n- `--color-bg` \u2014 page background\n- `--color-bg-muted` \u2014 subtle background\n- `--color-surface` \u2014 card or panel background\n- `--color-text` \u2014 primary text\n- `--color-text-muted` \u2014 secondary or label text\n- `--color-border` \u2014 border color\n\nSpacing:\n- `--space-4`\n- `--space-8`\n- `--space-12`\n- `--space-16`\n- `--space-24`\n- `--space-32`\n\nFonts:\n- `--font-sans`\n- `--font-mono`\n\nText sizes:\n- `--text-sm`\n- `--text-base`\n- `--text-lg`\n- `--text-xl`\n\nRadius:\n- `--radius-4`\n- `--radius-8`\n\n## Workflows\n\n### Create new internal artifact\n\n1. Decide that the result should be an internal artifact.\n2. Start the pending bundle:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type text/markdown --title "Artifact title" --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type text/html --title "Artifact title" --no-focus\n```\n\n`--screen` is required for internal artifact creation so the artifact has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\n3. Read the returned pending path and edit files there.\n4. Write `artifact.md`.\n5. In `artifact.md`, capture the user\'s language faithfully in `## User intent` before doing the rest of the authoring work. Use direct quotes when helpful, or a close paraphrase when that is clearer, but keep it representative of what the user actually said they wanted.\n6. Think through the artifact in a pure way and write `data.json` only as an authoring aid.\n7. For markdown artifacts, leave `data.json` as `{}` unless there is a compelling authoring reason not to.\n8. Render `public/index.md` or `public/index.html`.\n9. Append a current timestamped activity entry in `memory.md`.\n10. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\n### Update internal artifact with fresh data\n\n1. Stage the edit:\n\n```bash\ntv edit-internal-artifact --id "<artifact-id>"\n```\n\n2. Read `artifact.md`, `data.json`, and `memory.md` before changing anything.\n3. Refresh the underlying facts or source material.\n4. Update `data.json` only if it helps clarify the authoring plan.\n5. For markdown artifacts, prefer to keep `data.json` as `{}`.\n6. Make the minimum rendering changes needed to keep the artifact correct.\n7. Record what changed in `memory.md`.\n8. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\nAvoid unnecessary layout or styling churn during data-only refreshes.\n\n### Modify internal artifact from user feedback\n\n1. Stage the edit:\n\n```bash\ntv edit-internal-artifact --id "<artifact-id>"\n```\n\n2. Read `artifact.md`, `data.json`, and `memory.md`.\n3. Update `artifact.md` if the user intent or non-goals changed.\n4. When the user has added feedback, complaints, corrections, or new guidance, update `## User intent` so it remains a faithful record of what the user actually wants now. Preserve the user\'s language as closely as practical, using direct quotes or close paraphrases.\n5. Update `data.json` only if it improves the authoring model of the artifact.\n6. For markdown artifacts, prefer to keep `data.json` as `{}`.\n7. Adjust `public/index.md` or `public/index.html` as narrowly as possible.\n8. Record the request, decision, and resulting change in `memory.md`.\n9. Commit:\n\n```bash\ntv commit-pending-artifact --id "<artifact-id>"\n```\n\n### Abandon pending work\n\nIf the staged work should be discarded instead of committed:\n\n```bash\ntv abandon-pending-artifact --id "<artifact-id>"\n```\n\n### Create external artifact\n\nUse this when the file already exists on disk and Television should display it\nwithout owning a bundle:\n\n```bash\ntv create-external-artifact --screen "<screen-id>" --type text/markdown --title "Artifact title" --path /absolute/path/to/file.md --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-external-artifact --screen "<screen-id>" --type text/html --title "Artifact title" --path /absolute/path/to/file.html --no-focus\n```\n\n`--screen` is required for CLI creation so the file has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\nRules:\n\n- `--path` must be absolute\n- the file must already exist and be readable\n- the extension must match `type`\n- external artifacts do not use pending create, pending edit, commit, or abandon\n\n### Create URL artifact\n\nUse this when the artifact should display a live web page (an internal docs\npage, a dashboard, a third-party site) rather than content Television owns or a\nfile on disk:\n\n```bash\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com --focus-artifact\n```\n\nOr:\n\n```bash\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com --no-focus\n```\n\n`--screen` is required for CLI creation so the page has immediate screen membership. `--focus-artifact` or `--no-focus` is also required so you explicitly decide whether the user should be taken to it now.\n\nRules:\n\n- `--url` must be `http://` or `https://`\n- the type is always `text/html` \u2014 do not pass `--type`\n- URL artifacts are committed immediately on creation; they have no pending create, pending edit, commit, or abandon lifecycle\n- in the desktop app the page renders in a sandboxed `<webview>`; in the browser it renders in an `<iframe>`\n\n## CLI reference\n\nArtifact commands:\n\n```bash\ntv create-internal-artifact --screen "<screen-id>" --type <text/markdown|text/html> --title "Artifact title" (--focus-artifact|--no-focus)\ntv create-external-artifact --screen "<screen-id>" --type <text/markdown|text/html> --title "Artifact title" --path /absolute/path (--focus-artifact|--no-focus)\ntv create-url-artifact --screen "<screen-id>" --title "Artifact title" --url https://example.com (--focus-artifact|--no-focus)\ntv edit-internal-artifact --id "<artifact-id>"\ntv commit-pending-artifact --id "<artifact-id>"\ntv abandon-pending-artifact --id "<artifact-id>"\ntv update-artifact --id "<artifact-id>" --title "New title"\ntv list-artifacts [--screen "<screen-id>"] [--unplaced]\ntv get-artifact --id "<artifact-id>"\ntv delete-artifact --id "<artifact-id>"\n```\n\nScreen commands:\n\n```bash\ntv create-screen --name "Screen name" (--focus-screen|--no-focus)\ntv list-screens\ntv get-screen --id "<screen-id>"\ntv remove-screen --id "<screen-id>"\n```\n\nScreen membership commands:\n\n```bash\ntv attach-artifact --id "<artifact-id>" --screen "<screen-id>" (--focus-artifact|--no-focus)\ntv detach-artifact --id "<artifact-id>" --screen "<screen-id>"\n```\n\nFocus commands:\n\n```bash\ntv focus-status\ntv focus-screen --id "<screen-id>"\ntv focus-artifact --id "<artifact-id>" [--screen "<screen-id>"]\n```\n\nServer commands:\n\n```bash\ntv status\ntv storage-path\ntv serve\ntv stop\n```\n\nCLI behavior notes:\n\n- `--screen` is required on CLI create commands so new artifacts get immediate screen membership; use `tv attach-artifact` and `tv detach-artifact` for later screen membership changes\n- `tv create-screen` requires exactly one of `--focus-screen` or `--no-focus`; `tv create-internal-artifact`, `tv create-external-artifact`, `tv create-url-artifact`, and `tv attach-artifact` require exactly one of `--focus-artifact` or `--no-focus`\n- workflow and mutation commands print plain text\n- read commands print JSON\n- `tv get-screen` includes artifact `kind` and `status`\n- `tv attach-artifact` appends a default-sized card to the right end of the strip; idempotent if the artifact is already on that screen\n- `tv detach-artifact` removes the card from a screen\'s layout; the artifact metadata is never touched, even on the last reference\n- `tv delete-artifact` is the way to globally remove an artifact (detaches from every screen, then trashes the bundle / forgets the external pointer / discards pending-create)\n- `tv list-artifacts` accepts `--screen <id>` to filter by screen membership and `--unplaced` to surface artifacts attached to no screen\n- `tv update-artifact` changes title metadata only\n- `tv focus-screen` sets which screen the GUI is focused on; the change is persisted and broadcast to connected clients\n- `tv focus-artifact` is a transient nudge: clients switch screens if needed, scroll the artifact\'s card into view, and play a brief highlight animation; pass `--screen <id>` to pin which screen, otherwise the server picks one (preferring the active screen when the artifact is there)\n- `tv focus-status` prints the active screen ID and the count of connected GUI clients\n- when the CLI reports an error, follow the directive to run `tv help`\n\n## Deferred or out of scope\n\nThese are not part of the current implementation:\n\n- `tv help <topic>`\n- restore-from-trash\n- pending-listing commands\n- attestation or nonce commands\n- stale pending cleanup or stale trash cleanup\n- markdown editor UI recovery\n- client-side pending presentation work\n- multi-section help output';
50135
+ function listKnownArtifactTypeDocs() {
50136
+ if ('["artifact-types/table.md"]'.length > 0) {
50137
+ return JSON.parse('["artifact-types/table.md"]');
50128
50138
  }
50129
- const devSkillPath = import_node_path7.default.resolve(
50130
- getDevPackageDir(),
50131
- "../skills/television/SKILL.md"
50132
- );
50133
- if (!(0, import_node_fs4.existsSync)(devSkillPath)) {
50134
- throw new Error(
50135
- `Could not resolve packages/skills/television/SKILL.md for repo-local CLI help (looked at ${devSkillPath}).`
50136
- );
50139
+ const skillsRoot = import_node_path7.default.resolve(getDevPackageDir(), "../skills");
50140
+ if (!(0, import_node_fs4.existsSync)(skillsRoot)) {
50141
+ return [];
50142
+ }
50143
+ return (0, import_node_fs4.readdirSync)(skillsRoot, { withFileTypes: true }).filter((entry) => entry.isDirectory() && /^artifact-/.test(entry.name)).map((entry) => entry.name.slice("artifact-".length)).sort((a, b) => a.localeCompare(b)).map((slug) => `artifact-types/${slug}.md`);
50144
+ }
50145
+ function formatArtifactTypeDocsList() {
50146
+ const docs = listKnownArtifactTypeDocs();
50147
+ return docs.length > 0 ? docs.map((doc) => ` - ${doc}`).join("\n") : " - artifact-types/<name>.md";
50148
+ }
50149
+ function buildAgentHelpNote() {
50150
+ return [
50151
+ "",
50152
+ "Agent workflow note:",
50153
+ " Load/read the installed `television` skill before Television work.",
50154
+ " Then read `what-to-read.md` to choose the right companion docs.",
50155
+ " For artifact lifecycle work, read `artifact-workflow.md`.",
50156
+ " For HTML artifacts, also read `html-house-style.md`.",
50157
+ " Known artifact-type docs:",
50158
+ formatArtifactTypeDocsList(),
50159
+ " If the Television skill is not installed, you can use `tv skills install` (interactive) or `tv skills show` (agent-friendly, prints the bundled skill files directly)."
50160
+ ].join("\n");
50161
+ }
50162
+ function buildArtifactWorkflowHelpNote(includeHTMLNote) {
50163
+ const lines = [
50164
+ "",
50165
+ "Agent note:",
50166
+ " If you are an agent doing artifact lifecycle work, load/read the `television` skill and `artifact-workflow.md`."
50167
+ ];
50168
+ if (includeHTMLNote) {
50169
+ lines.push(" If you are authoring an HTML artifact, also read `html-house-style.md`.");
50170
+ lines.push(" Known artifact-type docs:");
50171
+ lines.push(formatArtifactTypeDocsList());
50137
50172
  }
50138
- return (0, import_node_fs4.readFileSync)(devSkillPath, "utf8").trimEnd();
50173
+ return lines.join("\n");
50174
+ }
50175
+ function getInstalledTelevisionSkillRoot(skillsRoot) {
50176
+ return import_node_path7.default.join(skillsRoot, "television");
50177
+ }
50178
+ function listSkillFiles(skillRoot, prefix = "") {
50179
+ const entries = (0, import_node_fs4.readdirSync)(skillRoot, { withFileTypes: true }).filter((entry) => !entry.name.startsWith(".")).sort((a, b) => a.name.localeCompare(b.name));
50180
+ const files = [];
50181
+ for (const entry of entries) {
50182
+ const relativePath = prefix === "" ? entry.name : import_node_path7.default.posix.join(prefix, entry.name);
50183
+ const absolutePath = import_node_path7.default.join(skillRoot, entry.name);
50184
+ if (entry.isDirectory()) {
50185
+ files.push(...listSkillFiles(absolutePath, relativePath));
50186
+ continue;
50187
+ }
50188
+ files.push(relativePath);
50189
+ }
50190
+ return files;
50191
+ }
50192
+ function resolveSkillFilePath(skillRoot, relativePath) {
50193
+ const normalized = import_node_path7.default.posix.normalize(relativePath);
50194
+ if (normalized.startsWith("../") || normalized === ".." || import_node_path7.default.isAbsolute(relativePath)) {
50195
+ throw createDirectiveError("tv skills show requires a relative path within the television skill root.");
50196
+ }
50197
+ const resolved = import_node_path7.default.join(skillRoot, normalized);
50198
+ const relativeResolved = import_node_path7.default.relative(skillRoot, resolved);
50199
+ if (relativeResolved.startsWith("..") || import_node_path7.default.isAbsolute(relativeResolved)) {
50200
+ throw createDirectiveError("tv skills show requires a relative path within the television skill root.");
50201
+ }
50202
+ if (!(0, import_node_fs4.existsSync)(resolved)) {
50203
+ throw createDirectiveError(`tv skills show could not find ${relativePath} in the television skill.`);
50204
+ }
50205
+ return resolved;
50139
50206
  }
50140
50207
  function commandNameFromArgv(argv) {
50141
50208
  const commandName = argv.find((value) => !value.startsWith("-"));
@@ -50192,10 +50259,13 @@ function resolveCanonicalDir() {
50192
50259
  );
50193
50260
  return (0, import_node_fs4.existsSync)(devCanonicalPath) ? devCanonicalPath : void 0;
50194
50261
  }
50195
- function isTopLevelHelpInvocation(argv) {
50196
- if (argv.length === 0) return true;
50197
- if (argv.length !== 1) return false;
50198
- return argv[0] === "help" || argv[0] === "-h" || argv[0] === "--help";
50262
+ function resolveBundledSkillsRoot() {
50263
+ const builtPath = typeof process.argv[1] === "string" ? import_node_path7.default.resolve(import_node_path7.default.dirname((0, import_node_fs4.realpathSync)(process.argv[1])), "./skills") : void 0;
50264
+ if (builtPath && (0, import_node_fs4.existsSync)(builtPath)) {
50265
+ return builtPath;
50266
+ }
50267
+ const devPath = import_node_path7.default.resolve(getDevPackageDir(), "../skills/dist/skills");
50268
+ return (0, import_node_fs4.existsSync)(devPath) ? devPath : void 0;
50199
50269
  }
50200
50270
  function isInTempDirectory(inputPath) {
50201
50271
  try {
@@ -50362,6 +50432,14 @@ function createEnvironment(environment) {
50362
50432
  resolveStaticDir: environment.resolveStaticDir ?? (() => resolveStaticDir()),
50363
50433
  resolveCanonicalDir: environment.resolveCanonicalDir ?? (() => resolveCanonicalDir()),
50364
50434
  resolveBundledViewsPath: environment.resolveBundledViewsPath ?? (() => resolveBundledViewsPath()),
50435
+ resolveBundledSkillsRoot: environment.resolveBundledSkillsRoot ?? (() => resolveBundledSkillsRoot()),
50436
+ runSkillsInstaller: environment.runSkillsInstaller ?? (async (args) => {
50437
+ const skillsBin = resolveSkillsBin();
50438
+ const result = (0, import_node_child_process3.spawnSync)(process.execPath, [skillsBin, ...args], { stdio: "inherit" });
50439
+ if (result.status !== 0) {
50440
+ throw new Error(`skills ${args.join(" ")} failed (exit ${result.status ?? "signal"})`);
50441
+ }
50442
+ }),
50365
50443
  onSignal: environment.onSignal ?? ((signal, handler) => process.on(signal, handler))
50366
50444
  };
50367
50445
  }
@@ -50370,15 +50448,12 @@ function createProgram(env, argv = []) {
50370
50448
  const createAuthenticatedClient = (serverURL) => {
50371
50449
  return env.createClient(serverURL, readAuthToken(getTelevisionStoragePath()));
50372
50450
  };
50373
- program2.name("tv").description("Television \u2014 virtual display for agents").version(readCLIVersion()).helpCommand(false).showSuggestionAfterError(false).configureOutput({
50451
+ program2.name("tv").description("Television \u2014 virtual display for agents").version(readCLIVersion()).showSuggestionAfterError(false).addHelpText("after", buildAgentHelpNote()).configureOutput({
50374
50452
  writeOut: (str) => env.stdout.write(str),
50375
50453
  writeErr: (str) => env.stderr.write(str),
50376
50454
  outputError: () => {
50377
50455
  }
50378
50456
  }).exitOverride();
50379
- program2.command("help").description("Show Television workflow help").action(() => {
50380
- writeLine(env.stdout, readWorkflowHelpText());
50381
- });
50382
50457
  program2.command("serve").description("Start the Television server").option("--host <address>", "Address to bind to").option("--port <number>", "Port to listen on", parsePortOption).option("--storage-path <path>", "Directory for persisted screen data").option("--public", "Serve without auth").option("--persist", "Install as a persistent system service").action(async (opts) => {
50383
50458
  if (opts.persist) {
50384
50459
  const storagePath = opts.storagePath ?? getTelevisionStoragePath();
@@ -50430,7 +50505,7 @@ function createProgram(env, argv = []) {
50430
50505
  });
50431
50506
  });
50432
50507
  });
50433
- program2.command("create-internal-artifact").description("Create a pending internal Television-managed artifact bundle").requiredOption("--screen <id>", "Target screen ID").requiredOption("--type <type>", `Artifact type (${ARTIFACT_TYPES.join(" or ")})`).requiredOption("--title <title>", "Artifact title").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50508
+ program2.command("create-internal-artifact").description("Create a pending internal Television-managed artifact bundle").requiredOption("--screen <id>", "Target screen ID").requiredOption("--type <type>", `Artifact type (${ARTIFACT_TYPES.join(" or ")})`).requiredOption("--title <title>", "Artifact title").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
50434
50509
  const shouldFocus = resolveFocusDirective(argv, "create-internal-artifact", "--focus-artifact");
50435
50510
  if (!isArtifactType(opts.type)) {
50436
50511
  throw createDirectiveError(
@@ -50453,24 +50528,24 @@ function createProgram(env, argv = []) {
50453
50528
  writeLine(env.stdout, `Edit files in ${result.pendingPath}, then commit with:`);
50454
50529
  writeLine(env.stdout, ` tv commit-pending-artifact --id ${result.artifact.id}`);
50455
50530
  });
50456
- program2.command("edit-internal-artifact").description("Stage a pending edit for an internal artifact").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50531
+ program2.command("edit-internal-artifact").description("Stage a pending edit for an internal artifact").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
50457
50532
  const client = createAuthenticatedClient(opts.server);
50458
50533
  const result = await client.artifacts.edit({ artifactID: opts.id });
50459
50534
  writeLine(env.stdout, `Pending edit for artifact ${result.artifact.id} staged.`);
50460
50535
  writeLine(env.stdout, `Edit files in ${result.pendingPath}, then commit with:`);
50461
50536
  writeLine(env.stdout, ` tv commit-pending-artifact --id ${result.artifact.id}`);
50462
50537
  });
50463
- program2.command("commit-pending-artifact").description("Validate and commit a pending internal artifact bundle").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50538
+ program2.command("commit-pending-artifact").description("Validate and commit a pending internal artifact bundle").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
50464
50539
  const client = createAuthenticatedClient(opts.server);
50465
50540
  const { artifact } = await client.artifacts.commitPending({ artifactID: opts.id });
50466
50541
  writeLine(env.stdout, `Artifact ${artifact.id} committed.`);
50467
50542
  });
50468
- program2.command("abandon-pending-artifact").description("Discard a pending internal artifact create or edit").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50543
+ program2.command("abandon-pending-artifact").description("Discard a pending internal artifact create or edit").requiredOption("--id <id>", "Artifact ID").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(false)).action(async (opts) => {
50469
50544
  const client = createAuthenticatedClient(opts.server);
50470
50545
  await client.artifacts.abandonPending({ artifactID: opts.id });
50471
50546
  writeLine(env.stdout, `Pending operation on artifact ${opts.id} abandoned.`);
50472
50547
  });
50473
- program2.command("create-external-artifact").description("Create an external artifact that points at an existing file").requiredOption("--screen <id>", "Target screen ID").requiredOption("--type <type>", `Artifact type (${ARTIFACT_TYPES.join(" or ")})`).requiredOption("--title <title>", "Artifact title").requiredOption("--path <path>", "Absolute path to an existing content file").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50548
+ program2.command("create-external-artifact").description("Create an external artifact that points at an existing file").requiredOption("--screen <id>", "Target screen ID").requiredOption("--type <type>", `Artifact type (${ARTIFACT_TYPES.join(" or ")})`).requiredOption("--title <title>", "Artifact title").requiredOption("--path <path>", "Absolute path to an existing content file").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
50474
50549
  const shouldFocus = resolveFocusDirective(argv, "create-external-artifact", "--focus-artifact");
50475
50550
  if (!isArtifactType(opts.type)) {
50476
50551
  throw createDirectiveError(
@@ -50498,7 +50573,7 @@ If you wish to display temporary content to the user, use an internal artifact i
50498
50573
  writeLine(env.stdout, `External artifact ${artifact.id} created.`);
50499
50574
  writeLine(env.stdout, `Television will display content from ${externalPath} and watch it for changes.`);
50500
50575
  });
50501
- program2.command("create-url-artifact").description("Create a URL-backed artifact that embeds an external page").requiredOption("--screen <id>", "Target screen ID").requiredOption("--title <title>", "Artifact title").requiredOption("--url <url>", "http(s) URL of the page to embed").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).action(async (opts) => {
50576
+ program2.command("create-url-artifact").description("Create a URL-backed artifact that embeds an external page").requiredOption("--screen <id>", "Target screen ID").requiredOption("--title <title>", "Artifact title").requiredOption("--url <url>", "http(s) URL of the page to embed").option("--focus-artifact", "Focus the new artifact after creation").option("--no-focus", "Create the artifact in the background without changing focus").option("--server <url>", "Server URL", DEFAULT_SERVER_URL).addHelpText("after", buildArtifactWorkflowHelpNote(true)).action(async (opts) => {
50502
50577
  const shouldFocus = resolveFocusDirective(argv, "create-url-artifact", "--focus-artifact");
50503
50578
  const client = createAuthenticatedClient(opts.server);
50504
50579
  const { artifact } = await client.artifacts.create({
@@ -50615,6 +50690,44 @@ If you wish to display temporary content to the user, use an internal artifact i
50615
50690
  const result = await client.viewer.focus(focusInput);
50616
50691
  writeLine(env.stdout, `Focused artifact ${result.artifactID} on screen ${result.screenID}.`);
50617
50692
  });
50693
+ const skillsCommand = program2.command("skills").description("Install the bundled Television skill").addHelpText("after", [
50694
+ "",
50695
+ "This command group manages the bundled `television` skill.",
50696
+ "`tv skills install` installs or reinstalls it globally through the `skills` package.",
50697
+ "`tv skills show` lists bundled skill files or prints one directly, which is useful for agents that need the content without running the interactive installer."
50698
+ ].join("\n"));
50699
+ skillsCommand.command("path").description("Print the bundled Television skills collection root").action(() => {
50700
+ const skillsRoot = env.resolveBundledSkillsRoot();
50701
+ if (!skillsRoot) {
50702
+ throw new Error("Could not resolve the bundled Television skills root.");
50703
+ }
50704
+ writeLine(env.stdout, skillsRoot);
50705
+ });
50706
+ skillsCommand.command("install").description("Install or reinstall the bundled Television skill globally").allowUnknownOption(true).action(async function() {
50707
+ const skillsRoot = env.resolveBundledSkillsRoot();
50708
+ if (!skillsRoot) {
50709
+ throw new Error("Could not resolve the bundled Television skills root.");
50710
+ }
50711
+ await env.runSkillsInstaller(["add", skillsRoot, "--global"]);
50712
+ });
50713
+ skillsCommand.command("show").description("List bundled Television skill files or print one by relative path").argument("[path]", "Relative path within the television skill root").action((relativePath) => {
50714
+ const skillsRoot = env.resolveBundledSkillsRoot();
50715
+ if (!skillsRoot) {
50716
+ throw new Error("Could not resolve the bundled Television skills root.");
50717
+ }
50718
+ const skillRoot = getInstalledTelevisionSkillRoot(skillsRoot);
50719
+ if (!(0, import_node_fs4.existsSync)(skillRoot)) {
50720
+ throw new Error(`Could not resolve the bundled television skill root at ${skillRoot}.`);
50721
+ }
50722
+ if (relativePath === void 0) {
50723
+ for (const file2 of listSkillFiles(skillRoot)) {
50724
+ writeLine(env.stdout, file2);
50725
+ }
50726
+ return;
50727
+ }
50728
+ const filepath = resolveSkillFilePath(skillRoot, relativePath);
50729
+ env.stdout.write((0, import_node_fs4.readFileSync)(filepath, "utf8"));
50730
+ });
50618
50731
  program2.command("stop").description("Stop the Television system service").action(async () => {
50619
50732
  const daemon = env.createDaemon();
50620
50733
  await daemon.uninstall();
@@ -50648,14 +50761,11 @@ function listVisibleCLICommandNames() {
50648
50761
  async function runCLI(argv, environment = {}) {
50649
50762
  const env = createEnvironment(environment);
50650
50763
  try {
50651
- if (isTopLevelHelpInvocation(argv)) {
50652
- writeLine(env.stdout, readWorkflowHelpText());
50764
+ const program2 = createProgram(env, argv);
50765
+ if (argv.length === 0) {
50766
+ program2.outputHelp();
50653
50767
  return 0;
50654
50768
  }
50655
- if (argv[0] === "help") {
50656
- throw createDirectiveError("tv help does not accept additional arguments.");
50657
- }
50658
- const program2 = createProgram(env, argv);
50659
50769
  await program2.parseAsync(argv, { from: "user" });
50660
50770
  return 0;
50661
50771
  } catch (error48) {
@@ -50684,6 +50794,7 @@ if (!isVitestRuntime()) {
50684
50794
  // Annotate the CommonJS export names for ESM import in node:
50685
50795
  0 && (module.exports = {
50686
50796
  listVisibleCLICommandNames,
50797
+ resolveBundledSkillsRoot,
50687
50798
  resolveBundledViewsPath,
50688
50799
  resolveCanonicalDir,
50689
50800
  resolveStaticDir,