@01.software/init 0.5.1 → 0.7.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 CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  fetchTenantContext,
4
4
  generateClaudeMd,
5
5
  getSkillFiles
6
- } from "./chunk-SRLZ5OIV.js";
6
+ } from "./chunk-T3A5SLEJ.js";
7
7
  export {
8
8
  fetchTenantContext,
9
9
  generateClaudeMd,
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/file-ops.ts
4
+ var envLineRegexCache = /* @__PURE__ */ new Map();
5
+ function envLineRegex(name) {
6
+ let re = envLineRegexCache.get(name);
7
+ if (!re) {
8
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
9
+ re = new RegExp(`^${escaped}=(.*)$`, "m");
10
+ envLineRegexCache.set(name, re);
11
+ }
12
+ return re;
13
+ }
14
+ function readEnvValue(content, name) {
15
+ const m = content.match(envLineRegex(name));
16
+ return m ? m[1] : null;
17
+ }
18
+ function setEnvValue(content, name, value) {
19
+ const re = envLineRegex(name);
20
+ if (re.test(content)) return content.replace(re, `${name}=${value}`);
21
+ const sep = content.length === 0 || content.endsWith("\n") ? "" : "\n";
22
+ return content + sep + `${name}=${value}
23
+ `;
24
+ }
25
+ var OWNED_MCP_TOML_SECTION = "mcp_servers.01software";
26
+ function tomlSectionName(line) {
27
+ const match = line.trim().match(/^\[([^\]]+)\]$/);
28
+ return match ? match[1] : null;
29
+ }
30
+ function isOwnedMcpTomlSection(sectionName) {
31
+ return sectionName === OWNED_MCP_TOML_SECTION || sectionName.startsWith(`${OWNED_MCP_TOML_SECTION}.`);
32
+ }
33
+ function replaceTomlMcpSection(content, newSection) {
34
+ const lines = content.split("\n");
35
+ const kept = [];
36
+ let inOurSection = false;
37
+ for (const line of lines) {
38
+ const sectionName = tomlSectionName(line);
39
+ if (sectionName) {
40
+ inOurSection = isOwnedMcpTomlSection(sectionName);
41
+ if (inOurSection) continue;
42
+ }
43
+ if (!inOurSection) kept.push(line);
44
+ }
45
+ let result = kept.join("\n").replace(/\n+$/, "");
46
+ if (result.length > 0) result += "\n";
47
+ result += newSection.startsWith("\n") ? newSection : "\n" + newSection;
48
+ return result;
49
+ }
50
+
51
+ export {
52
+ readEnvValue,
53
+ setEnvValue,
54
+ replaceTomlMcpSection
55
+ };
56
+ //# sourceMappingURL=chunk-JT3G6B66.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/file-ops.ts"],"sourcesContent":["// Pure helpers for in-place file content manipulation. Kept side-effect-free\n// so they can be unit-tested without touching the filesystem or prompts.\n\n// ── .env merge ───────────────────────────────────────────────────────\n\nconst envLineRegexCache = new Map<string, RegExp>()\n\nfunction envLineRegex(name: string): RegExp {\n let re = envLineRegexCache.get(name)\n if (!re) {\n const escaped = name.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n re = new RegExp(`^${escaped}=(.*)$`, 'm')\n envLineRegexCache.set(name, re)\n }\n return re\n}\n\nexport function readEnvValue(content: string, name: string): string | null {\n const m = content.match(envLineRegex(name))\n return m ? m[1] : null\n}\n\nexport function setEnvValue(content: string, name: string, value: string): string {\n const re = envLineRegex(name)\n if (re.test(content)) return content.replace(re, `${name}=${value}`)\n const sep = content.length === 0 || content.endsWith('\\n') ? '' : '\\n'\n return content + sep + `${name}=${value}\\n`\n}\n\n// ── Codex TOML manipulation ──────────────────────────────────────────\n\nconst OWNED_MCP_TOML_SECTION = 'mcp_servers.01software'\n\nfunction tomlSectionName(line: string): string | null {\n const match = line.trim().match(/^\\[([^\\]]+)\\]$/)\n return match ? match[1] : null\n}\n\nfunction isOwnedMcpTomlSection(sectionName: string): boolean {\n return (\n sectionName === OWNED_MCP_TOML_SECTION ||\n sectionName.startsWith(`${OWNED_MCP_TOML_SECTION}.`)\n )\n}\n\n/** Removes the existing `[mcp_servers.01software]` block and sub-blocks from a\n * TOML document, then appends the provided section. */\nexport function replaceTomlMcpSection(content: string, newSection: string): string {\n const lines = content.split('\\n')\n const kept: string[] = []\n let inOurSection = false\n for (const line of lines) {\n const sectionName = tomlSectionName(line)\n if (sectionName) {\n inOurSection = isOwnedMcpTomlSection(sectionName)\n if (inOurSection) continue\n }\n if (!inOurSection) kept.push(line)\n }\n let result = kept.join('\\n').replace(/\\n+$/, '')\n if (result.length > 0) result += '\\n'\n // newSection already starts with a blank line; keep it that way\n result += newSection.startsWith('\\n') ? newSection : '\\n' + newSection\n return result\n}\n"],"mappings":";;;AAKA,IAAM,oBAAoB,oBAAI,IAAoB;AAElD,SAAS,aAAa,MAAsB;AAC1C,MAAI,KAAK,kBAAkB,IAAI,IAAI;AACnC,MAAI,CAAC,IAAI;AACP,UAAM,UAAU,KAAK,QAAQ,uBAAuB,MAAM;AAC1D,SAAK,IAAI,OAAO,IAAI,OAAO,UAAU,GAAG;AACxC,sBAAkB,IAAI,MAAM,EAAE;AAAA,EAChC;AACA,SAAO;AACT;AAEO,SAAS,aAAa,SAAiB,MAA6B;AACzE,QAAM,IAAI,QAAQ,MAAM,aAAa,IAAI,CAAC;AAC1C,SAAO,IAAI,EAAE,CAAC,IAAI;AACpB;AAEO,SAAS,YAAY,SAAiB,MAAc,OAAuB;AAChF,QAAM,KAAK,aAAa,IAAI;AAC5B,MAAI,GAAG,KAAK,OAAO,EAAG,QAAO,QAAQ,QAAQ,IAAI,GAAG,IAAI,IAAI,KAAK,EAAE;AACnE,QAAM,MAAM,QAAQ,WAAW,KAAK,QAAQ,SAAS,IAAI,IAAI,KAAK;AAClE,SAAO,UAAU,MAAM,GAAG,IAAI,IAAI,KAAK;AAAA;AACzC;AAIA,IAAM,yBAAyB;AAE/B,SAAS,gBAAgB,MAA6B;AACpD,QAAM,QAAQ,KAAK,KAAK,EAAE,MAAM,gBAAgB;AAChD,SAAO,QAAQ,MAAM,CAAC,IAAI;AAC5B;AAEA,SAAS,sBAAsB,aAA8B;AAC3D,SACE,gBAAgB,0BAChB,YAAY,WAAW,GAAG,sBAAsB,GAAG;AAEvD;AAIO,SAAS,sBAAsB,SAAiB,YAA4B;AACjF,QAAM,QAAQ,QAAQ,MAAM,IAAI;AAChC,QAAM,OAAiB,CAAC;AACxB,MAAI,eAAe;AACnB,aAAW,QAAQ,OAAO;AACxB,UAAM,cAAc,gBAAgB,IAAI;AACxC,QAAI,aAAa;AACf,qBAAe,sBAAsB,WAAW;AAChD,UAAI,aAAc;AAAA,IACpB;AACA,QAAI,CAAC,aAAc,MAAK,KAAK,IAAI;AAAA,EACnC;AACA,MAAI,SAAS,KAAK,KAAK,IAAI,EAAE,QAAQ,QAAQ,EAAE;AAC/C,MAAI,OAAO,SAAS,EAAG,WAAU;AAEjC,YAAU,WAAW,WAAW,IAAI,IAAI,aAAa,OAAO;AAC5D,SAAO;AACT;","names":[]}
@@ -0,0 +1,180 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ../auth-contracts/dist/index.js
4
+ var MCP_RESOURCE_AUDIENCE = "https://mcp.01.software/mcp";
5
+
6
+ // src/templates.ts
7
+ function getClientTemplate(env, publishableKeyEnvVar) {
8
+ if (env === "nextjs") {
9
+ return `import { createClient } from '@01.software/sdk'
10
+
11
+ export const client = createClient({
12
+ publishableKey: process.env.${publishableKeyEnvVar}!,
13
+ })
14
+ `;
15
+ }
16
+ if (env === "react-cra") {
17
+ return `import { createClient } from '@01.software/sdk'
18
+
19
+ export const client = createClient({
20
+ publishableKey: process.env.${publishableKeyEnvVar}!,
21
+ })
22
+ `;
23
+ }
24
+ if (env === "vanilla") {
25
+ return `import { createClient } from '@01.software/sdk'
26
+
27
+ // Replace 'YOUR_PUBLISHABLE_KEY' with your actual publishable key from the 01.software console
28
+ export const client = createClient({
29
+ publishableKey: 'YOUR_PUBLISHABLE_KEY',
30
+ })
31
+ `;
32
+ }
33
+ return `import { createClient } from '@01.software/sdk'
34
+
35
+ export const client = createClient({
36
+ publishableKey: import.meta.env.${publishableKeyEnvVar},
37
+ })
38
+ `;
39
+ }
40
+ function getAnalyticsTemplate(env, publishableKeyEnvVar) {
41
+ if (env === "vanilla") {
42
+ return `import { createAnalytics } from '@01.software/sdk/analytics'
43
+
44
+ // Replace 'YOUR_PUBLISHABLE_KEY' with your actual publishable key from the 01.software console
45
+ export const analytics = createAnalytics({
46
+ publishableKey: 'YOUR_PUBLISHABLE_KEY',
47
+ })
48
+ `;
49
+ }
50
+ const publishableKeyExpression = env === "react-vite" ? `import.meta.env.${publishableKeyEnvVar}` : `process.env.${publishableKeyEnvVar}!`;
51
+ return `import { createAnalytics } from '@01.software/sdk/analytics'
52
+
53
+ export const analytics = createAnalytics({
54
+ publishableKey: ${publishableKeyExpression},
55
+ })
56
+ `;
57
+ }
58
+ function getQueryProviderTemplate(env) {
59
+ const useClientDirective = env === "nextjs" ? "'use client'\n\n" : "";
60
+ return `${useClientDirective}import { QueryClientProvider } from '@tanstack/react-query'
61
+ import { client } from './client'
62
+
63
+ export function QueryProvider({ children }: { children: React.ReactNode }) {
64
+ return (
65
+ <QueryClientProvider client={client.queryClient}>
66
+ {children}
67
+ </QueryClientProvider>
68
+ )
69
+ }
70
+ `;
71
+ }
72
+ function getServerTemplate(env, publishableKeyEnvVar, secretKeyEnvVar) {
73
+ if (env === "edge") {
74
+ return `import { createServerClient } from '@01.software/sdk'
75
+
76
+ // Edge runtime: pass your env bindings here
77
+ // e.g. Cloudflare Workers: use env.SOFTWARE_PUBLISHABLE_KEY from the handler context
78
+ // e.g. Vercel Edge: use process.env.${publishableKeyEnvVar}
79
+ export function createEdgeClient(publishableKey: string, secretKey: string) {
80
+ return createServerClient({ publishableKey, secretKey })
81
+ }
82
+ `;
83
+ }
84
+ return `import { createServerClient } from '@01.software/sdk'
85
+
86
+ /**
87
+ * Runtime guard: this module contains secret keys and must never be
88
+ * imported from client-side (browser) code. If the bundler accidentally
89
+ * includes it in a client bundle, this throws at module-evaluation time.
90
+ */
91
+ if (typeof window !== 'undefined') {
92
+ throw new Error(
93
+ 'lib/software/server.ts must not be imported in client-side code \u2014 it contains secret keys.',
94
+ )
95
+ }
96
+
97
+ type ServerClient = ReturnType<typeof createServerClient>
98
+
99
+ let cachedClient: ServerClient | null = null
100
+
101
+ function createConfiguredClient(): ServerClient {
102
+ const publishableKey = process.env.${publishableKeyEnvVar}
103
+ const secretKey = process.env.${secretKeyEnvVar}
104
+
105
+ if (!publishableKey || !secretKey) {
106
+ throw new Error(
107
+ 'Server client requires ${publishableKeyEnvVar} and ${secretKeyEnvVar}.',
108
+ )
109
+ }
110
+
111
+ return createServerClient({ publishableKey, secretKey })
112
+ }
113
+
114
+ export function getServerClient(): ServerClient {
115
+ cachedClient ??= createConfiguredClient()
116
+ return cachedClient
117
+ }
118
+
119
+ /**
120
+ * Lazy Proxy: the underlying client is created only on first property access,
121
+ * so importing this file has no side effects until you actually call it.
122
+ */
123
+ export const serverClient = new Proxy({} as ServerClient, {
124
+ get(_target, prop, receiver) {
125
+ const target = getServerClient()
126
+ const value = Reflect.get(target as object, prop, receiver)
127
+ return typeof value === 'function' ? value.bind(target) : value
128
+ },
129
+ })
130
+ `;
131
+ }
132
+ function getEnvContent(publishableKey, secretKey, publishableKeyEnvVar, secretKeyEnvVar) {
133
+ let content = `
134
+ # 01.software
135
+ ${publishableKeyEnvVar}=${publishableKey}
136
+ `;
137
+ if (secretKeyEnvVar) {
138
+ content += `${secretKeyEnvVar}=${secretKey}
139
+ `;
140
+ }
141
+ return content;
142
+ }
143
+ function getMcpServerEntry(client = "generic") {
144
+ if (client === "windsurf") {
145
+ return {
146
+ serverUrl: MCP_RESOURCE_AUDIENCE
147
+ };
148
+ }
149
+ return {
150
+ type: "http",
151
+ url: MCP_RESOURCE_AUDIENCE
152
+ };
153
+ }
154
+ function getMcpConfigTemplate(client = "generic") {
155
+ return JSON.stringify(
156
+ { mcpServers: { "01software": getMcpServerEntry(client) } },
157
+ null,
158
+ 2
159
+ ) + "\n";
160
+ }
161
+ function getCodexMcpTomlSection() {
162
+ return `
163
+ [mcp_servers.01software]
164
+ url = "${MCP_RESOURCE_AUDIENCE}"
165
+ `;
166
+ }
167
+ var CODEX_MCP_SECTION_MARKER = "[mcp_servers.01software]";
168
+
169
+ export {
170
+ getClientTemplate,
171
+ getAnalyticsTemplate,
172
+ getQueryProviderTemplate,
173
+ getServerTemplate,
174
+ getEnvContent,
175
+ getMcpServerEntry,
176
+ getMcpConfigTemplate,
177
+ getCodexMcpTomlSection,
178
+ CODEX_MCP_SECTION_MARKER
179
+ };
180
+ //# sourceMappingURL=chunk-S3KHPWCE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../auth-contracts/src/index.ts","../src/templates.ts"],"sourcesContent":["export const MCP_RESOURCE_AUDIENCE = 'https://mcp.01.software/mcp'\n\nexport const MCP_OAUTH_ISSUER = 'https://01.software'\n\nexport const MCP_PROTECTED_RESOURCE_METADATA_PATH =\n '/.well-known/oauth-protected-resource/mcp'\n\nexport const MCP_AUTHORIZATION_SERVER_METADATA_PATH =\n '/.well-known/oauth-authorization-server'\n\nexport const MCP_TENANT_CLAIM = 'tenant_id'\n\nexport const MCP_TENANT_ROLE_CLAIM = 'tenant_role'\n\nexport const MCP_SCOPES = {\n read: 'mcp:read',\n write: 'mcp:write',\n} as const\n\nexport const MCP_CONSOLE_SERVICE_AUDIENCE =\n 'https://api.01.software/internal/mcp'\n\nexport const MCP_CONSOLE_SERVICE_SCOPE = 'console:mcp_proxy'\n\nexport const MCP_SERVICE_TOKEN_LIFETIME_SECONDS = 60\n","import type { ProjectEnv } from './detect'\nimport { MCP_RESOURCE_AUDIENCE } from '@01.software/auth-contracts'\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// ── Analytics template (browser) ─────────────────────────────────────\n\nexport function getAnalyticsTemplate(\n env: ProjectEnv,\n publishableKeyEnvVar: string,\n): string {\n if (env === 'vanilla') {\n return `import { createAnalytics } from '@01.software/sdk/analytics'\n\n// Replace 'YOUR_PUBLISHABLE_KEY' with your actual publishable key from the 01.software console\nexport const analytics = createAnalytics({\n publishableKey: 'YOUR_PUBLISHABLE_KEY',\n})\n`\n }\n\n const publishableKeyExpression =\n env === 'react-vite'\n ? `import.meta.env.${publishableKeyEnvVar}`\n : `process.env.${publishableKeyEnvVar}!`\n\n return `import { createAnalytics } from '@01.software/sdk/analytics'\n\nexport const analytics = createAnalytics({\n publishableKey: ${publishableKeyExpression},\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\n/**\n * Runtime guard: this module contains secret keys and must never be\n * imported from client-side (browser) code. If the bundler accidentally\n * includes it in a client bundle, this throws at module-evaluation time.\n */\nif (typeof window !== 'undefined') {\n throw new Error(\n 'lib/software/server.ts must not be imported in client-side code — it contains secret keys.',\n )\n}\n\ntype ServerClient = ReturnType<typeof createServerClient>\n\nlet cachedClient: ServerClient | null = null\n\nfunction createConfiguredClient(): ServerClient {\n const publishableKey = process.env.${publishableKeyEnvVar}\n const secretKey = process.env.${secretKeyEnvVar}\n\n if (!publishableKey || !secretKey) {\n throw new Error(\n 'Server client requires ${publishableKeyEnvVar} and ${secretKeyEnvVar}.',\n )\n }\n\n return createServerClient({ publishableKey, secretKey })\n}\n\nexport function getServerClient(): ServerClient {\n cachedClient ??= createConfiguredClient()\n return cachedClient\n}\n\n/**\n * Lazy Proxy: the underlying client is created only on first property access,\n * so importing this file has no side effects until you actually call it.\n */\nexport const serverClient = new Proxy({} as ServerClient, {\n get(_target, prop, receiver) {\n const target = getServerClient()\n const value = Reflect.get(target as object, prop, receiver)\n return typeof value === 'function' ? value.bind(target) : value\n },\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 type McpJsonClient = 'generic' | 'windsurf'\n\nexport function getMcpServerEntry(client: McpJsonClient = 'generic') {\n if (client === 'windsurf') {\n return {\n serverUrl: MCP_RESOURCE_AUDIENCE,\n }\n }\n\n return {\n type: 'http' as const,\n url: MCP_RESOURCE_AUDIENCE,\n }\n}\n\nexport function getMcpConfigTemplate(client: McpJsonClient = 'generic'): string {\n return (\n JSON.stringify(\n { mcpServers: { '01software': getMcpServerEntry(client) } },\n null,\n 2,\n ) + '\\n'\n )\n}\n\n// ── MCP config (TOML — Codex CLI) ────────────────────────────────────\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(): string {\n return `\n[mcp_servers.01software]\nurl = \"${MCP_RESOURCE_AUDIENCE}\"\n`\n}\n\nexport const CODEX_MCP_SECTION_MARKER = '[mcp_servers.01software]'\n"],"mappings":";;;AAAO,IAAM,wBAAwB;;;ACK9B,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,MAAI,QAAQ,WAAW;AACrB,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT;AAGA,SAAO;AAAA;AAAA;AAAA,oCAG2B,oBAAoB;AAAA;AAAA;AAGxD;AAIO,SAAS,qBACd,KACA,sBACQ;AACR,MAAI,QAAQ,WAAW;AACrB,WAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOT;AAEA,QAAM,2BACJ,QAAQ,eACJ,mBAAmB,oBAAoB,KACvC,eAAe,oBAAoB;AAEzC,SAAO;AAAA;AAAA;AAAA,oBAGW,wBAAwB;AAAA;AAAA;AAG5C;AAIO,SAAS,yBAAyB,KAAyB;AAChE,QAAM,qBAAqB,QAAQ,WAAW,qBAAqB;AAEnE,SAAO,GAAG,kBAAkB;AAAA;AAA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Common setups:
58
58
  - Blog only: hide \`ecommerce\`, \`customers\`, \`videos\` collections
59
- - Store: hide \`posts\`, \`documents\`, \`galleries\`, \`canvas\` collections
59
+ - Store: hide \`articles\`, \`documents\`, \`galleries\`, \`canvas\` collections
60
60
  - Minimal: hide all except the collections you actively use
61
61
 
62
62
  Ask me: "Show current field config" or "Hide ecommerce fields"
@@ -128,7 +128,7 @@ CLI:
128
128
  - \`01 schema list\` \u2014 all available collections
129
129
  - \`01 schema show <collection>\` \u2014 field names, types, required status
130
130
 
131
- Common collections: products, orders, customers, posts, documents, images
131
+ Common collections: products, orders, customers, articles, documents, images
132
132
  Use \`get-tenant-context\` to see which collections are active for this tenant.
133
133
  `
