Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/PULSE/MenuBar/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
HOME_DIR="$HOME"
. "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/hooks/lib/paths.sh"
APP_NAME="PAI Pulse"
APP_DIR="$HOME_DIR/Applications"
APP_DEST="$APP_DIR/$APP_NAME.app"
Expand Down Expand Up @@ -68,7 +69,7 @@ sed "s|__HOME__|$HOME_DIR|g" "$PLIST_SRC" > "$PLIST_DST"
echo " Installed $PLIST_DST"

# Ensure logs directory exists
mkdir -p "$HOME_DIR/.claude/PAI/PULSE/logs"
mkdir -p "$(pai_path PULSE logs)"

launchctl load "$PLIST_DST"
echo " Loaded $PLIST_LABEL"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import { join, extname } from "path"
import { readFileSync, readdirSync, existsSync, realpathSync } from "fs"
import YAML from "yaml"
import { getPaiDir } from "../../../hooks/lib/paths"

// Bun is always the runtime here (Pulse launches this via `bun`). The Next
// tsconfig's DOM+esnext lib doesn't include bun-types, so declare the minimal
Expand Down Expand Up @@ -1646,7 +1647,7 @@ function readDirMdFiles(dir: string): { name: string, content: string, sections:

function handleUserIndexApi(filter: string | null): Response {
try {
const PAI_DIR = process.env.PAI_DIR || join(process.env.HOME || "", ".claude", "PAI")
const PAI_DIR = getPaiDir()
const indexPath = join(PAI_DIR, "Pulse", "state", "user-index.json")
const raw = Bun.file(indexPath)
if (!raw.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import { readFileSync, writeFileSync, existsSync, mkdirSync, appendFileSync } from "fs";
import { join, dirname } from "path";
import { createHash } from "crypto";
import { getPaiDir } from "../../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const STATE_FILE = join(PAI_DIR, "Pulse", "state", "notification-governor.json");
const LOG_FILE = join(PAI_DIR, "MEMORY", "OBSERVABILITY", "notification-governor.jsonl");
const NOTIFY_URL = "http://localhost:31337/notify";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import { readFileSync, existsSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const PULSE_STATE = join(PAI_DIR, "Pulse", "state", "state.json");
const PULSE_TOML = join(PAI_DIR, "Pulse", "PULSE.toml");

Expand Down
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/PULSE/manage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# PAI Pulse — Process Management
# Usage: manage.sh {start|stop|restart|status|install|uninstall}

PULSE_DIR="$HOME/.claude/PAI/PULSE"
. "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/hooks/lib/paths.sh"
PULSE_DIR="$(pai_path PULSE)"
PLIST_NAME="com.pai.pulse"
PLIST_SRC="$PULSE_DIR/$PLIST_NAME.plist"
PLIST_DST="$HOME/Library/LaunchAgents/$PLIST_NAME.plist"
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/PULSE/modules/user-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

import { readFileSync, writeFileSync, statSync, readdirSync, mkdirSync, existsSync, watch } from "fs"
import { join, relative, basename, dirname } from "path"
import { getPaiDir } from "../../../hooks/lib/paths"

const HOME = process.env.HOME ?? ""
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI")
const PAI_DIR = getPaiDir()
const USER_DIR = join(PAI_DIR, "USER")
const STATE_DIR = join(PAI_DIR, "Pulse", "state")
const INDEX_PATH = join(STATE_DIR, "user-index.json")
Expand Down
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/TOOLS/AgentWatchdog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

import { existsSync, readFileSync, statSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const PAI_DIR = process.env.PAI_DIR || join(process.env.HOME!, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const OBS_DIR = join(PAI_DIR, "MEMORY", "OBSERVABILITY");
const ACTIVITY_FILE = join(OBS_DIR, "tool-activity.jsonl");
const STARTS_FILE = join(OBS_DIR, "subagent-starts.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import { readFileSync, writeFileSync, existsSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const QUEUE_FILE = join(PAI_DIR, "USER", "TELOS", "CURRENT_STATE", "proposals.jsonl");
const CURRENT_STATE_DIR = join(PAI_DIR, "USER", "TELOS", "CURRENT_STATE");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
import { parseArgs } from "util";
import * as fs from "fs";
import * as path from "path";
import { getPaiDir } from "../../hooks/lib/paths";

// ============================================================================
// Configuration
// ============================================================================

const HOME = process.env.HOME!;
const PAI_DIR = process.env.PAI_DIR || path.join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const ARCH_SOURCE = path.join(PAI_DIR, "DOCUMENTATION", "PAISystemArchitecture.md");
const SUMMARY_OUTPUT = path.join(PAI_DIR, "DOCUMENTATION", "ARCHITECTURE_SUMMARY.md");
const ALGORITHM_DIR = path.join(PAI_DIR, "ALGORITHM");
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/Arthur.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

import { appendFileSync, existsSync, mkdirSync, readFileSync } from "node:fs";
import { join } from "node:path";
import { homedir } from "node:os";
import YAML from "yaml";
import { getPaiDir } from "../../hooks/lib/paths";

const PAI_DIR = process.env.PAI_DIR ?? join(homedir(), ".claude", "PAI");
const PAI_DIR = getPaiDir();
const POLICIES_PATH = join(PAI_DIR, "USER", "ARTHUR", "policies.yaml");
const GCP_PROJECT = process.env.PAI_GCP_PROJECT ?? "";

Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/ComputeGap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import { readFileSync, existsSync, appendFileSync, mkdirSync } from "fs";
import { join, dirname } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const IDEAL_DIR = join(PAI_DIR, "USER", "TELOS", "IDEAL_STATE");
const CURRENT_DIR = join(PAI_DIR, "USER", "TELOS", "CURRENT_STATE");
const HEALTH_DIR = join(PAI_DIR, "USER", "HEALTH");
Expand Down
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/TOOLS/FailureCapture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
import { existsSync, mkdirSync, readFileSync, writeFileSync, copyFileSync } from 'fs';
import { join, basename } from 'path';
import { inference } from './Inference';
import { getPaiDir } from '../../hooks/lib/paths';

const PAI_DIR = process.env.PAI_DIR || join(process.env.HOME!, '.claude');
const PAI_DIR = getPaiDir();

interface FailureCaptureInput {
transcriptPath: string;
Expand Down
12 changes: 8 additions & 4 deletions Releases/v5.0.0/.claude/PAI/TOOLS/GetCounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@

import { readdirSync, existsSync, statSync } from "fs";
import { join } from "path";
import { getPaiDir, getClaudeDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME!;
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude");
// PAI data (MEMORY, USER) lives under getPaiDir() (~/.claude/PAI);
// skills/ live under Claude home (getClaudeDir(), ~/.claude).
const PAI_DIR = getPaiDir();
const CLAUDE_DIR = getClaudeDir();

interface Counts {
skills: number;
Expand Down Expand Up @@ -101,7 +105,7 @@ function countWorkflowFiles(dir: string): number {
*/
function countSkills(): number {
let count = 0;
const skillsDir = join(PAI_DIR, "skills");
const skillsDir = join(CLAUDE_DIR, "skills");
try {
for (const entry of readdirSync(skillsDir, { withFileTypes: true })) {
// Handle both real directories and symlinks to directories
Expand Down Expand Up @@ -169,10 +173,10 @@ function countRatings(): number {
function getCounts(): Counts {
return {
skills: countSkills(),
workflows: countWorkflowFiles(join(PAI_DIR, "skills")),
workflows: countWorkflowFiles(join(CLAUDE_DIR, "skills")),
hooks: countHooks(),
signals: countFilesRecursive(join(PAI_DIR, "MEMORY/LEARNING"), ".md"),
files: countFilesRecursive(join(PAI_DIR, "PAI/USER")),
files: countFilesRecursive(join(PAI_DIR, "USER")),
work: (() => {
let count = 0;
try {
Expand Down
8 changes: 6 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/IntegrityMaintenance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { readFileSync, existsSync } from 'fs';
import { join, basename, dirname } from 'path';
import { inference } from './Inference';
import { getIdentity } from '../../../.claude/hooks/lib/identity';
import { getClaudeDir } from '../../../.claude/hooks/lib/paths';

// ============================================================================
// Types
Expand Down Expand Up @@ -108,8 +109,11 @@ interface UpdateData {
// Constants
// ============================================================================

const PAI_DIR = process.env.HOME + '/.claude/PAI';
const CREATE_UPDATE_SCRIPT = join(PAI_DIR, 'skills/_PAI/TOOLS/CreateUpdate.ts');
// skills/ lives under Claude home, not PAI data dir. (Pre-existing: the
// referenced skills/_PAI/TOOLS/CreateUpdate.ts does not exist in the tree —
// see NOTE D in the fix spec; flagged separately, not resolved here.)
const CLAUDE_DIR = getClaudeDir();
const CREATE_UPDATE_SCRIPT = join(CLAUDE_DIR, 'skills/_PAI/TOOLS/CreateUpdate.ts');

// Words that indicate generic/bad titles - reject these
const GENERIC_TITLE_PATTERNS = [
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/InterviewIdealState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import { readFileSync, writeFileSync, existsSync, readdirSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const TELOS_DIR = join(PAI_DIR, "USER", "TELOS");
const IDEAL_DIR = join(TELOS_DIR, "IDEAL_STATE");
const STATE_FILE = join(PAI_DIR, "USER", "TELOS", "CURRENT_STATE", "interview-state.json");
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/InterviewScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import { readFileSync, existsSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const USER_DIR = join(PAI_DIR, "USER");
const TELOS_DIR = join(USER_DIR, "TELOS");
const IDEAL_DIR = join(TELOS_DIR, "IDEAL_STATE");
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/KnowledgeGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
import { parseArgs } from "util";
import * as fs from "fs";
import * as path from "path";
import { getPaiDir } from "../../hooks/lib/paths";

// ============================================================================
// Configuration
// ============================================================================

const HOME = process.env.HOME!;
const PAI_DIR = process.env.PAI_DIR || path.join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const KNOWLEDGE_DIR = path.join(PAI_DIR, "MEMORY", "KNOWLEDGE");
const DOMAINS = ["People", "Companies", "Ideas", "Research"];
const SKIP_FILES = new Set(["_index.md", "_schema.md", "_log.md"]);
Expand Down
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/TOOLS/KnowledgeHarvester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
import { parseArgs } from "util";
import * as fs from "fs";
import * as path from "path";
import { getPaiDir } from "../../hooks/lib/paths";

// ============================================================================
// Configuration
// ============================================================================

const HOME = process.env.HOME!;
const PAI_DIR = process.env.PAI_DIR || path.join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const MEMORY_DIR = path.join(PAI_DIR, "MEMORY");
const KNOWLEDGE_DIR = path.join(MEMORY_DIR, "KNOWLEDGE");
const WORK_DIR = path.join(MEMORY_DIR, "WORK");
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/MemoryRetriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ import { parseArgs } from "util";
import * as fs from "fs";
import * as path from "path";
import { spawnSync } from "child_process";
import { getPaiDir } from "../../hooks/lib/paths";

// ============================================================================
// Configuration
// ============================================================================

const HOME = process.env.HOME!;
const PAI_DIR = process.env.PAI_DIR || path.join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const KNOWLEDGE_DIR = path.join(PAI_DIR, "MEMORY", "KNOWLEDGE");
const DOMAINS = ["People", "Companies", "Ideas", "Research"];

Expand Down
3 changes: 2 additions & 1 deletion Releases/v5.0.0/.claude/PAI/TOOLS/MigrateApprove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@

import { readFileSync, writeFileSync, existsSync, appendFileSync, mkdirSync } from "fs";
import { join, dirname } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const QUEUE_FILE = join(PAI_DIR, "MEMORY", "MIGRATION", "migration-proposals.jsonl");
const COMMITTED_LOG = join(PAI_DIR, "MEMORY", "MIGRATION", "committed.jsonl");

Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/MigrateScan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import { readFileSync, writeFileSync, existsSync, readdirSync, statSync, mkdirSync, appendFileSync } from "fs";
import { join, basename, dirname, extname } from "path";
import { randomUUID } from "crypto";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const QUEUE_FILE = join(PAI_DIR, "MEMORY", "MIGRATION", "migration-proposals.jsonl");

type Target =
Expand Down
5 changes: 3 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/OpinionTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@

import { readFileSync, writeFileSync, existsSync, mkdirSync } from 'fs';
import { join } from 'path';
import { getPaiDir } from '../../hooks/lib/paths';

const PAI_DIR = process.env.PAI_DIR || join(process.env.HOME!, '.claude');
const OPINIONS_FILE = join(PAI_DIR, 'PAI/USER/OPINIONS.md');
const PAI_DIR = getPaiDir();
const OPINIONS_FILE = join(PAI_DIR, 'USER/OPINIONS.md');
const RELATIONSHIP_LOG = join(PAI_DIR, 'MEMORY/RELATIONSHIP');

interface Evidence {
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/ProposeCurrentStateEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import { appendFileSync, mkdirSync, existsSync } from "fs";
import { join, dirname } from "path";
import { randomUUID } from "crypto";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const QUEUE_FILE = join(PAI_DIR, "USER", "TELOS", "CURRENT_STATE", "proposals.jsonl");

const ALLOWED_SOURCES = ["lifelog", "calendar", "gmail", "homebridge", "manual", "amazon", "bills"];
Expand Down
4 changes: 2 additions & 2 deletions Releases/v5.0.0/.claude/PAI/TOOLS/Recommend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

import { readFileSync, existsSync } from "fs";
import { join } from "path";
import { getPaiDir } from "../../hooks/lib/paths";

const HOME = process.env.HOME || "";
const PAI_DIR = process.env.PAI_DIR || join(HOME, ".claude", "PAI");
const PAI_DIR = getPaiDir();
const TELOS_DIR = join(PAI_DIR, "USER", "TELOS");
const CURRENT_DIR = join(TELOS_DIR, "CURRENT_STATE");

Expand Down
11 changes: 6 additions & 5 deletions Releases/v5.0.0/.claude/PAI/TOOLS/RelationshipReflect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@
import { readFileSync, writeFileSync, existsSync, readdirSync, mkdirSync } from 'fs';
import { join } from 'path';
import { execSync } from 'child_process';
import { getPaiDir } from '../../hooks/lib/paths';

const PAI_DIR = process.env.PAI_DIR || join(process.env.HOME!, '.claude');
const PAI_DIR = getPaiDir();

interface RelationshipNote {
type: 'W' | 'B' | 'O';
Expand Down Expand Up @@ -265,7 +266,7 @@ function aggregateEvidence(notes: RelationshipNote[], ratings: Array<{ rating: n
*/
function parseOpinions(): Map<string, { confidence: number; section: string }> {
const opinions = new Map<string, { confidence: number; section: string }>();
const opinionsPath = join(PAI_DIR, 'PAI/USER/OPINIONS.md');
const opinionsPath = join(PAI_DIR, 'USER/OPINIONS.md');

if (!existsSync(opinionsPath)) return opinions;

Expand Down Expand Up @@ -297,7 +298,7 @@ function updateOpinionConfidence(
evidence: Map<string, OpinionEvidence>,
dryRun: boolean
): { updated: number; majorShifts: string[] } {
const opinionsPath = join(PAI_DIR, 'PAI/USER/OPINIONS.md');
const opinionsPath = join(PAI_DIR, 'USER/OPINIONS.md');
if (!existsSync(opinionsPath)) return { updated: 0, majorShifts: [] };

let content = readFileSync(opinionsPath, 'utf-8');
Expand Down Expand Up @@ -361,7 +362,7 @@ function escapeRegex(str: string): string {
*/
function checkMilestones(notes: RelationshipNote[]): string[] {
const achieved: string[] = [];
const storyPath = join(PAI_DIR, 'PAI/USER/OUR_STORY.md');
const storyPath = join(PAI_DIR, 'USER/OUR_STORY.md');

if (!existsSync(storyPath)) return achieved;

Expand All @@ -384,7 +385,7 @@ function checkMilestones(notes: RelationshipNote[]): string[] {
* Add milestone to OUR_STORY.md
*/
function addMilestone(description: string, dryRun: boolean): boolean {
const storyPath = join(PAI_DIR, 'PAI/USER/OUR_STORY.md');
const storyPath = join(PAI_DIR, 'USER/OUR_STORY.md');
if (!existsSync(storyPath)) return false;

let content = readFileSync(storyPath, 'utf-8');
Expand Down
Loading