Skip to content

Commit 5b69bff

Browse files
authored
Merge pull request #920 from SonicJs-Org/v3
feat: merge v3 document model architecture into main
2 parents e679682 + 9286bb4 commit 5b69bff

710 files changed

Lines changed: 45937 additions & 184526 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/settings.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"hooks": {
3-
"userPromptSubmitHook": {
4-
"command": "echo '\n\n---\n\n📋 TESTING REMINDER: After completing this task, create and run E2E tests to verify the changes work correctly. Tests should go in tests/e2e/ using Playwright.\n\n---\n'",
5-
"description": "Remind Claude to create E2E tests for all changes"
6-
}
3+
"UserPromptSubmit": [
4+
{
5+
"hooks": [
6+
{
7+
"type": "command",
8+
"command": "echo '\n\n---\n\n📋 TESTING REMINDER: After completing this task, create and run E2E tests to verify the changes work correctly. Tests should go in tests/e2e/ using Playwright.\n\n---\n'"
9+
}
10+
]
11+
}
12+
]
713
}
814
}

.codegraph/.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CodeGraph data files
2+
# These are local to each machine and should not be committed
3+
4+
# Database
5+
*.db
6+
*.db-wal
7+
*.db-shm
8+
9+
# Cache
10+
cache/
11+
12+
# Logs
13+
*.log
14+
15+
# Hook markers
16+
.dirty

.github/workflows/pr-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
pull_request_target:
55
branches:
66
- main
7+
- v3
78
push:
89
branches:
910
- main
11+
- v3
1012

1113
jobs:
1214
# Authorization job - gates fork PRs behind environment approval
@@ -45,10 +47,8 @@ jobs:
4547
- name: Install dependencies
4648
run: npm ci
4749

48-
# TODO: Re-enable type checking after fixing remaining TypeScript errors
49-
# Tracked in follow-up issue
50-
# - name: Type check
51-
# run: npm run type-check
50+
- name: Type check
51+
run: npm run type-check
5252

5353
- name: Run unit tests with coverage
5454
run: npm run test:cov

.github/workflows/publish.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Publish to npm
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
inputs:
8+
dry_run:
9+
description: 'Dry run (npm publish --dry-run)'
10+
required: false
11+
default: false
12+
type: boolean
13+
14+
jobs:
15+
publish:
16+
name: Build and Publish
17+
runs-on: ubuntu-latest
18+
permissions:
19+
contents: read
20+
id-token: write
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
cache: 'npm'
30+
registry-url: 'https://registry.npmjs.org/'
31+
32+
- name: Install dependencies
33+
run: npm ci
34+
35+
- name: Build core
36+
run: npm run build:core
37+
38+
- name: Type check
39+
run: npm run type-check
40+
41+
- name: Publish @sonicjs-cms/core
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
run: |
45+
if [ "${{ inputs.dry_run }}" = "true" ]; then
46+
npm publish --workspace=@sonicjs-cms/core --provenance --access public --dry-run
47+
else
48+
npm publish --workspace=@sonicjs-cms/core --provenance --access public
49+
fi
50+
51+
- name: Publish create-sonicjs
52+
env:
53+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54+
run: |
55+
if [ "${{ inputs.dry_run }}" = "true" ]; then
56+
npm publish --workspace=create-sonicjs --provenance --access public --dry-run
57+
else
58+
npm publish --workspace=create-sonicjs --provenance --access public
59+
fi

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ node_modules/
66
# Production builds
77
/dist
88
/build
9+
# Package dist artifacts — generated by build, never committed
10+
packages/*/dist/
11+
packages/*/build
912

1013
# Development
1114
.wrangler/
@@ -82,4 +85,7 @@ coverage/
8285
test-install/my-sonicjs-app/node_modules/
8386
test-install/my-sonicjs-app/.wrangler/
8487
test-install/my-sonicjs-app/.dev.vars
85-
test-install/my-sonicjs-app/package-lock.json
88+
test-install/my-sonicjs-app/package-lock.json
89+
90+
# Codegraph index (local, auto-generated)
91+
.codegraph/

.husky/pre-commit

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ npm run lint --workspace=@sonicjs-cms/core
33

44
echo "Running type checks..."
55
npm run type-check
6-
7-
echo "Running unit tests..."
8-
npm test

AGENTS.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22

33
These instructions mirror the workflow Claude Code already follows in Conductor so every coding agent behaves consistently.
44

