portable-agent-layer 0.9.0 → 0.11.0

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.
Files changed (51) hide show
  1. package/assets/skills/{analyze-pdf.md → analyze-pdf/SKILL.md} +4 -4
  2. package/{src → assets/skills/analyze-pdf}/tools/pdf-download.ts +3 -3
  3. package/assets/skills/{analyze-youtube.md → analyze-youtube/SKILL.md} +4 -4
  4. package/{src → assets/skills/analyze-youtube}/tools/youtube-analyze.ts +2 -2
  5. package/assets/skills/{council.md → council/SKILL.md} +3 -2
  6. package/assets/skills/{create-skill.md → create-skill/SKILL.md} +2 -1
  7. package/assets/skills/{extract-entities.md → extract-entities/SKILL.md} +4 -5
  8. package/{src → assets/skills/extract-entities}/tools/entity-save.ts +3 -3
  9. package/assets/skills/{extract-wisdom.md → extract-wisdom/SKILL.md} +3 -2
  10. package/assets/skills/{first-principles.md → first-principles/SKILL.md} +3 -2
  11. package/assets/skills/{fyzz-chat-api.md → fyzz-chat-api/SKILL.md} +6 -6
  12. package/{src → assets/skills/fyzz-chat-api}/tools/fyzz-api.ts +6 -6
  13. package/assets/skills/{reflect.md → reflect/SKILL.md} +2 -1
  14. package/assets/skills/{research.md → research/SKILL.md} +2 -1
  15. package/assets/skills/{review.md → review/SKILL.md} +2 -1
  16. package/assets/skills/{summarize.md → summarize/SKILL.md} +3 -2
  17. package/assets/skills/telos/SKILL.md +60 -0
  18. package/assets/skills/telos/tools/update-telos.ts +101 -0
  19. package/assets/skills/think/SKILL.md +47 -0
  20. package/assets/templates/AGENTS.md.template +8 -37
  21. package/assets/templates/PAL/CONTEXT_ROUTING.md +12 -0
  22. package/assets/templates/PAL/MEMORY_SYSTEM.md +26 -0
  23. package/assets/templates/PAL/OPINION_TRACKING.md +3 -0
  24. package/assets/templates/PAL/STEERING_RULES.md +23 -0
  25. package/assets/templates/PAL/WORK_TRACKING.md +14 -0
  26. package/assets/templates/settings.claude.json +80 -0
  27. package/package.json +2 -5
  28. package/src/hooks/handlers/rating.ts +4 -47
  29. package/src/hooks/handlers/reflect-trigger.ts +83 -0
  30. package/src/hooks/handlers/relationship.ts +8 -5
  31. package/src/hooks/handlers/session-name.ts +8 -6
  32. package/src/hooks/handlers/work-learning.ts +1 -0
  33. package/src/hooks/handlers/work-session.ts +16 -3
  34. package/src/hooks/lib/claude-md.ts +9 -24
  35. package/src/hooks/lib/context.ts +31 -48
  36. package/src/hooks/lib/graduation.ts +6 -4
  37. package/src/hooks/lib/learning-store.ts +7 -117
  38. package/src/hooks/lib/opinions.ts +191 -0
  39. package/src/hooks/lib/paths.ts +2 -0
  40. package/src/hooks/lib/relationship.ts +5 -4
  41. package/src/hooks/lib/security.ts +2 -0
  42. package/src/hooks/lib/stop.ts +3 -0
  43. package/src/hooks/lib/text-similarity.ts +125 -0
  44. package/src/targets/claude/install.ts +16 -93
  45. package/src/targets/claude/uninstall.ts +22 -47
  46. package/src/targets/lib.ts +190 -48
  47. package/src/targets/opencode/install.ts +13 -2
  48. package/src/targets/opencode/uninstall.ts +4 -1
  49. package/src/tools/analyze.ts +49 -15
  50. package/src/tools/opinion.ts +250 -0
  51. package/src/tools/relationship-reflect.ts +215 -105
@@ -1,15 +1,16 @@
1
1
  ---
2
2
  name: analyze-pdf
3
- description: Download and analyze PDF files from URLs or local paths — extract text, answer questions, summarize content
3
+ description: Download and analyze PDF files from URLs or local paths — extract text, answer questions, summarize content. Use when analyzing, reading, or extracting information from a PDF.
4
+ argument-hint: <URL or file path>
4
5
  ---
5
6
 
6
7
  When the user asks to analyze, read, or extract information from a PDF:
