refactor: split repo into docs/ mockup/ app/

- move static mockups from resource/ui to mockup/
- move React app scaffold from resource/ui to app/
- move prome.md + images to docs/
- drop empty resource/jsonfile and resource/
- add root .gitignore
- rewrite README for new layout
- fix paths in mockup/index.html (resource/ui -> mockup, docs/prome.md)
This commit is contained in:
Bkk1234 committed 2026-10-27 00:55:32 +07:00
1 parent 8e87e47017
commit 92a2adad6a
133 files changed
+23416 -50

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
# Data layer — start here
This file plus `drizzle/crud-action-example.ts` is all you need to add a table
and wire CRUD. You do **not** need the `storing-data`, `actions`, or
`agent-native-docs` skills for standard CRUD, and you do **not** need to search
`node_modules` or read any `dist/*.d.ts` to discover the API — the pattern is
already stubbed in the files below.
## The files are already here
| What | Path | State |
| ------------ | -------------------------------------- | ----------------------------- |
| App tables | `drizzle/schema.ts` | Stub — add tables here |
| DB client | `server/db.ts` → `getDb()`, `schema` | Stub — uncomment to enable |
| CRUD pattern | `drizzle/crud-action-example.ts` | Copy into `actions/<name>.ts` |
| Migrate | `pnpm db:generate` → `pnpm db:migrate` | `drizzle.config.ts` ships |
| Actions | `actions/<name>.ts` | You create these |
Open `server/db.ts` and `drizzle/schema.ts` and edit them in place. Do **not**
`find` / `cat` over `node_modules/@agent-native` or `drizzle-orm`, and do **not**
read `dist/*.d.ts` — everything you need is in the two stub files.
## Enable the data layer (once)
`drizzle-orm`, `drizzle-kit`, `drizzle.config.ts`, and the `pnpm db:generate` /
`pnpm db:migrate` scripts already ship — do not re-add them.
1. Add a table to `drizzle/schema.ts` (an example is commented in the file).
2. Uncomment the wiring in `server/db.ts`.
3. Run `pnpm db:generate` to create the migration, then `pnpm db:migrate` to
apply it.
4. Copy the CRUD pattern from `drizzle/crud-action-example.ts` into
`actions/<name>.ts`. **One action per file, default-exported** — the four
`export const ...Example` blocks in that reference each become their own
`actions/<name>.ts` (e.g. `listNotesExample` → `actions/list-notes.ts` with
`export default`); the kebab-case filename is the action name. Don't paste
them into one file as named exports.
## After a batch of schema/action edits
One smoke path (create + list), then one `pnpm typecheck`. See Verification
in `DEVELOPING.md`.
+130
View File
@@ -0,0 +1,130 @@
// @ts-nocheck
/**
* COPY-PASTE REFERENCE — not a live action.
*
* Read with `drizzle/START_HERE.md`. Do not move this file into `actions/` as-is;
* copy the pieces you need into `actions/<name>.ts` after the matching table
* exists in `drizzle/schema.ts` and has been migrated (`pnpm db:generate`, then
* `pnpm db:migrate`).
*
* ONE ACTION PER FILE, DEFAULT-EXPORTED. The four `export const ...Example`
* blocks below are a catalog crammed into one file only so this reference stays
* a single doc. Each becomes its OWN file whose default export IS the action,
* and the kebab-case filename IS the action name. Do NOT copy them into one file
* as named exports — only the default export of a file is registered, so the
* extras never become actions and the file won't match `.generated/action-types.d.ts`.
* listNotesExample -> actions/list-notes.ts (export default defineAction(...))
* createNoteExample -> actions/create-note.ts
* updateNoteExample -> actions/update-note.ts
* deleteNoteExample -> actions/delete-note.ts
*
* Assumes the `notes` and `noteShares` tables from the `drizzle/schema.ts`
* example and `getDb` / `schema` from `server/db.ts` (this starter's layout),
* with `notes` registered as the shareable resource type "note". Notes are
* private to their creator: every read goes through `accessFilter` and every
* write through `assertAccess`, so one user can never see or change another
* user's rows. Read the `sharing` skill before choosing a different model.
*
* Verification after a batch of CRUD work: one smoke call (e.g. create +
* list), then one `pnpm typecheck` — not one CLI test per action.
*/
import { defineAction, fail } from "@agent-native/core/action";
import {
getRequestOrgId,
getRequestUserEmail,
} from "@agent-native/core/server/request-context";
import { accessFilter, assertAccess } from "@agent-native/core/sharing";
import { desc, eq } from "drizzle-orm";
import { z } from "zod";
import { getDb, schema } from "../server/db.js";
export const listNotesExample = defineAction({
description:
"List the notes the caller can see, most recently created first.",
schema: z.object({
limit: z.number().int().min(1).max(200).default(50).describe("Max rows"),
}),
http: { method: "GET" },
run: async ({ limit }) => {
const db = getDb();
return db
.select()
.from(schema.notes)
.where(accessFilter(schema.notes, schema.noteShares))
.orderBy(desc(schema.notes.createdAt))
.limit(limit);
},
});
export const createNoteExample = defineAction({
description: "Create a note owned by the caller.",
schema: z.object({
title: z.string().min(1).describe("Note title"),
body: z.string().optional().describe("Optional note body"),
}),
run: async ({ title, body }) => {
const ownerEmail = getRequestUserEmail();
if (!ownerEmail) fail("Not authenticated", { statusCode: 401 });
const db = getDb();
const [row] = await db
.insert(schema.notes)
.values({
id: crypto.randomUUID(),
title: title.trim(),
body: body?.trim() ?? "",
ownerEmail,
orgId: getRequestOrgId(),
})
.returning();
return row;
},
});
export const updateNoteExample = defineAction({
description: "Update a note's title, body, and/or archived flag.",
schema: z.object({
id: z.string().describe("Note id"),
title: z.string().min(1).optional().describe("New title"),
body: z.string().optional().describe("New body"),
archived: z.boolean().optional().describe("Archived flag"),
}),
run: async ({ id, title, body, archived }) => {
await assertAccess("note", id, "editor");
const db = getDb();
const patch: {
title?: string;
body?: string;
archived?: boolean;
updatedAt: string;
} = { updatedAt: new Date().toISOString() };
if (title !== undefined) patch.title = title.trim();
if (body !== undefined) patch.body = body;
if (archived !== undefined) patch.archived = archived;
const [row] = await db
.update(schema.notes)
.set(patch)
.where(eq(schema.notes.id, id))
.returning();
return row;
},
});
export const deleteNoteExample = defineAction({
description: "Delete a note by id.",
schema: z.object({
id: z.string().describe("Note id"),
}),
http: { method: "DELETE" },
run: async ({ id }) => {
await assertAccess("note", id, "admin");
const db = getDb();
const [row] = await db
.delete(schema.notes)
.where(eq(schema.notes.id, id))
.returning();
return row;
},
});
@@ -0,0 +1,5 @@
{
"version": "7",
"dialect": "postgresql",
"entries": []
}
+27
View File
@@ -0,0 +1,27 @@
// App tables live here, defined with Drizzle's PostgreSQL builders. Local dev
// runs them on PGlite and hosted deploys on Postgres.
//
// After editing this file, run `pnpm db:generate` and restart the dev server
// (see `drizzle/START_HERE.md`). Example table, private to its creator unless
// shared (see the `sharing` skill) — uncomment and adapt:
//
// import { sql } from "drizzle-orm";
// import { boolean, pgTable, text } from "drizzle-orm/pg-core";
// import {
// createSharesTable,
// ownableColumns,
// } from "@agent-native/core/db/schema";
//
// export const notes = pgTable("notes", {
// id: text("id").primaryKey(),
// title: text("title").notNull(),
// body: text("body").notNull().default(""),
// archived: boolean("archived").notNull().default(false),
// createdAt: text("created_at").notNull().default(sql`now()`),
// updatedAt: text("updated_at").notNull().default(sql`now()`),
// ...ownableColumns(),
// });
//
// export const noteShares = createSharesTable("note_shares");
export {};