5+
## Token-Efficient Tooling (use FIRST, before grep/Read sprees)
6+
7+
This repo is indexed by **codegraph** (684 files, 5693 nodes). Use it as the default code-lookup tool. Hook also rewrites shell commands via **rtk** for 60-90% bash savings. Default response mode is **caveman** for terse output.
8+
9+
### Decision tree — code exploration
10+
11+
| Intent | Tool | Why |
12+
|--------|------|-----|
13+
| "How does X work / where does X live / trace flow X→Y" | `mcp__codegraph__codegraph_explore` | ONE call returns verbatim source grouped by file. Replaces many Read/Grep. |
14+
| "Just the location of symbol named X" | `mcp__codegraph__codegraph_search` | Cheapest — name + path only. |
15+
| "What calls this / what does this call / blast radius" | `codegraph_callers` / `codegraph_callees` / `codegraph_impact` | Edges already indexed; grep can't follow dynamic dispatch. |
16+
| Pinpoint known file edit | `Read` + `Edit` | Codegraph not needed for known path. |
17+
| Truly open-ended cross-cutting search | `Agent` w/ `Explore` or `cavecrew-investigator` | Compressed output, protects main context. |
18+
19+
**Rule:** Before any 3+ Grep/Read combo for "where is X", call `codegraph_explore` first. Treat codegraph as a pre-built index — don't re-run searches it already answers.
20+
21+
### rtk (Rust Token Killer)
22+
23+
- Bash commands auto-rewritten by hook — transparent, 0 overhead. No action needed.
24+
- `rtk gain` to audit savings; `rtk discover` to find missed opportunities.
25+
- Don't bypass rtk with raw shell unless debugging.
26+
27+
### caveman mode
28+
29+
- Active by default (full). Drops articles/filler. Code blocks, commits, security warnings stay normal.
30+
- Toggle: `/caveman lite|full|ultra`, off via "stop caveman".
31+
32+
### Delegation — cavecrew subagents
33+
34+
Use when scope is bounded AND output would bloat main context:
35+
- `cavecrew-investigator` — read-only locator ("where is X / what calls Y / map this dir"). ~60% smaller tool result vs vanilla Explore.
36+
- `cavecrew-builder` — surgical 1-2 file edit (typo, single-fn rewrite, mechanical rename). Refuses 3+ files.
37+
- `cavecrew-reviewer` — diff/PR review, one line per finding.
38+
39+
Skip cavecrew for: known-path edits, multi-file features, anything codegraph answers in one call.
40+
41+
### Anti-patterns (token waste)
42+
43+
- ❌ Running `grep -r` across the repo when `codegraph_search` would answer.
44+
- ❌ Reading 5+ files to understand a flow — `codegraph_explore` returns the relevant slice.
45+
- ❌ Spawning a subagent just to read one known file.
46+
- ❌ Verbose narration. Caveman mode handles that — keep updates to one sentence.
47+
548
## Project Structure & Stack
649
- Monorepo managed with npm workspaces. Core Hono + Workers code, routes, middleware, templates, plugins, utils, and DB lives in `packages/core/src`.
750
- Shared templates/components: `packages/templates/`. CLI scaffolder: `packages/create-app/`. Helper scripts: `packages/scripts/`.
@@ -26,6 +69,11 @@ These instructions mirror the workflow Claude Code already follows in Conductor
2669
- Playwright E2E: `npm run e2e`, smoke subset via `npm run e2e:smoke`, headed/UI via `npm run e2e:ui`
2770
- Sample-app DB reset: `npm run db:reset` (or `npm run setup:db` inside `my-sonicjs-app`)
2871

72+
### Local secrets (`my-sonicjs-app/.dev.vars`)
73+
- `wrangler dev` reads `my-sonicjs-app/.dev.vars` for local secrets. Auth refuses to initialize without `BETTER_AUTH_SECRET` (>=16 chars); requests to `/auth/*` then return 500 with "BETTER_AUTH_SECRET is missing or too short".
74+
- `npm run workspace` (and `npm run db:reset``setup-worktree-db.sh`) auto-create `.dev.vars` with a fresh `openssl rand -hex 32` secret. Re-runs are idempotent — won't overwrite.
75+
- Manual fix if file is missing: `cd my-sonicjs-app && cp .dev.vars.example .dev.vars` then set `BETTER_AUTH_SECRET="$(openssl rand -hex 32)"`. `.dev.vars` is gitignored — never commit it. For prod/preview use `wrangler secret put BETTER_AUTH_SECRET`.
76+
2977
## Coding Style & Patterns
3078
- TypeScript-first ES modules. Keep exported/public signatures fully typed; lean on Zod validation where applicable.
3179
- Use established folder conventions for routes (`packages/core/src/routes`), templates (`packages/core/src/templates`), plugins (`packages/core/src/plugins`), and Drizzle schema (`packages/core/src/db`).

0 commit comments

Comments
 (0)