7
8
 
8
9
  ## How to get the PDF
9
10
 
10
- - **URL**: Use the `ai:pdf-download` CLI tool to download and archive the PDF:
11
+ - **URL**: Use the `pdf-download` CLI tool to download and archive the PDF:
11
12
  ```bash
12
- bun run ai:pdf-download -- <url> [--filename <name.pdf>]
13
+ bun ~/.agents/skills/analyze-pdf/tools/pdf-download.ts -- <url> [--filename <name.pdf>]
13
14
  ```
14
15
  The tool downloads the file, saves it to `memory/downloads/{YYYY}/{MM}/{DD}/{filename}.pdf`, and returns JSON with the saved `path`.
15
16
 
@@ -33,7 +34,6 @@ Follow the user's request. Common tasks:
33
34
 
34
35
  ## Guidelines
35
36
 
36
- - Always run the tool from the PAL directory (the `ai:pdf-download` script is registered there)
37
37
  - For large PDFs, read specific page ranges rather than the entire document
38
38
  - Preserve the original structure (headings, lists, tables) when relevant
39
39
  - Quote verbatim when the user asks about specific content
@@ -6,7 +6,7 @@
6
6
  * Saves to: {PAL_ROOT}/memory/downloads/{YYYY}/{MM}/{DD}/{filename}.pdf
7
7
  *
8
8
  * Usage:
9
- * bun run ai:pdf-download -- <url> [--filename <name.pdf>]
9
+ * bun pdf-download.ts -- <url> [--filename <name.pdf>]
10
10
  *
11
11
  * Returns JSON with the saved file path for downstream reading.
12
12
  */
@@ -14,7 +14,7 @@
14
14
  import { mkdir } from "node:fs/promises";
15
15
  import { basename, join } from "node:path";
16
16
  import { parseArgs } from "node:util";
17
- import { palHome } from "../hooks/lib/paths";
17
+ import { palHome } from "../../../../src/hooks/lib/paths";
18
18
 
19
19
  const DOWNLOADS_DIR = join(palHome(), "memory", "downloads");
20
20
 