134
134
  }
@@ -160,4 +160,4 @@ export {
160
160
  getSkillFiles,
161
161
  fetchTenantContext
162
162
  };
163
- //# sourceMappingURL=chunk-SRLZ5OIV.js.map
163
+ //# sourceMappingURL=chunk-T3A5SLEJ.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 \\`articles\\`, \\`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, articles, 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"],"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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAgBX;AAAA,EACF;AACF;AAIA,eAAsB,mBACpB,gBACA,WAC+B;AAC/B,MAAI;AACF,UAAM,SAAS,QAAQ,IAAI,oBAAoB;AAE/C,UAAM,MAAM,MAAM,MAAM,GAAG,MAAM,wBAAwB;AAAA,MACvD,SAAS;AAAA,QACP,qBAAqB;AAAA,QACrB,eAAe,UAAU,SAAS;AAAA,MACpC;AAAA,IACF,CAAC;AACD,QAAI,CAAC,IAAI,GAAI,QAAO;AACpB,UAAM,OAAQ,MAAM,IAAI,KAAK;AAC7B,WAAO;AAAA,MACL,YAAY,KAAK,QAAQ,QAAQ;AAAA,MACjC,UAAU,KAAK,YAAY,CAAC;AAAA,MAC5B,aAAa,2BAA2B,KAAK,WAAW;AAAA,IAC1D;AAAA,EACF,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ readEnvValue,
4
+ replaceTomlMcpSection,
5
+ setEnvValue
6
+ } from "./chunk-JT3G6B66.js";
7
+ export {
8
+ readEnvValue,
9
+ replaceTomlMcpSection,
10
+ setEnvValue
11
+ };
12
+ //# sourceMappingURL=file-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}