Skip to content
Draft
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
15 changes: 6 additions & 9 deletions templates/content/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Documents — Agent Guide

Documents is an agent-native editor for docs, comments, media blocks, databases,
sharing, and Notion-connected content; the agent and the UI share the same
actions and application state.
Documents edits pages, comments, media, databases, and connected content.
The agent and UI share actions and application state.

## Skills

Read the relevant skill before deeper work:

- `content` — Markdown/MDX authoring, local folder sources, databases, intake
forms, and Slack/A2A artifact replies.
- `document-editing` — document and comment actions, screen context and IDs,
Expand Down Expand Up @@ -77,6 +74,8 @@ Read the relevant skill before deeper work:
| `pull-document` | Flush live collab state, then read (external edits) |
| `get-blocks-field-word-count` | Count one exact Blocks field; omit `propertyId` for the primary Content body |
| `create-document` | Create a page, optionally under a parent |
| `duplicate-document` | Private same-space root copy of a native Page tree; same retry key replays the receipt |
| `get-document-sidebar-commands` | Current title, write eligibility, and optional authorized Move destinations |
| `resolve-content-landing` | Restore the caller's last authorized page or ensure their private Personal welcome page |
| `edit-document` | Find/replace edit — preferred for small changes |
| `update-document` | Full rewrite of title, content, or description |
Expand All @@ -85,10 +84,8 @@ Read the relevant skill before deeper work:
| `mutate-content-database-block` | Insert, update, upsert, delete, or reorder one supported stable block |
| `migrate-content-database-rows` | Validate/apply/verify; terminal phases use `manage-content-database-migration` |

Every action carries its own schema, and the rest of the app-specific surface
(comments, sharing, databases, Notion, local file sources such as
`remove-local-file-source`) is registered too — use `tool-search` instead of
scanning a table here.
Use `tool-search` for other registered actions and their schemas, including
comments, sharing, databases, Notion, and local file sources.

Sidebar ordering has two meanings. Reordering Pinned or workspace roots moves
the exact `databaseId` + `itemId` membership, never the document. Files Custom
Expand Down
45 changes: 28 additions & 17 deletions templates/content/actions/_database-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,16 +673,37 @@ export async function getContentDatabasePageResponse(
)
).map((document) => document.id)
: null;
const organizationFilesItemFilter =
const organizationFilesDocumentFilter =
database.systemRole === "files" && database.orgId
? sql`exists (
? and(
eq(schema.documents.orgId, database.orgId),
or(
and(
or(
eq(schema.documents.visibility, "org"),
eq(schema.documents.visibility, "public"),
),
or(
eq(schema.documents.hideFromSearch, 0),
isNull(schema.documents.hideFromSearch),
),
),
normalizedUserEmail
? and(
eq(schema.documents.visibility, "private"),
sql`lower(${schema.documents.ownerEmail}) = ${normalizedUserEmail}`,
)
: undefined,
),
)
: undefined;
const organizationFilesItemFilter = organizationFilesDocumentFilter
? sql`exists (
select 1 from ${schema.documents}
where ${schema.documents.id} = ${schema.contentDatabaseItems.documentId}
and ${schema.documents.orgId} = ${database.orgId}
and ${schema.documents.visibility} in ('org', 'public')
and (${schema.documents.hideFromSearch} = 0 or ${schema.documents.hideFromSearch} is null)
and ${organizationFilesDocumentFilter}
)`
: undefined;
: undefined;
const visibleItemFilter = and(
eq(schema.contentDatabaseItems.databaseId, databaseId),
options.documentIds !== undefined
Expand Down Expand Up @@ -938,17 +959,7 @@ export async function getContentDatabasePageResponse(
? inArray(schema.documents.id, workspacesVisibleDocumentIds)
: sql`1 = 0`
: database.systemRole === "files" && database.orgId
? and(
eq(schema.documents.orgId, database.orgId),
or(
eq(schema.documents.visibility, "org"),
eq(schema.documents.visibility, "public"),
),
or(
eq(schema.documents.hideFromSearch, 0),
isNull(schema.documents.hideFromSearch),
),
)
? organizationFilesDocumentFilter
: eq(schema.documents.ownerEmail, database.ownerEmail),
),
)
Expand Down
Loading
Loading