@01.software/init 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai-docs.js +12 -0
- package/dist/ai-docs.js.map +1 -0
- package/dist/chunk-OEAQV63E.js +120 -0
- package/dist/chunk-OEAQV63E.js.map +1 -0
- package/dist/chunk-SRLZ5OIV.js +163 -0
- package/dist/chunk-SRLZ5OIV.js.map +1 -0
- package/dist/index.js +187 -348
- package/dist/index.js.map +1 -1
- package/dist/templates.js +22 -0
- package/dist/templates.js.map +1 -0
- package/package.json +2 -1
package/dist/ai-docs.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/templates.ts
|
|
4
|
+
function getClientTemplate(env, publishableKeyEnvVar) {
|
|
5
|
+
if (env === "nextjs") {
|
|
6
|
+
return `import { createClient } from '@01.software/sdk'
|
|
7
|
+
|
|
8
|
+
export const client = createClient({
|
|
9
|
+
publishableKey: process.env.${publishableKeyEnvVar}!,
|
|
10
|
+
})
|
|
11
|
+
`;
|
|
12
|
+
}
|
|
13
|
+
if (env === "react-cra") {
|
|
14
|
+
return `import { createClient } from '@01.software/sdk'
|
|
15
|
+
|
|
16
|
+
export const client = createClient({
|
|
17
|
+
publishableKey: process.env.${publishableKeyEnvVar}!,
|
|
18
|
+
})
|
|
19
|
+
`;
|
|
20
|
+
}
|
|
21
|
+
if (env === "vanilla") {
|
|
22
|
+
return `import { createClient } from '@01.software/sdk'
|
|
23
|
+
|
|
24
|
+
// Replace 'YOUR_PUBLISHABLE_KEY' with your actual publishable key from the 01.software console
|
|
25
|
+
export const client = createClient({
|
|
26
|
+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
|
|
27
|
+
})
|
|
28
|
+
`;
|
|
29
|
+
}
|
|
30
|
+
return `import { createClient } from '@01.software/sdk'
|
|
31
|
+
|
|
32
|
+
export const client = createClient({
|
|
33
|
+
publishableKey: import.meta.env.${publishableKeyEnvVar},
|
|
34
|
+
})
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
function getQueryProviderTemplate(env) {
|
|
38
|
+
const useClientDirective = env === "nextjs" ? "'use client'\n\n" : "";
|
|
39
|
+
return `${useClientDirective}import { QueryClientProvider } from '@tanstack/react-query'
|
|
40
|
+
import { client } from './client'
|
|
41
|
+
|
|
42
|
+
export function QueryProvider({ children }: { children: React.ReactNode }) {
|
|
43
|
+
return (
|
|
44
|
+
<QueryClientProvider client={client.queryClient}>
|
|
45
|
+
{children}
|
|
46
|
+
</QueryClientProvider>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
}
|
|
51
|
+
function getServerTemplate(env, publishableKeyEnvVar, secretKeyEnvVar) {
|
|
52
|
+
if (env === "edge") {
|
|
53
|
+
return `import { createServerClient } from '@01.software/sdk'
|
|
54
|
+
|
|
55
|
+
// Edge runtime: pass your env bindings here
|
|
56
|
+
// e.g. Cloudflare Workers: use env.SOFTWARE_PUBLISHABLE_KEY from the handler context
|
|
57
|
+
// e.g. Vercel Edge: use process.env.${publishableKeyEnvVar}
|
|
58
|
+
export function createEdgeClient(publishableKey: string, secretKey: string) {
|
|
59
|
+
return createServerClient({ publishableKey, secretKey })
|
|
60
|
+
}
|
|
61
|
+
`;
|
|
62
|
+
}
|
|
63
|
+
return `import { createServerClient } from '@01.software/sdk'
|
|
64
|
+
|
|
65
|
+
export const serverClient = createServerClient({
|
|
66
|
+
publishableKey: process.env.${publishableKeyEnvVar}!,
|
|
67
|
+
secretKey: process.env.${secretKeyEnvVar}!,
|
|
68
|
+
})
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
function getEnvContent(publishableKey, secretKey, publishableKeyEnvVar, secretKeyEnvVar) {
|
|
72
|
+
let content = `
|
|
73
|
+
# 01.software
|
|
74
|
+
${publishableKeyEnvVar}=${publishableKey}
|
|
75
|
+
`;
|
|
76
|
+
if (secretKeyEnvVar) {
|
|
77
|
+
content += `${secretKeyEnvVar}=${secretKey}
|
|
78
|
+
`;
|
|
79
|
+
}
|
|
80
|
+
return content;
|
|
81
|
+
}
|
|
82
|
+
function getMcpServerEntry(apiKey) {
|
|
83
|
+
return {
|
|
84
|
+
type: "http",
|
|
85
|
+
url: "https://mcp.01.software/mcp",
|
|
86
|
+
headers: { "x-api-key": apiKey }
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function getMcpConfigTemplate(apiKey) {
|
|
90
|
+
return JSON.stringify(
|
|
91
|
+
{ mcpServers: { "01software": getMcpServerEntry(apiKey) } },
|
|
92
|
+
null,
|
|
93
|
+
2
|
|
94
|
+
) + "\n";
|
|
95
|
+
}
|
|
96
|
+
function escapeTomlString(s) {
|
|
97
|
+
return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
98
|
+
}
|
|
99
|
+
function getCodexMcpTomlSection(apiKey) {
|
|
100
|
+
return `
|
|
101
|
+
[mcp_servers.01software]
|
|
102
|
+
url = "https://mcp.01.software/mcp"
|
|
103
|
+
|
|
104
|
+
[mcp_servers.01software.headers]
|
|
105
|
+
x-api-key = "${escapeTomlString(apiKey)}"
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
var CODEX_MCP_SECTION_MARKER = "[mcp_servers.01software]";
|
|
109
|
+
|
|
110
|
+
export {
|
|
111
|
+
getClientTemplate,
|
|
112
|
+
getQueryProviderTemplate,
|
|
113
|
+
getServerTemplate,
|
|
114
|
+
getEnvContent,
|
|
115
|
+
getMcpServerEntry,
|
|
116
|
+
getMcpConfigTemplate,
|
|
117
|
+
getCodexMcpTomlSection,
|
|
118
|
+
CODEX_MCP_SECTION_MARKER
|
|
119
|
+
};
|
|
120
|
+
//# sourceMappingURL=chunk-OEAQV63E.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/templates.ts"],"sourcesContent":["import type { ProjectEnv } from './detect'\n\n// ── Client template (browser) ────────────────────────────────────────\n\nexport function getClientTemplate(env: ProjectEnv, publishableKeyEnvVar: string): string {\n if (env === 'nextjs') {\n return `import { createClient } from '@01.software/sdk'\n\nexport const client = createClient({\n publishableKey: process.env.${publishableKeyEnvVar}!,\n})\n`\n }\n\n if (env === 'react-cra') {\n return `import { createClient } from '@01.software/sdk'\n\nexport const client = createClient({\n publishableKey: process.env.${publishableKeyEnvVar}!,\n})\n`\n }\n\n if (env === 'vanilla') {\n return `import { createClient } from '@01.software/sdk'\n\n// Replace 'YOUR_PUBLISHABLE_KEY' with your actual publishable key from the 01.software console\nexport const client = createClient({\n publishableKey: 'YOUR_PUBLISHABLE_KEY',\n})\n`\n }\n\n // react-vite (import.meta.env)\n return `import { createClient } from '@01.software/sdk'\n\nexport const client = createClient({\n publishableKey: import.meta.env.${publishableKeyEnvVar},\n})\n`\n}\n\n// ── Query Provider template ──────────────────────────────────────────\n\nexport function getQueryProviderTemplate(env: ProjectEnv): string {\n const useClientDirective = env === 'nextjs' ? \"'use client'\\n\\n\" : ''\n\n return `${useClientDirective}import { QueryClientProvider } from '@tanstack/react-query'\nimport { client } from './client'\n\nexport function QueryProvider({ children }: { children: React.ReactNode }) {\n return (\n <QueryClientProvider client={client.queryClient}>\n {children}\n </QueryClientProvider>\n )\n}\n`\n}\n\n// ── Server template ──────────────────────────────────────────────────\n\nexport function getServerTemplate(\n env: ProjectEnv,\n publishableKeyEnvVar: string,\n secretKeyEnvVar: string,\n): string {\n if (env === 'edge') {\n return `import { createServerClient } from '@01.software/sdk'\n\n// Edge runtime: pass your env bindings here\n// e.g. Cloudflare Workers: use env.SOFTWARE_PUBLISHABLE_KEY from the handler context\n// e.g. Vercel Edge: use process.env.${publishableKeyEnvVar}\nexport function createEdgeClient(publishableKey: string, secretKey: string) {\n return createServerClient({ publishableKey, secretKey })\n}\n`\n }\n\n return `import { createServerClient } from '@01.software/sdk'\n\nexport const serverClient = createServerClient({\n publishableKey: process.env.${publishableKeyEnvVar}!,\n secretKey: process.env.${secretKeyEnvVar}!,\n})\n`\n}\n\n// ── Env file content ─────────────────────────────────────────────────\n\nexport function getEnvContent(\n publishableKey: string,\n secretKey: string,\n publishableKeyEnvVar: string,\n secretKeyEnvVar: string | null,\n): string {\n let content = `\\n# 01.software\\n${publishableKeyEnvVar}=${publishableKey}\\n`\n if (secretKeyEnvVar) {\n content += `${secretKeyEnvVar}=${secretKey}\\n`\n }\n return content\n}\n\n// ── MCP config (JSON) ────────────────────────────────────────────────\n\nexport function getMcpServerEntry(apiKey: string) {\n return {\n type: 'http' as const,\n url: 'https://mcp.01.software/mcp',\n headers: { 'x-api-key': apiKey },\n }\n}\n\nexport function getMcpConfigTemplate(apiKey: string): string {\n return (\n JSON.stringify(\n { mcpServers: { '01software': getMcpServerEntry(apiKey) } },\n null,\n 2,\n ) + '\\n'\n )\n}\n\n// ── MCP config (TOML — Codex CLI) ────────────────────────────────────\n\nfunction escapeTomlString(s: string): string {\n return s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')\n}\n\n/** Codex CLI `[mcp_servers.01software]` block. Idempotent marker: the header\n * line. Intended to be appended to `~/.codex/config.toml`. */\nexport function getCodexMcpTomlSection(apiKey: string): string {\n return `\n[mcp_servers.01software]\nurl = \"https://mcp.01.software/mcp\"\n\n[mcp_servers.01software.headers]\nx-api-key = \"${escapeTomlString(apiKey)}\"\n`\n}\n\nexport const CODEX_MCP_SECTION_MARKER = '[mcp_servers.01software]'\n"],"mappings":";;;AAIO,SAAS,kBAAkB,KAAiB,sBAAsC;AACvF,MAAI,QAAQ,UAAU;AACpB,WAAO;AAAA;AAAA;AAAA,gCAGqB,oBAAoB;AAAA;AAAA;AAAA,EAGlD;AAEA,MAAI,QAAQ,aAAa;AACvB,WAAO;AAAA;AAAA;AAAA,gCAGqB,oBAAoB;AAAA;AAAA;AAAA,EAGlD;AAEA,M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IAAM,2BAA2B;","names":[]}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/ai-docs.ts
|
|
4
|
+
function normalizeActiveCollections(collections) {
|
|
5
|
+
if (Array.isArray(collections?.active)) return collections.active;
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
8
|
+
function generateClaudeMd(ctx) {
|
|
9
|
+
const featuresSection = ctx.features && ctx.features.length > 0 ? ctx.features.map((f) => `- ${f}`).join("\n") : "- See console";
|
|
10
|
+
const collectionsSection = ctx.collections && ctx.collections.length > 0 ? ctx.collections.join(", ") : "Run `01 schema list`";
|
|
11
|
+
return `# 01.software SDK \u2014 ${ctx.tenantName}
|
|
12
|
+
|
|
13
|
+
## Connection
|
|
14
|
+
- Publishable Key: \`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\` (env)
|
|
15
|
+
- Secret Key: \`SOFTWARE_SECRET_KEY\` (env)
|
|
16
|
+
- MCP: \`.mcp.json\`
|
|
17
|
+
|
|
18
|
+
## Active Features
|
|
19
|
+
${featuresSection}
|
|
20
|
+
|
|
21
|
+
## Active Collections
|
|
22
|
+
${collectionsSection}
|
|
23
|
+
|
|
24
|
+
## MCP Quick Reference
|
|
25
|
+
| Tool | Use |
|
|
26
|
+
|------|-----|
|
|
27
|
+
| \`query-collection\` | List/filter documents |
|
|
28
|
+
| \`create-collection\` | Create documents |
|
|
29
|
+
| \`update-field-config\` | Hide unused fields |
|
|
30
|
+
| \`get-tenant-context\` | Show active features & collections |
|
|
31
|
+
|
|
32
|
+
## CLI
|
|
33
|
+
- \`01 query <collection>\` \u2014 query data
|
|
34
|
+
- \`01 schema show <collection>\` \u2014 inspect fields
|
|
35
|
+
- \`01 schema list\` \u2014 list all collections
|
|
36
|
+
|
|
37
|
+
## Initial Setup
|
|
38
|
+
Run \`/01software-field-config\` in Claude Code to configure field visibility for your use case.
|
|
39
|
+
Use \`get-collection-schema\` or \`01 schema show <collection>\` for live field introspection instead of relying on this document as a schema snapshot.
|
|
40
|
+
`;
|
|
41
|
+
}
|
|
42
|
+
function getSkillFiles() {
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
dirName: "01software-field-config",
|
|
46
|
+
content: `---
|
|
47
|
+
name: 01software-field-config
|
|
48
|
+
description: Configure field visibility for this tenant \u2014 hide unused collections and fields via MCP
|
|
49
|
+
disable-model-invocation: true
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
Steps:
|
|
53
|
+
1. Use \`list-configurable-fields\` to see current visibility settings
|
|
54
|
+
2. Identify fields/collections not needed for your use case
|
|
55
|
+
3. Use \`update-field-config\` to hide them
|
|
56
|
+
|
|
57
|
+
Common setups:
|
|
58
|
+
- Blog only: hide \`ecommerce\`, \`customers\`, \`videos\` collections
|
|
59
|
+
- Store: hide \`posts\`, \`documents\`, \`galleries\`, \`canvas\` collections
|
|
60
|
+
- Minimal: hide all except the collections you actively use
|
|
61
|
+
|
|
62
|
+
Ask me: "Show current field config" or "Hide ecommerce fields"
|
|
63
|
+
`
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
dirName: "01software-query",
|
|
67
|
+
content: `---
|
|
68
|
+
name: 01software-query
|
|
69
|
+
description: Query 01.software collections via MCP or CLI with filter, sort, and pagination examples
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
Query collections using the MCP \`query-collection\` tool or CLI.
|
|
73
|
+
|
|
74
|
+
MCP examples:
|
|
75
|
+
- List products: \`query-collection\` with collection="products", limit=10
|
|
76
|
+
- Filter by status: add where={"status":{"equals":"published"}}
|
|
77
|
+
- Sort by date: sort="-createdAt"
|
|
78
|
+
- Paginate: page=2, limit=20
|
|
79
|
+
|
|
80
|
+
CLI examples:
|
|
81
|
+
- \`01 query products --limit 10\`
|
|
82
|
+
- \`01 query orders --where '{"status":{"equals":"paid"}}'\`
|
|
83
|
+
- \`01 schema show products\` \u2014 inspect available fields
|
|
84
|
+
|
|
85
|
+
SDK (server):
|
|
86
|
+
\`\`\`typescript
|
|
87
|
+
const { docs } = await serverClient.collection('products').find({
|
|
88
|
+
where: { status: { equals: 'published' } },
|
|
89
|
+
sort: '-createdAt',
|
|
90
|
+
limit: 10,
|
|
91
|
+
})
|
|
92
|
+
\`\`\`
|
|
93
|
+
`
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
dirName: "01software-order-flow",
|
|
97
|
+
content: `---
|
|
98
|
+
name: 01software-order-flow
|
|
99
|
+
description: Order lifecycle reference \u2014 create, pay, fulfill, and return flows for 01.software
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
Complete order flow from creation to fulfillment.
|
|
103
|
+
|
|
104
|
+
States: pending \u2192 paid \u2192 preparing \u2192 shipped \u2192 delivered \u2192 confirmed
|
|
105
|
+
|
|
106
|
+
1. Create order: \`create-order\` with orderNumber, customerSnapshot, orderProducts, totalAmount
|
|
107
|
+
2. Mark paid: \`update-order\` with status="paid" (after payment gateway confirms)
|
|
108
|
+
3. Fulfill: \`create-fulfillment\` with items and carrier/trackingNumber
|
|
109
|
+
4. Returns: \`create-return\` or \`return-with-refund\` (atomic)
|
|
110
|
+
|
|
111
|
+
Free orders: omit paymentId, totalAmount=0 \u2192 auto-transitions to paid
|
|
112
|
+
|
|
113
|
+
CLI: \`01 order create --help\` for full options
|
|
114
|
+
`
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
dirName: "01software-schema",
|
|
118
|
+
content: `---
|
|
119
|
+
name: 01software-schema
|
|
120
|
+
description: Inspect 01.software collection schemas and available fields via MCP or CLI
|
|
121
|
+
---
|
|
122
|
+
|
|
123
|
+
Inspect collection schemas to understand available fields.
|
|
124
|
+
|
|
125
|
+
MCP: use \`get-collection-schema\` with collection
|
|
126
|
+
|
|
127
|
+
CLI:
|
|
128
|
+
- \`01 schema list\` \u2014 all available collections
|
|
129
|
+
- \`01 schema show <collection>\` \u2014 field names, types, required status
|
|
130
|
+
|
|
131
|
+
Common collections: products, orders, customers, posts, documents, images
|
|
132
|
+
Use \`get-tenant-context\` to see which collections are active for this tenant.
|
|
133
|
+
`
|
|
134
|
+
}
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
async function fetchTenantContext(publishableKey, secretKey) {
|
|
138
|
+
try {
|
|
139
|
+
const apiUrl = process.env.SOFTWARE_API_URL || "https://api.01.software";
|
|
140
|
+
const res = await fetch(`${apiUrl}/api/tenants/context`, {
|
|
141
|
+
headers: {
|
|
142
|
+
"X-Publishable-Key": publishableKey,
|
|
143
|
+
Authorization: `Bearer ${secretKey}`
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
if (!res.ok) return null;
|
|
147
|
+
const data = await res.json();
|
|
148
|
+
return {
|
|
149
|
+
tenantName: data.tenant?.name || "",
|
|
150
|
+
features: data.features || [],
|
|
151
|
+
collections: normalizeActiveCollections(data.collections)
|
|
152
|
+
};
|
|
153
|
+
} catch {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export {
|
|
159
|
+
generateClaudeMd,
|
|
160
|
+
getSkillFiles,
|
|
161
|
+
fetchTenantContext
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=chunk-SRLZ5OIV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ai-docs.ts"],"sourcesContent":["export interface TenantContext {\n tenantName: string\n features?: string[]\n collections?: string[]\n}\n\ninterface TenantContextApiResponse {\n tenant?: { name?: string }\n features?: string[]\n collections?: { active?: string[]; inactive?: string[] }\n}\n\nfunction normalizeActiveCollections(\n collections: TenantContextApiResponse['collections'],\n): string[] {\n if (Array.isArray(collections?.active)) return collections.active\n return []\n}\n\n// ── CLAUDE.md ────────────────────────────────────────────────────────\n\nexport function generateClaudeMd(ctx: TenantContext): string {\n const featuresSection =\n ctx.features && ctx.features.length > 0\n ? ctx.features.map((f) => `- ${f}`).join('\\n')\n : '- See console'\n\n const collectionsSection =\n ctx.collections && ctx.collections.length > 0\n ? ctx.collections.join(', ')\n : 'Run `01 schema list`'\n\n return `# 01.software SDK — ${ctx.tenantName}\n\n## Connection\n- Publishable Key: \\`NEXT_PUBLIC_SOFTWARE_PUBLISHABLE_KEY\\` (env)\n- Secret Key: \\`SOFTWARE_SECRET_KEY\\` (env)\n- MCP: \\`.mcp.json\\`\n\n## Active Features\n${featuresSection}\n\n## Active Collections\n${collectionsSection}\n\n## MCP Quick Reference\n| Tool | Use |\n|------|-----|\n| \\`query-collection\\` | List/filter documents |\n| \\`create-collection\\` | Create documents |\n| \\`update-field-config\\` | Hide unused fields |\n| \\`get-tenant-context\\` | Show active features & collections |\n\n## CLI\n- \\`01 query <collection>\\` — query data\n- \\`01 schema show <collection>\\` — inspect fields\n- \\`01 schema list\\` — list all collections\n\n## Initial Setup\nRun \\`/01software-field-config\\` in Claude Code to configure field visibility for your use case.\nUse \\`get-collection-schema\\` or \\`01 schema show <collection>\\` for live field introspection instead of relying on this document as a schema snapshot.\n`\n}\n\n// ── Skill files ──────────────────────────────────────────────────────\n\nexport function getSkillFiles(): Array<{ dirName: string; content: string }> {\n return [\n {\n dirName: '01software-field-config',\n content: `---\nname: 01software-field-config\ndescription: Configure field visibility for this tenant — hide unused collections and fields via MCP\ndisable-model-invocation: true\n---\n\nSteps:\n1. Use \\`list-configurable-fields\\` to see current visibility settings\n2. Identify fields/collections not needed for your use case\n3. Use \\`update-field-config\\` to hide them\n\nCommon setups:\n- Blog only: hide \\`ecommerce\\`, \\`customers\\`, \\`videos\\` collections\n- Store: hide \\`posts\\`, \\`documents\\`, \\`galleries\\`, \\`canvas\\` collections\n- Minimal: hide all except the collections you actively use\n\nAsk me: \"Show current field config\" or \"Hide ecommerce fields\"\n`,\n },\n {\n dirName: '01software-query',\n content: `---\nname: 01software-query\ndescription: Query 01.software collections via MCP or CLI with filter, sort, and pagination examples\n---\n\nQuery collections using the MCP \\`query-collection\\` tool or CLI.\n\nMCP examples:\n- List products: \\`query-collection\\` with collection=\"products\", limit=10\n- Filter by status: add where={\"status\":{\"equals\":\"published\"}}\n- Sort by date: sort=\"-createdAt\"\n- Paginate: page=2, limit=20\n\nCLI examples:\n- \\`01 query products --limit 10\\`\n- \\`01 query orders --where '{\"status\":{\"equals\":\"paid\"}}'\\`\n- \\`01 schema show products\\` — inspect available fields\n\nSDK (server):\n\\`\\`\\`typescript\nconst { docs } = await serverClient.collection('products').find({\n where: { status: { equals: 'published' } },\n sort: '-createdAt',\n limit: 10,\n})\n\\`\\`\\`\n`,\n },\n {\n dirName: '01software-order-flow',\n content: `---\nname: 01software-order-flow\ndescription: Order lifecycle reference — create, pay, fulfill, and return flows for 01.software\n---\n\nComplete order flow from creation to fulfillment.\n\nStates: pending → paid → preparing → shipped → delivered → confirmed\n\n1. Create order: \\`create-order\\` with orderNumber, customerSnapshot, orderProducts, totalAmount\n2. Mark paid: \\`update-order\\` with status=\"paid\" (after payment gateway confirms)\n3. Fulfill: \\`create-fulfillment\\` with items and carrier/trackingNumber\n4. Returns: \\`create-return\\` or \\`return-with-refund\\` (atomic)\n\nFree orders: omit paymentId, totalAmount=0 → auto-transitions to paid\n\nCLI: \\`01 order create --help\\` for full options\n`,\n },\n {\n dirName: '01software-schema',\n content: `---\nname: 01software-schema\ndescription: Inspect 01.software collection schemas and available fields via MCP or CLI\n---\n\nInspect collection schemas to understand available fields.\n\nMCP: use \\`get-collection-schema\\` with collection\n\nCLI:\n- \\`01 schema list\\` — all available collections\n- \\`01 schema show <collection>\\` — field names, types, required status\n\nCommon collections: products, orders, customers, posts, documents, images\nUse \\`get-tenant-context\\` to see which collections are active for this tenant.\n`,\n },\n ]\n}\n\n// ── Tenant context fetch ─────────────────────────────────────────────\n\nexport async function fetchTenantContext(\n publishableKey: string,\n secretKey: string,\n): Promise<TenantContext | null> {\n try {\n const apiUrl = process.env.SOFTWARE_API_URL || 'https://api.01.software'\n // secretKey is now an opaque sk01_/pat01_ bearer token — send it directly.\n const res = await fetch(`${apiUrl}/api/tenants/context`, {\n headers: {\n 'X-Publishable-Key': publishableKey,\n Authorization: `Bearer ${secretKey}`,\n },\n })\n if (!res.ok) return null\n const data = (await res.json()) as TenantContextApiResponse\n return {\n tenantName: data.tenant?.name || '',\n features: data.features || [],\n collections: normalizeActiveCollections(data.collections),\n }\n } catch {\n return null\n }\n}\n"],"mappings":";;;AAYA,SAAS,2BACP,aACU;AACV,MAAI,MAAM,QAAQ,aAAa,MAAM,EAAG,QAAO,YAAY;AAC3D,SAAO,CAAC;AACV;AAIO,SAAS,iBAAiB,KAA4B;AAC3D,QAAM,kBACJ,IAAI,YAAY,IAAI,SAAS,SAAS,IAClC,IAAI,SAAS,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,EAAE,KAAK,IAAI,IAC3C;AAEN,QAAM,qBACJ,IAAI,eAAe,IAAI,YAAY,SAAS,IACxC,IAAI,YAAY,KAAK,IAAI,IACzB;AAEN,SAAO,4BAAuB,IAAI,UAAU;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQ5C,eAAe;AAAA;AAAA;AAAA,EAGf,kBAAkB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAmBpB;AAIO,SAAS,gBAA6D;AAC3E,SAAO;AAAA,IACL;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAkBX;AAAA,IACA;AAAA,MACE,SAAS;AAAA,MACT,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IA2BX;AAAA,IACA;AAAA,MACE,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