Skip to content
Merged
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
1 change: 1 addition & 0 deletions CLAUDE.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ FOR: Multi-step, complex, or difficult work. Troubleshooting, debugging, buildin

- **Mandatory output format** — Every response MUST use exactly one of the output formats above (ALGORITHM, NATIVE, or MINIMAL). No freeform output.
- **Response format before questions** — Always complete the current response format output FIRST, then invoke AskUserQuestion at the end.
- **Branch and PR workflow** — Before editing, committing, or pushing repo files, verify the current branch is not `main`. Create a feature branch first and use a PR for review. Do not commit on `main` or push `main` directly unless the user explicitly approves that exact main-branch write in the current turn.

---

Expand Down
2 changes: 1 addition & 1 deletion MEMORY/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# MEMORY - Unified Memory System

**Version:** 7.3.2 (Projects-native architecture, 2026-01-12)
**Version:** 7.4.2 (Projects-native architecture, 2026-01-12)

Full documentation: `~/.claude/skills/PAI/MEMORYSYSTEM.md`

Expand Down
2 changes: 1 addition & 1 deletion PAI/ACTIONS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Actions

> **KAI 7.3.2** — Stable release.
> **KAI 7.4.2** — Stable release.

**Atomic, Composable Units of Work**

Expand Down
2 changes: 1 addition & 1 deletion PAI/ACTIONS/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PAI Actions

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

Atomic, composable units of work. Each action does one thing, takes JSON in, returns JSON out.