@@ -45,7 +45,7 @@ async function main() {
45
45
 
46
46
  const url = positionals[0];
47
47
  if (!url) {
48
- console.error("Usage: bun run ai:pdf-download -- <url> [--filename <name.pdf>]");
48
+ console.error("Usage: bun pdf-download.ts -- <url> [--filename <name.pdf>]");
49
49
  process.exit(1);
50
50
  }
51
51
 
@@ -1,16 +1,17 @@
1
1
  ---
2
2
  name: analyze-youtube
3
- description: Analyze YouTube videos using Gemini's native video understanding — summarize, extract insights, answer questions
3
+ description: Analyze YouTube videos using Gemini's native video understanding — summarize, extract insights, answer questions. Use when analyzing, summarizing, or extracting information from a YouTube video.
4
+ argument-hint: <YouTube URL>
4
5
  ---
5
6
 
6
7
  When the user asks to analyze, summarize, or extract information from a YouTube video:
7
8
 
8
9
  ## How to analyze
9
10
 
10
- Use the `ai:youtube-analyze` CLI tool. It sends the video to Gemini, which processes both visual and audio content natively.
11
+ Use the `youtube-analyze` CLI tool. It sends the video to Gemini, which processes both visual and audio content natively.
11
12
 
12
13
  ```bash
13
- bun run ai:youtube-analyze -- <youtube-url> [--prompt "your question"]
14
+ bun ~/.agents/skills/analyze-youtube/tools/youtube-analyze.ts -- <youtube-url> [--prompt "your question"]
14
15
  ```
15
16
 
16
17
  - Without `--prompt`, it returns a structured summary with key insights, topics, people, and quotes.
@@ -28,7 +29,6 @@ Follow the user's request. Common tasks:
28
29
 
29
30
  ## Guidelines
30
31
 
31
- - Always run the tool from the PAL directory (the `ai:youtube-analyze` script is registered there)
32
32
  - For long videos, consider asking a focused question via `--prompt` rather than a full analysis
33
33
  - Gemini sees both visuals and audio — mention on-screen content (slides, code, diagrams) when relevant
34
34
  - Quote speakers verbatim when the user asks about specific statements
@@ -7,7 +7,7 @@
7
7
  * Requires GEMINI_API_KEY environment variable.
8
8
  *
9
9
  * Usage:
10
- * bun run ai:youtube-analyze -- <youtube-url> [--prompt "your question"]
10
+ * bun youtube-analyze.ts -- <youtube-url> [--prompt "your question"]
11
11
  *
12
12
  * Default prompt extracts a structured summary with key insights.
13
13
  */
@@ -45,7 +45,7 @@ async function main() {
45
45
  const url = positionals[0];
46
46
  if (!url) {
47
47
  console.error(
48
- 'Usage: bun run ai:youtube-analyze -- <youtube-url> [--prompt "your question"]'
48
+ 'Usage: bun youtube-analyze.ts -- <youtube-url> [--prompt "your question"]'
49
49
  );
50
50
  process.exit(1);
51
51
  }
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: council
3
- description: Multi-perspective parallel debate on a decision — 3-5 independent perspectives argue in parallel, then synthesize into a verdict
3
+ description: Multi-perspective parallel debate on a decision — 3-5 independent perspectives argue in parallel, then synthesize into a verdict. Use when debating, weighing options, or needing multiple viewpoints on a question.
4
+ argument-hint: <question or decision>
4
5
  ---
5
6
 
6
- When the user invokes /council <question or decision>:
7
+ Debate $ARGUMENTS from multiple perspectives:
7
8
 
8
9
  ## Step 1: Define Perspectives
9
10
 
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: create-skill
3
- description: Scaffold a new PAL skill from a description
3
+ description: Scaffold a new PAL skill from a description. Use when creating a new skill, adding a capability, or building a custom command.
4
+ argument-hint: <skill description>
4
5
  ---
5
6
 
6
7
  When the user invokes /create-skill <name> <description>:
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: extract-entities
3
- description: Extract people and companies from content (articles, videos, URLs, pasted text)
3
+ description: Extract people and companies from content (articles, videos, URLs, pasted text). Use when identifying who and what organizations are mentioned in content.
4
+ argument-hint: <content, URL, or pasted text>
4
5
  ---
5
6
 
6
- When the user invokes /extract-entities <content, URL, or pasted text>:
7
+ Extract people and companies from $ARGUMENTS:
7
8
 
8
9
  1. Read/fetch the content
9
10
  2. Extract ALL people and companies mentioned
@@ -52,12 +53,10 @@ Return structured JSON:
52
53
 
53
54
  ## Persistence
54
55
 
55
- Always run the tool from the PAL directory (the `ai:entity-save` script is registered there).
56
-
57
56
  After displaying results, ask the user if they want to save. When saving, pipe the JSON output through the entity-save tool which handles deduplication automatically:
58
57
 
59
58
  ```bash
60
- echo '<the JSON output>' | bun run ai:entity-save -- --source "<URL or content origin>"
59
+ echo '<the JSON output>' | bun ~/.agents/skills/extract-entities/tools/entity-save.ts -- --source "<URL or content origin>"
61
60
  ```
62
61
 
63
62
  The tool deduplicates against the entity index (`memory/entities/entity-index.json`), assigns stable UUIDs, tracks occurrences, and reports what was new vs existing.
@@ -6,13 +6,13 @@
6
6
  * deduplicates against the entity index, and saves.
7
7
  *
8
8
  * Usage:
9
- * echo '{"people":[...],"companies":[...]}' | bun run ai:entity-save -- --source "https://example.com"
10
- * bun run ai:entity-save -- --file /path/to/extracted.json --source "https://example.com"
9
+ * echo '{"people":[...],"companies":[...]}' | bun entity-save.ts -- --source "https://example.com"
10
+ * bun entity-save.ts -- --file /path/to/extracted.json --source "https://example.com"
11
11
  */
12
12
 
13
13
  import { readFileSync } from "node:fs";
14
14
  import { parseArgs } from "node:util";
15
- import { loadEntityIndex, processEntities } from "../hooks/lib/entities";
15
+ import { loadEntityIndex, processEntities } from "../../../../src/hooks/lib/entities";
16
16
 
17
17
  const { values } = parseArgs({
18
18
  args: Bun.argv.slice(2),
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: extract-wisdom
3
- description: Extract structured insights from content (articles, videos, podcasts)
3
+ description: Extract structured insights from content (articles, videos, podcasts). Use when extracting wisdom, key takeaways, or structured insights from any content.
4
+ argument-hint: <content or URL>
4
5
  ---
5
6
 
6
- When the user invokes /extract-wisdom <content or URL>:
7
+ Extract structured insights from $ARGUMENTS:
7
8
 
8
9
  1. Read/fetch the content
9
10
  2. Extract:
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: first-principles
3
- description: Break down a problem to its fundamental constraints and build up a solution
3
+ description: Break down a problem to its fundamental constraints and build up a solution. Use when decomposing complexity, challenging assumptions, or finding root causes.
4
+ argument-hint: <problem>
4
5
  ---
5
6
 
6
- When the user invokes /first-principles <problem>:
7
+ Break down $ARGUMENTS to fundamentals:
7
8
 
8
9
  1. **State the problem** clearly in one sentence
9
10
  2. **Identify assumptions** — what are we taking for granted?
@@ -1,28 +1,29 @@
1
1
  ---
2
2
  name: fyzz-chat-api
3
- description: Query Fyzz Chat conversations and projects via the REST API (API key is handled securely by the CLI tool)
3
+ description: Query Fyzz Chat conversations and projects via the REST API. Use when looking up conversations, searching chat history, or listing projects in Fyzz Chat.
4
+ argument-hint: <conversations|projects> [options]
4
5
  ---
5
6
 
6
- When you need to access the user's Fyzz Chat conversations or projects, use the `ai:fyzz-api` CLI tool. The tool reads the API key from the `FYZZ_API_KEY` environment variable automatically — never attempt to read, print, or reference the API key or the env var directly.
7
+ When you need to access the user's Fyzz Chat conversations or projects, use the `fyzz-api` CLI tool. The tool reads the API key from the `FYZZ_API_KEY` environment variable automatically — never attempt to read, print, or reference the API key or the env var directly.
7
8
 
8
9
  ## Available commands
9
10
 
10
11
  ### List conversations
11
12
 
12
13
  ```bash
13
- bun run ai:fyzz-api -- conversations [--limit 20] [--search "query"] [--project-id <id>] [--cursor <cursor>]
14
+ bun ~/.agents/skills/fyzz-chat-api/tools/fyzz-api.ts -- conversations [--limit 20] [--search "query"] [--project-id <id>] [--cursor <cursor>]
14
15
  ```
15
16
 
16
17
  ### Get a single conversation with messages
17
18
 
18
19
  ```bash
19
- bun run ai:fyzz-api -- conversations <conversation-id>
20
+ bun ~/.agents/skills/fyzz-chat-api/tools/fyzz-api.ts -- conversations <conversation-id>
20
21
  ```
21
22
 
22
23
  ### List projects
23
24
 
24
25
  ```bash
25
- bun run ai:fyzz-api -- projects
26
+ bun ~/.agents/skills/fyzz-chat-api/tools/fyzz-api.ts -- projects
26
27
  ```
27
28
 
28
29
  ## Setup
@@ -35,7 +36,6 @@ If the tool reports a missing API key:
35
36
 
36
37
  ## Guidelines
37
38
 
38
- - Always run the tool from the PAL directory (the `ai:fyzz-api` script is registered there)
39
39
  - The API key is never visible in this conversation — that is by design
40
40
  - Use `--search` for keyword-based lookup across titles and message content
41
41
  - Use `--project-id` to scope results to a specific project
@@ -6,9 +6,9 @@
6
6
  * Returns JSON responses from the Fyzz Chat REST API.
7
7
  *
8
8
  * Usage:
9
- * bun run ai:fyzz-api -- conversations [--limit 20] [--search "query"] [--project-id <id>] [--cursor <cursor>]
10
- * bun run ai:fyzz-api -- conversations <id>
11
- * bun run ai:fyzz-api -- projects
9
+ * bun fyzz-api.ts -- conversations [--limit 20] [--search "query"] [--project-id <id>] [--cursor <cursor>]
10
+ * bun fyzz-api.ts -- conversations <id>
11
+ * bun fyzz-api.ts -- projects
12
12
  */
13
13
 
14
14
  import { parseArgs } from "node:util";
@@ -53,11 +53,11 @@ const command = args[0];
53
53
 
54
54
  if (!command || command === "--help" || command === "-h") {
55
55
  console.log("Usage:");
56
- console.log(" bun run ai:fyzz-api -- conversations List conversations");
56
+ console.log(" bun fyzz-api.ts -- conversations List conversations");
57
57
  console.log(
58
- " bun run ai:fyzz-api -- conversations <id> Get conversation with messages"
58
+ " bun fyzz-api.ts -- conversations <id> Get conversation with messages"
59
59
  );
60
- console.log(" bun run ai:fyzz-api -- projects List projects");
60
+ console.log(" bun fyzz-api.ts -- projects List projects");
61
61
  console.log("");
62
62
  console.log("Options for 'conversations' (list mode):");
63
63
  console.log(" --limit <n> Max results (default 20)");
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: reflect
3
- description: Diagnose why a PAL behavior did not trigger as expected — trace hooks, instructions, and logic to find the gap
3
+ description: Diagnose why a PAL behavior did not trigger as expected — trace hooks, instructions, and logic to find the gap. Use when a hook, skill, or automation didn't fire or behaved unexpectedly.
4
+ argument-hint: <what went wrong>
4
5
  ---
5
6
 
6
7
  When the user invokes `/reflect [optional: description of what didn't happen]`:
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: research
3
- description: Multi-agent parallel research — quick/standard/extensive modes with specialized researcher agents for depth, breadth, and verification
3
+ description: Multi-agent parallel research — quick/standard/extensive modes with specialized researcher agents for depth, breadth, and verification. Use when researching a topic, finding information, or investigating something thoroughly.
4
+ argument-hint: <topic or question>
4
5
  ---
5
6
 
6
7
  ## Mode Routing
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  name: review
3
- description: Security-focused code review with severity ratings
3
+ description: Security-focused code review with severity ratings. Use when reviewing code for security issues, vulnerabilities, or OWASP concerns.
4
+ argument-hint: [file or directory]
4
5
  ---
5
6
 
6
7
  When the user invokes /review <file, diff, or PR>:
@@ -1,9 +1,10 @@
1
1
  ---
2
2
  name: summarize
3
- description: Structured summarization of documents, URLs, or conversations
3
+ description: Structured summarization of documents, URLs, or conversations. Use when summarizing content, creating overviews, or distilling key points.
4
+ argument-hint: <document, URL, or topic>
4
5
  ---
5
6
 
6
- When the user invokes /summarize <target>:
7
+ Summarize $ARGUMENTS:
7
8
 
8
9
  1. Fetch or read the target content
9
10
  2. Produce:
@@ -0,0 +1,60 @@
1
+ ---
2
+ name: telos
3
+ description: Personal and project context management. Use when discussing goals, projects, beliefs, challenges, identity, updating telos, life context, what am I working on, adding a project, changing a goal, priorities, what do I believe, current obstacles, mission, or strategies.
4
+ argument-hint: [area to view or update]
5
+ ---
6
+
7
+ Manage the user's TELOS files — the persistent personal context that drives PAL.
8
+
9
+ ## TELOS Files
10
+
11
+ All files live in `~/.agents/PAL/telos/`:
12
+
13
+ | File | Contains |
14
+ |------|----------|
15
+ | `GOALS.md` | Short/medium/long-term goals |
16
+ | `PROJECTS.md` | Active projects, status, priority |
17
+ | `BELIEFS.md` | Core principles and values |
18
+ | `CHALLENGES.md` | Current obstacles |
19
+ | `IDENTITY.md` | AI identity and personality |
20
+ | `MISSION.md` | Purpose and direction |
21
+ | `STRATEGIES.md` | Approaches and plans |
22
+ | `IDEAS.md` | Ideas to explore |
23
+ | `LEARNED.md` | Key lessons |
24
+ | `MODELS.md` | Mental models |
25
+ | `NARRATIVES.md` | Narrative context |
26
+
27
+ ## Reading
28
+
29
+ Read the file directly from `~/.agents/PAL/telos/` when the user asks about any area.
30
+
31
+ ## Updating
32
+
33
+ Use the update tool for all changes. It validates the file, creates a backup, appends content, and logs the change:
34
+
35
+ ```bash
36
+ bun ~/.agents/skills/telos/tools/update-telos.ts <FILE> "<content>" "<description>"
37
+ ```
38
+
39
+ **Example:**
40
+ ```bash
41
+ bun ~/.agents/skills/telos/tools/update-telos.ts PROJECTS.md "| New Project | In progress | High | Description |" "Added New Project"
42
+ ```
43
+
44
+ ## Routing
45
+
46
+ | Intent | Action |
47
+ |--------|--------|
48
+ | "what am I working on", "my projects", "priorities" | Read `PROJECTS.md`, summarize |
49
+ | "my goals", "what are my goals" | Read `GOALS.md`, present current state |
50
+ | "update goals/projects/beliefs/challenges" | Read the target file, discuss changes with user, then run update tool |
51
+ | "add a project", "new project" | Read `PROJECTS.md`, confirm with user, run update tool |
52
+ | "what do I believe", "my principles" | Read `BELIEFS.md` |
53
+ | "current obstacles", "challenges" | Read `CHALLENGES.md` |
54
+ | General "update telos", "telos" | Ask which area to review/update |
55
+
56
+ ## Rules
57
+
58
+ - **Always read the file first** before making changes — match the existing format exactly
59
+ - **Confirm changes** with the user before running the update tool
60
+ - **Always use the tool** for writes — never edit TELOS files directly
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env bun
2
+ /**
3
+ * UpdateTelos — Validate, backup, update, and log changes to TELOS files.
4
+ *
5
+ * Usage:
6
+ * bun update-telos.ts <file> "<content>" "<description>"
7
+ *
8
+ * - Validates the filename against the known TELOS files
9
+ * - Creates a timestamped backup before modifying
10
+ * - Appends content (preserves existing)
11
+ * - Logs the change to updates.md
12
+ */
13
+
14
+ import {
15
+ copyFileSync,
16
+ existsSync,
17
+ mkdirSync,
18
+ readFileSync,
19
+ writeFileSync,
20
+ } from "node:fs";
21
+ import { resolve } from "node:path";
22
+ import { palHome } from "../../../../src/hooks/lib/paths";
23
+
24
+ const TELOS_DIR = resolve(palHome(), "telos");
25
+ const BACKUPS_DIR = resolve(TELOS_DIR, "backups");
26
+ const UPDATES_LOG = resolve(TELOS_DIR, "updates.md");
27
+
28
+ const VALID_FILES = [
29
+ "BELIEFS.md",
30
+ "CHALLENGES.md",
31
+ "GOALS.md",
32
+ "IDEAS.md",
33
+ "IDENTITY.md",
34
+ "LEARNED.md",
35
+ "MISSION.md",
36
+ "MODELS.md",
37
+ "NARRATIVES.md",
38
+ "PROJECTS.md",
39
+ "STRATEGIES.md",
40
+ ];
41
+
42
+ function timestamp(): string {
43
+ const now = new Date();
44
+ const pad = (n: number) => n.toString().padStart(2, "0");
45
+ return `${now.getFullYear()}${pad(now.getMonth() + 1)}${pad(now.getDate())}-${pad(now.getHours())}${pad(now.getMinutes())}${pad(now.getSeconds())}`;
46
+ }
47
+
48
+ function isoDate(): string {
49
+ return new Date().toISOString().replace("T", " ").slice(0, 19);
50
+ }
51
+
52
+ const args = process.argv.slice(2);
53
+ const file = args[0];
54
+ const content = args[1];
55
+ const description = args[2];
56
+
57
+ if (!file || !content || !description) {
58
+ console.error('Usage: bun update-telos.ts <file> "<content>" "<description>"');
59
+ console.error(`\nValid files: ${VALID_FILES.join(", ")}`);
60
+ process.exit(1);
61
+ }
62
+
63
+ if (!VALID_FILES.includes(file)) {
64
+ console.error(`Error: "${file}" is not a valid TELOS file.`);
65
+ console.error(`Valid files: ${VALID_FILES.join(", ")}`);
66
+ process.exit(1);
67
+ }
68
+
69
+ const filePath = resolve(TELOS_DIR, file);
70
+
71
+ // Backup
72
+ mkdirSync(BACKUPS_DIR, { recursive: true });
73
+ if (existsSync(filePath)) {
74
+ const backupName = `${file.replace(".md", "")}-${timestamp()}.md`;
75
+ copyFileSync(filePath, resolve(BACKUPS_DIR, backupName));
76
+ }
77
+
78
+ // Append content
79
+ const existing = existsSync(filePath) ? readFileSync(filePath, "utf-8") : "";
80
+ const separator = existing.trim() ? "\n\n" : "";
81
+ writeFileSync(filePath, `${existing.trimEnd()}${separator}${content.trim()}\n`, "utf-8");
82
+
83
+ // Log change
84
+ const logEntry = `- **${isoDate()}** — \`${file}\`: ${description}`;
85
+ const existingLog = existsSync(UPDATES_LOG)
86
+ ? readFileSync(UPDATES_LOG, "utf-8")
87
+ : "# TELOS Updates\n";
88
+ writeFileSync(UPDATES_LOG, `${existingLog.trimEnd()}\n${logEntry}\n`, "utf-8");
89
+
90
+ console.log(
91
+ JSON.stringify(
92
+ {
93
+ file,
94
+ backed_up: true,
95
+ logged: true,
96
+ description,
97
+ },
98
+ null,
99
+ 2
100
+ )
101
+ );
@@ -0,0 +1,47 @@
1
+ ---
2
+ name: think
3
+ description: Thinking mode router — selects the right analytical approach for a question. Use when thinking through a problem, analyzing deeply, brainstorming ideas, debating options, decomposing to root cause, challenging assumptions, or exploring from multiple perspectives.
4
+ argument-hint: <question or topic>
5
+ ---
6
+
7
+ Route $ARGUMENTS to the right thinking mode based on intent. Detect the mode from context — do NOT ask.
8
+
9
+ ## Routing
10
+
11
+ | Intent signals | Mode | How to invoke |
12
+ |---------------|------|---------------|
13
+ | decompose, root cause, fundamental, challenge assumptions, first principles | **First Principles** | Use the Skill tool to invoke `first-principles` with $ARGUMENTS |
14
+ | debate, weigh options, multiple viewpoints, perspectives, deliberate | **Council** | Use the Skill tool to invoke `council` with $ARGUMENTS |
15
+ | brainstorm, creative, divergent, ideas, what if, possibilities | **Creative** | Follow the Creative steps below with $ARGUMENTS |
16
+ | think through, analyze, explore deeply, examine from angles | **Deep Analysis** | Follow the Deep Analysis steps below with $ARGUMENTS |
17
+
18
+ If intent is ambiguous, default to **Deep Analysis**.
19
+
20
+ ---
21
+
22
+ ## Creative
23
+
24
+ Divergent ideation — quantity and variety over polish.
25
+
26
+ 1. **Restate the challenge** in one sentence
27
+ 2. **Obvious solutions** — 2-3 conventional approaches (acknowledge, then move past)
28
+ 3. **Wild ideas** — 5-7 unconventional approaches. Mix:
29
+ - Inversion (what if we did the opposite?)
30
+ - Analogy (how does a different domain solve this?)
31
+ - Removal (what if we deleted the constraint?)
32
+ - Combination (what if we merged two approaches?)
33
+ 4. **Diamond pick** — which 1-2 wild ideas have real potential and why
34
+ 5. **Next step** — one concrete action to explore the best idea
35
+
36
+ ---
37
+
38
+ ## Deep Analysis
39
+
40
+ Multi-angle exploration for complex topics.
41
+
42
+ 1. **Frame the question** precisely
43
+ 2. **Technical** — mechanics, constraints, and trade-offs
44
+ 3. **Practical** — what does this look like in practice? What's the effort?
45
+ 4. **Strategic** — how does this fit the bigger picture? What does it enable or block?
46
+ 5. **Tensions** — where do the angles disagree?
47
+ 6. **Synthesis** — what the analysis reveals that wasn't obvious at the surface
@@ -1,45 +1,16 @@
1
1
  # PAL — Portable Agent Layer
2
2
 
3
- You have PA installed. PAL provides persistent personal context across sessions — the user's identity, goals, projects, beliefs, and challenges are stored in TELOS files and loaded into your context automatically. Use this information to tailor your responses to who they are and what they care about.
3
+ You have PAL installed. PAL provides persistent personal context across sessions — the user's identity, goals, projects, beliefs, and challenges are stored in TELOS files and loaded on demand via the `telos` skill.
4
4
 
5
5
  When TELOS is populated, you already know the user. When it's empty, first-run setup is required — follow the setup instructions below.
6
6
 
7
7
  {{SETUP_PROMPT}}
8
- {{TELOS}}
9
- ## Memory
8
+ ## Context Routing
10
9
 
11
- PAL has its own memory system that persists across sessions AND across tools (Claude Code, opencode). Always prefer PAL memory over any tool-native memory system.
10
+ When you need context about any of these topics, read `~/.agents/PAL/CONTEXT_ROUTING.md` for the file path:
12
11
 
13
- ### Where to write
14
-
15
- {{MEMORY_PATHS}}
16
-
17
- ### Format
18
-
19
- - **Wisdom frames**: One `.md` file per domain/topic. Each file contains bullet-point principles the user has validated or you've learned. Append new principles to existing files or create new domain files.
20
- - **Relationship notes**: Daily `.md` file with bullet-point observations about the interaction (tone, preferences, corrections).
21
- - **Session learnings**: One `.md` file per session with a `**Title:**` line summarizing what was learned.
22
- - **Failure captures**: One directory per failure, named `{YYYYMMDD-HHmmss}_{slug}/`, containing a `capture.md` with what went wrong and why.
23
-
24
- ## Work Tracking
25
-
26
- PAL tracks your work across sessions in `memory/state/sessions.json` (auto-captured) and `memory/state/projects.json` (AI-managed).
27
-
28
- ### Projects
29
-
30
- Update `projects.json` via the work-tracking library when:
31
- - **Starting sustained multi-session work** → create a project with objectives and an id (slugified, e.g. "pdf-template-engine")
32
- - **Making a key decision** → add to the project's `decisions` array
33
- - **Completing a milestone** → add to `completed`, remove from `nextSteps`
34
- - **Session ends with open work** → update `nextSteps` and `handoff`
35
- - **Work is done** → set status to "completed"
36
-
37
- Do not create projects for one-off questions or quick fixes.
38
-
39
- ### When to write
40
-
41
- - When the user corrects you or gives feedback → wisdom frame
42
- - When you learn something about how the user prefers to work → relationship note
43
- - When a session produces reusable insights → session learning
44
- - When something fails significantly (rating < 6) → failure capture
45
- - Do NOT write memories about trivial exchanges or things already captured in TELOS.
12
+ - PAL internals
13
+ - The user, their life and work, etc
14
+ - Your own personality and rules
15
+ - Any project referenced, any work, etc.
16
+ - Basically anything that's specialized
@@ -0,0 +1,12 @@
1
+ # Context Routing
2
+
3
+ Load context on-demand by reading the file at the path listed. Only load what the current task requires.
4
+
5
+ ## PAL System
6
+
7
+ | Topic | Path |
8
+ |-------|------|
9
+ | Memory format & guidelines | `~/.agents/PAL/MEMORY_SYSTEM.md` |
10
+ | Work tracking (projects, sessions) | `~/.agents/PAL/WORK_TRACKING.md` |
11
+ | Opinion tracking | `~/.agents/PAL/OPINION_TRACKING.md` |
12
+ | Steering rules | `~/.agents/PAL/STEERING_RULES.md` |
@@ -0,0 +1,26 @@
1
+ # Memory System
2
+
3
+ PAL has its own memory system that persists across sessions AND across tools (Claude Code, opencode). Always prefer PAL memory over any tool-native memory system.
4
+
5
+ ## Where to write
6
+
7
+ - **Wisdom frames**: `~/.agents/PAL/memory/wisdom/frames/` — crystallized principles per domain (loaded every session)
8
+ - **Relationship notes**: `~/.agents/PAL/memory/relationship/YYYY-MM/YYYY-MM-DD.md` — daily interaction observations (loaded every session)
9
+ - **Session learnings**: `~/.agents/PAL/memory/learning/session/YYYY-MM/*.md` — reusable insights from sessions (loaded every session)
10
+ - **Failure captures**: `~/.agents/PAL/memory/learning/failures/YYYY-MM/{timestamp}_{slug}/capture.md` — what went wrong and why
11
+ - **Signals**: `~/.agents/PAL/memory/signals/ratings.jsonl` — append-only rating signal log (do not edit directly)
12
+
13
+ ## Format
14
+
15
+ - **Wisdom frames**: One `.md` file per domain/topic. Each file contains bullet-point principles the user has validated or you've learned. Append new principles to existing files or create new domain files.
16
+ - **Relationship notes**: Daily `.md` file with bullet-point observations about the interaction (tone, preferences, corrections).
17
+ - **Session learnings**: One `.md` file per session with a `**Title:**` line summarizing what was learned.
18
+ - **Failure captures**: One directory per failure, named `{YYYYMMDD-HHmmss}_{slug}/`, containing a `capture.md` with what went wrong and why.
19
+
20
+ ## When to write
21
+
22
+ - When the user corrects you or gives feedback → wisdom frame
23
+ - When you learn something about how the user prefers to work → relationship note
24
+ - When a session produces reusable insights → session learning
25
+ - When something fails significantly (rating < 6) → failure capture
26
+ - Do NOT write memories about trivial exchanges or things already captured in TELOS.
@@ -0,0 +1,3 @@
1
+ # Opinion Tracking
2
+
3
+ PAL tracks confidence-scored opinions about the user. When you notice the user confirming or contradicting a behavioral pattern, update it via `bun run tool:opinion`. Run `bun run tool:opinion -- --help` for full usage and examples. Opinions at ≥85% confidence are automatically injected into every session context.