Expand Down
2 changes: 2 additions & 0 deletions PAI/AISTEERINGRULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Personal overrides in `USER/AISTEERINGRULES.md`. Full examples in `AISTEERINGRUL

**Check git remote before push.** Run `git remote -v` to verify correct repo.

**Branch and PR workflow (CRITICAL).** Before editing, committing, or pushing repo files, verify the current branch is not `main`. Create a feature branch first and use a PR for review. Do not commit on `main` or push `main` directly unless {PRINCIPAL.NAME} explicitly approves that exact main-branch write in the current turn.

**Don't modify user content without asking.** Never edit quotes or user-written text.

**Minimal scope.** Only change what was asked. No bonus refactoring, no extra cleanup.
Expand Down
2 changes: 1 addition & 1 deletion PAI/CLI.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> **KAI 7.3.2** — Stable release.
> **KAI 7.4.2** — Stable release.

# PAI Command-Line Tools

Expand Down
2 changes: 1 addition & 1 deletion PAI/FLOWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flows

> **KAI 7.3.2** — Stable release.
> **KAI 7.4.2** — Stable release.

**Connecting Sources to Pipelines on a Schedule**

Expand Down
2 changes: 1 addition & 1 deletion PAI/FLOWS/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PAI Flows

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

Flows connect **sources** to **pipelines** on a **schedule**. A flow fetches content from an external source (RSS feed, API, etc.), pipes it through a pipeline of actions, and delivers results to a destination (email, webhook, etc.).

Expand Down
2 changes: 1 addition & 1 deletion PAI/PIPELINES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pipelines

> **KAI 7.3.2** — Stable release.
> **KAI 7.4.2** — Stable release.

**Chaining Actions into Sequential Workflows**

Expand Down
2 changes: 1 addition & 1 deletion PAI/PIPELINES/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PAI Pipelines

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

Pipelines chain actions together. A pipeline is just a list of actions executed in order using the **pipe model** — the output of each action becomes the input of the next.

Expand Down
2 changes: 1 addition & 1 deletion PAI/Tools/Banner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ interface Stats {

function getStats(): Stats {
let name = "PAI";
let paiVersion = "7.3.2";
let paiVersion = "7.4.2";
let algorithmVersion = "3.14.0";
let skills = 0, workflows = 0, hooks = 0, learnings = 0, userFiles = 0;
let connection = "API";
Expand Down
2 changes: 1 addition & 1 deletion PAI/Tools/BuildCLAUDE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function loadVariables(): Record<string, string> {
"{DAIDENTITY.DISPLAYNAME}": settings.daidentity?.displayName || "Assistant",
"{PRINCIPAL.NAME}": settings.principal?.name || "User",
"{PRINCIPAL.TIMEZONE}": settings.principal?.timezone || "UTC",
"{{PAI_VERSION}}": settings.pai?.version || "7.3.2",
"{{PAI_VERSION}}": settings.pai?.version || "7.4.2",
"{{PRODUCT_NAME}}": settings.pai?.productName || "PAI",
"{{ALGO_VERSION}}": algoVersion,
"{{ALGO_PATH}}": `PAI/Algorithm/${algoVersion}.md`,
Expand Down
2 changes: 1 addition & 1 deletion config/preferences.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
// PAI version information
"pai": {
"repoUrl": "github.com/kai-cli/kai",
"version": "7.3.2",
"version": "7.4.2",
"algorithmVersion": "3.14.0",
"productName": "KAI"
},
Expand Down
2 changes: 1 addition & 1 deletion config/spinner-tips.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
"Phase discipline: 7 separate phases. BUILD is not EXECUTE. Never merge or skip.",
"spinnerVerbs in settings.json customizes the animated verb shown while working.",
"The meaning of PAI: magnifying human capabilities through general problem-solving.",
"KAI v.3.2 with Algorithm v3.14.0 \u2014 the latest system architecture.",
"KAI v.4.2 with Algorithm v3.14.0 \u2014 the latest system architecture.",
"The counts section in settings.json tracks skills, signals, files, and sessions.",
"v4.0: contextFiles is empty. Core context in CLAUDE.md (native). Dynamic context via LoadContext.hook.ts.",
"The Splitting Test checks every ISC: and/with test, independent failure, scope words, domain boundaries.",
Expand Down
2 changes: 1 addition & 1 deletion hooks/LoadContext.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ Dynamic context loaded. Core identity, rules, and format are in CLAUDE.md.
} catch { /* non-fatal */ }

flushTty();
console.error('✅ KAI session initialization complete (v7.3.2)');
console.error('✅ KAI session initialization complete (v7.4.2)');
process.exit(0);
} catch (error) {
flushTty();
Expand Down
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
# ═══════════════════════════════════════════════════════════
# KAI Installer v7.3 — Bootstrap Script
# KAI Installer v7.4 — Bootstrap Script
# Requirements: bash, curl
# This script bootstraps the installer by ensuring Bun is
# available, then hands off to the TypeScript installer.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "7.3.2",
"version": "7.4.2",
"productName": "KAI",
"algorithmVersion": "v3.14.0",
"counts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ async function main() {
| Component | Count | Description |
|-----------|-------|-------------|
| Algorithm | <!-- KAI:algorithm-version:begin -->v3.14.0<!-- KAI:algorithm-version:end --> | Core reasoning engine |
| Skills | <!-- KAI:counts:skills:begin -->71<!-- KAI:counts:skills:end --> | Research, security, writing, analysis, etc. |
| Skills | <!-- KAI:counts:skills:begin -->70<!-- KAI:counts:skills:end --> | Research, security, writing, analysis, etc. |
| Hooks | <!-- KAI:counts:hooks:begin -->59<!-- KAI:counts:hooks:end --> | Pre/post tool guards, format enforcement, etc. |
| Agents | <!-- KAI:counts:agents:begin -->20<!-- KAI:counts:agents:end --> | Specialized agent definitions |
| Scripts | 4 | Board, Ralph Loop, deploy |
Expand Down
16 changes: 15 additions & 1 deletion scripts/docs-spec-consistency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,20 @@ export function mergedPrNumbersFromGit(root = repoRoot()): Set<number> {
}
}

function isPublicKaiRepo(root = repoRoot()): boolean {
try {
const remote = execFileSync('git', ['remote', 'get-url', 'origin'], {
cwd: root,
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'ignore'],
timeout: 5000,
});
return remote.includes('kai-cli/kai');
} catch {
return false;
}
}

export function prNumbersFromText(text: string): Set<number> {
const prs = new Set<number>();
for (const match of text.matchAll(/#(\d+)/g)) {
Expand Down Expand Up @@ -173,7 +187,7 @@ export function runDocsSpecConsistency(root = repoRoot()): ConsistencyResult {
}

const findings: Finding[] = [
...checkShippedPrReferences(files, mergedPrNumbersFromGit(root)),
...(isPublicKaiRepo(root) ? [] : checkShippedPrReferences(files, mergedPrNumbersFromGit(root))),
...checkStaleTaskTerminology(files),
];

Expand Down
13 changes: 13 additions & 0 deletions scripts/hooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ if [ -f "$GIT_DIR_PATH/.sync-scrub-in-progress" ]; then
exit 1
fi

# Branch workflow guard: repo changes must happen on feature branches and flow through PRs.
# Override only when the user explicitly approves a main-branch write in the current turn:
# PAI_ALLOW_MAIN_WRITE=1 git commit ...
CURRENT_BRANCH="$(git symbolic-ref --quiet --short HEAD 2>/dev/null || true)"
if [[ "$CURRENT_BRANCH" == "main" && "${PAI_ALLOW_MAIN_WRITE:-}" != "1" ]]; then
echo ""
echo "❌ Commit blocked: current branch is main."
echo " Create a feature branch and open a PR instead."
echo " Explicit one-off override: PAI_ALLOW_MAIN_WRITE=1 git commit ..."
echo ""
exit 1
fi

# Secret patterns (same patterns as SecretScanner.hook.ts + extras for tool output)
PATTERNS=(
# GitHub tokens
Expand Down
17 changes: 17 additions & 0 deletions scripts/hooks/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ fi
# Capture it NOW (before any subshell consumes stdin) so the gate can scan the exact push range.
PUSH_STDIN="$(cat || true)"

# Branch workflow guard: changes should leave local repos through feature branches and PRs.
# Override only when the user explicitly approves a main-branch write in the current turn:
# PAI_ALLOW_MAIN_WRITE=1 git push origin main
if [[ "${PAI_ALLOW_MAIN_WRITE:-}" != "1" ]]; then
while read -r lref _lsha rref _rsha; do
[[ -z "${lref:-}" ]] && continue
if [[ "$lref" == "refs/heads/main" || "$rref" == "refs/heads/main" ]]; then
echo ""
echo "❌ Pre-push BLOCKED: direct main-branch push."
echo " Push a feature branch and open a PR instead."
echo " Explicit one-off override: PAI_ALLOW_MAIN_WRITE=1 git push ..."
echo ""
exit 1
fi
done <<< "$PUSH_STDIN"
fi

echo "── KAI pre-push checks ──"

# ── Compute the push range once (shared by the repo-safety + PII gates) ──────
Expand Down
43 changes: 43 additions & 0 deletions scripts/sync-ci-gate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ function getKaiDir(): string {
return process.env.KAI_DIR || join(process.env.HOME!, 'Projects', 'kai');
}

function isPublicKaiRepo(root: string): boolean {
try {
const remote = execSync('git remote get-url origin', {
cwd: root,
encoding: 'utf-8',
stdio: ['ignore', 'pipe', 'ignore'],
});
return remote.includes('kai-cli/kai');
} catch {
return false;
}
}

// PII patterns loaded from external file (excluded from kai sync to avoid leaking identifiers)
function loadPIIPatterns(paiDir: string): string[] {
const patternsPath = join(paiDir, 'scripts', 'pii-patterns.json');
Expand Down Expand Up @@ -384,6 +397,7 @@ function runDependencyClosureReport(paiDir: string): { errors: string[]; warning
function main() {
const PAI_DIR = getPaiDir();
const KAI_DIR = getKaiDir();
const syncScript = join(PAI_DIR, 'scripts', 'sync-to-kai.sh');

console.log('\n=== Sync CI Gate ===');
console.log(`PAI: ${PAI_DIR}`);
Expand All @@ -394,6 +408,35 @@ function main() {
process.exit(1);
}

if (!existsSync(syncScript) && isPublicKaiRepo(PAI_DIR)) {
info('Public KAI checkout detected; sync-to-kai.sh is intentionally not shipped');
const manifestPath = join(PAI_DIR, 'manifest.json');
const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, 'utf-8')) : null;
if (!manifest?.counts) {
fail('manifest.json missing product counts');
process.exit(1);
}
const actualSkills = execSync(
"find skills -name SKILL.md -not -path '*/.archive/*' | wc -l | tr -d ' '",
{ cwd: PAI_DIR, encoding: 'utf-8' }
).trim();
const actualHooks = execSync(
"find hooks -maxdepth 1 -name '*.hook.ts' | wc -l | tr -d ' '",
{ cwd: PAI_DIR, encoding: 'utf-8' }
).trim();
const actualAgents = execSync(
"find agents -maxdepth 1 -name '*.md' ! -name README.md | wc -l | tr -d ' '",
{ cwd: PAI_DIR, encoding: 'utf-8' }
).trim();
if (String(manifest.counts.skills) !== actualSkills || String(manifest.counts.hooks) !== actualHooks || String(manifest.counts.agents) !== actualAgents) {
fail(`Manifest counts do not match filesystem (${actualSkills} skills, ${actualHooks} hooks, ${actualAgents} agents)`);
process.exit(1);
}
pass(`Public KAI manifest counts match filesystem (${actualSkills} skills, ${actualHooks} hooks, ${actualAgents} agents)`);
console.log('\n✅ Public KAI sync readiness gate skipped private sync checks\n');
process.exit(0);
}

// Step 1: Parse sync rules
info('Parsing sync rules from sync-to-kai.sh');
const excludePaths = parseExcludePaths(PAI_DIR);
Expand Down
32 changes: 32 additions & 0 deletions scripts/version-targets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"version": 1,
"targets": [
{ "file": "manifest.json", "kind": "json-version", "category": "config" },
{ "file": "settings.json", "kind": "settings-pai-version", "category": "config", "optional": true },
{ "file": "config/preferences.jsonc", "kind": "preferences-pai-algo", "category": "config" },
{ "file": "install.sh", "kind": "install-major-minor", "category": "config" },
{ "file": "PAI/Tools/Banner.ts", "kind": "banner-pai-algo-fallback", "category": "fallback" },
{ "file": "PAI/Tools/BuildCLAUDE.ts", "kind": "buildclaude-default-algo", "category": "fallback" },
{ "file": "PAI/Tools/BuildCLAUDE.ts", "kind": "buildclaude-default-pai", "category": "fallback" },
{ "file": "CLAUDE.md", "kind": "h1-kai-version", "category": "docs", "optional": true },
{ "file": "README.md", "kind": "h1-kai-version", "category": "docs" },
{ "file": "README.md", "kind": "readme-algo-inline", "category": "docs" },
{ "file": "docs/WHATS-DIFFERENT.md", "kind": "whats-different-title", "category": "docs" },
{ "file": "docs/WHATS-DIFFERENT.md", "kind": "whats-different-deploying", "category": "docs" },
{ "file": "docs/WHATS-DIFFERENT.md", "kind": "whats-different-table-version", "category": "docs" },
{ "file": "docs/WHATS-DIFFERENT.md", "kind": "whats-different-algo-table", "category": "docs" },
{ "file": "config/spinner-tips.json", "kind": "spinner-tip-pai-algo", "category": "docs" },
{ "file": "hooks/LoadContext.hook.ts", "kind": "loadcontext-init-version", "category": "docs" },
{ "file": "hooks/lib/recovery-block.ts", "kind": "recovery-block-algo", "category": "docs" },
{ "file": "MEMORY/README.md", "kind": "architecture-version-banner", "category": "docs" },
{ "file": "skills/PAI/MEMORYSYSTEM.md", "kind": "architecture-version-banner", "category": "docs" }
],
"discover": [
{
"roots": ["PAI", "skills/PAI"],
"extensions": [".md"],
"kind": "stable-release-banner",
"category": "docs"
}
]
}
2 changes: 1 addition & 1 deletion skills-lock.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": 1,
"generated": "2026-06-26T05:57:39.062Z",
"generated": "2026-06-26T15:21:17.086Z",
"skills": {
"Agents": {
"source": "kai",
Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/ACTIONS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Actions

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

**Atomic, Composable Units of Work**

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/BROWSERAUTOMATION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Browser Automation

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

**Debug-first browser automation with always-on visibility.**

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/CLI.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

# PAI Command-Line Tools

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/DEPLOYMENT.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

# Arbol Deployment Guide

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/FLOWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flows

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

**Connecting Sources to Pipelines on a Schedule**

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/FLOWS/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PAI Flows

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

Flows connect **sources** to **pipelines** on a **schedule**. A flow fetches content from an external source (RSS feed, API, etc.), pipes it through a pipeline of actions, and delivers results to a destination (email, webhook, etc.).

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/MEMORYSYSTEM.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**The unified system memory - what happened, what we learned, what we're working on.**

**Version:** 7.3.2 (Projects-native architecture, 2026-01-12)
**Version:** 7.4.2 (Projects-native architecture, 2026-01-12)
**Location:** `~/.claude/MEMORY/`

---
Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/PIPELINES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pipelines

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

**Orchestrating Sequences of Actions with Verification Gates**

Expand Down
2 changes: 1 addition & 1 deletion skills/PAI/PIPELINES/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# PAI Pipelines

> **KAI 7.1.0** — Stable release.
> **KAI 7.4.2** — Stable release.

Pipelines chain actions together. A pipeline is just a list of actions executed in order using the **pipe model** — the output of each action becomes the input of the next.

Expand Down
Loading
Loading