anhedral 0.13.0 → 0.16.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/README.md +23 -229
- package/assets/patches/audit-deps.mjs +12 -2
- package/assets/stack/ai-schema.ts.txt +5 -0
- package/assets/stack/ai.ts.txt +30 -0
- package/assets/stack/api-index.ts.txt +15 -0
- package/assets/stack/auth-features.ts.txt +4 -0
- package/assets/stack/auth-journal.json.txt +13 -0
- package/assets/stack/auth-migration.sql.txt +53 -0
- package/assets/stack/auth-routes.ts.txt +11 -0
- package/assets/stack/auth-schema.ts.txt +64 -0
- package/assets/stack/auth-snapshot.json.txt +346 -0
- package/assets/stack/auth.ts.txt +32 -0
- package/assets/stack/billing-mode.ts.txt +8 -0
- package/assets/stack/billing-schema.ts.txt +11 -0
- package/assets/stack/desktop.rs.txt +21 -0
- package/assets/stack/entitlement-guard.ts.txt +32 -0
- package/assets/stack/entitlements.ts.txt +8 -0
- package/assets/stack/events-schema.ts.txt +12 -0
- package/assets/stack/events.ts.txt +59 -0
- package/assets/stack/mobile-auth.ts.txt +25 -0
- package/assets/stack/mobile-billing.tsx.txt +63 -0
- package/assets/stack/mobile-session.tsx.txt +83 -0
- package/assets/stack/native-button.tsx.txt +108 -0
- package/assets/stack/native-global.css.txt +4 -0
- package/assets/stack/native-lib-utils.ts.txt +5 -0
- package/assets/stack/native-metro.config.js.txt +6 -0
- package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
- package/assets/stack/native-tailwind.config.js.txt +73 -0
- package/assets/stack/native-text.tsx.txt +89 -0
- package/assets/stack/purchases.ts.txt +65 -0
- package/assets/stack/revenuecat.ts.txt +88 -0
- package/assets/stack/rtc-schema.ts.txt +10 -0
- package/assets/stack/rtc.ts.txt +122 -0
- package/assets/stack/security.ts.txt +31 -0
- package/assets/stack/storage.ts.txt +36 -0
- package/assets/stack/stripe.ts.txt +126 -0
- package/assets/stack/web-sign-in.tsx.txt +51 -0
- package/assets/ui/LICENSE.react-native-reusables +21 -0
- package/assets/ui/LICENSE.shadcn +21 -0
- package/assets/ui/UPSTREAM.json +39 -0
- package/assets/ui/catalog.json +891 -0
- package/assets/ui/extensions/registry.json +6 -0
- package/assets/ui/native/_controls.tsx +521 -0
- package/assets/ui/native/_core.tsx +118 -0
- package/assets/ui/native/_data.tsx +200 -0
- package/assets/ui/native/_display.tsx +453 -0
- package/assets/ui/native/_feedback.tsx +242 -0
- package/assets/ui/native/_legacy-dialog.tsx +38 -0
- package/assets/ui/native/_motion.tsx +520 -0
- package/assets/ui/native/_overlay.tsx +402 -0
- package/assets/ui/native/_selection.tsx +366 -0
- package/assets/ui/native/accordion.tsx +1 -0
- package/assets/ui/native/alert-dialog.tsx +11 -0
- package/assets/ui/native/alert.tsx +1 -0
- package/assets/ui/native/aspect-ratio.tsx +1 -0
- package/assets/ui/native/attachment.tsx +8 -0
- package/assets/ui/native/avatar.tsx +8 -0
- package/assets/ui/native/badge.tsx +1 -0
- package/assets/ui/native/breadcrumb.tsx +9 -0
- package/assets/ui/native/bubble.tsx +1 -0
- package/assets/ui/native/button-group.tsx +1 -0
- package/assets/ui/native/button.tsx +86 -0
- package/assets/ui/native/calendar.tsx +170 -0
- package/assets/ui/native/card.tsx +44 -0
- package/assets/ui/native/carousel.tsx +1 -0
- package/assets/ui/native/chart.tsx +193 -0
- package/assets/ui/native/checkbox.tsx +1 -0
- package/assets/ui/native/code-block.tsx +137 -0
- package/assets/ui/native/collapsible.tsx +1 -0
- package/assets/ui/native/combobox.tsx +1 -0
- package/assets/ui/native/command.tsx +11 -0
- package/assets/ui/native/context-menu.tsx +16 -0
- package/assets/ui/native/data-table.tsx +1 -0
- package/assets/ui/native/date-picker.tsx +43 -0
- package/assets/ui/native/dialog.tsx +15 -0
- package/assets/ui/native/direction.tsx +1 -0
- package/assets/ui/native/drawer.tsx +10 -0
- package/assets/ui/native/dropdown-menu.tsx +16 -0
- package/assets/ui/native/empty.tsx +8 -0
- package/assets/ui/native/field.tsx +13 -0
- package/assets/ui/native/hover-card.tsx +1 -0
- package/assets/ui/native/input-group.tsx +8 -0
- package/assets/ui/native/input-otp.tsx +1 -0
- package/assets/ui/native/input.tsx +28 -0
- package/assets/ui/native/item.tsx +12 -0
- package/assets/ui/native/kbd.tsx +1 -0
- package/assets/ui/native/label.tsx +4 -0
- package/assets/ui/native/layout.tsx +26 -0
- package/assets/ui/native/marker.tsx +1 -0
- package/assets/ui/native/menubar.tsx +17 -0
- package/assets/ui/native/message-scroller.tsx +6 -0
- package/assets/ui/native/message.tsx +10 -0
- package/assets/ui/native/native-select.tsx +1 -0
- package/assets/ui/native/navigation-menu.tsx +10 -0
- package/assets/ui/native/pagination.tsx +9 -0
- package/assets/ui/native/popover.tsx +1 -0
- package/assets/ui/native/progress.tsx +1 -0
- package/assets/ui/native/questionnaire.tsx +130 -0
- package/assets/ui/native/radio-group.tsx +1 -0
- package/assets/ui/native/registry.json +1103 -0
- package/assets/ui/native/resizable.tsx +1 -0
- package/assets/ui/native/scroll-area.tsx +1 -0
- package/assets/ui/native/select.tsx +11 -0
- package/assets/ui/native/separator.tsx +1 -0
- package/assets/ui/native/sheet.tsx +10 -0
- package/assets/ui/native/sidebar.tsx +22 -0
- package/assets/ui/native/skeleton.tsx +1 -0
- package/assets/ui/native/slider.tsx +1 -0
- package/assets/ui/native/spinner.tsx +1 -0
- package/assets/ui/native/switch.tsx +1 -0
- package/assets/ui/native/table.tsx +10 -0
- package/assets/ui/native/tabs.tsx +1 -0
- package/assets/ui/native/text.tsx +20 -0
- package/assets/ui/native/textarea.tsx +1 -0
- package/assets/ui/native/theme-switcher.tsx +22 -0
- package/assets/ui/native/toast.tsx +11 -0
- package/assets/ui/native/toggle-group.tsx +1 -0
- package/assets/ui/native/toggle.tsx +1 -0
- package/assets/ui/native/tooltip.tsx +1 -0
- package/assets/ui/native/trace.tsx +20 -0
- package/assets/ui/native/typography.tsx +15 -0
- package/assets/ui/theme-storage.ts +25 -0
- package/assets/ui/theme.tsx +66 -0
- package/assets/ui/web/button.tsx +59 -0
- package/assets/ui/web/input.tsx +21 -0
- package/assets/ui/web/label.tsx +19 -0
- package/dist/bin.js +7 -12
- package/dist/capabilities.d.ts +4 -33
- package/dist/capabilities.js +2 -84
- package/dist/capability-catalog.d.ts +83 -0
- package/dist/capability-catalog.js +121 -0
- package/dist/capability-command.d.ts +3 -0
- package/dist/capability-command.js +188 -0
- package/dist/capability-editor.d.ts +17 -0
- package/dist/capability-editor.js +97 -0
- package/dist/capability-recipes.d.ts +4 -0
- package/dist/capability-recipes.js +520 -0
- package/dist/capability-references.d.ts +4 -0
- package/dist/capability-references.js +7 -0
- package/dist/cli-commands.d.ts +1 -2
- package/dist/cli-commands.js +10 -104
- package/dist/cli-output.d.ts +1 -2
- package/dist/cli-output.js +6 -251
- package/dist/command-schema.js +40 -374
- package/dist/dependencies.d.ts +34 -62
- package/dist/dependencies.js +112 -199
- package/dist/index.d.ts +1 -45
- package/dist/index.js +1 -30
- package/dist/platforms/mobile.js +29 -139
- package/dist/platforms/web.d.ts +3 -0
- package/dist/platforms/web.js +251 -0
- package/dist/project-config.d.ts +2 -13
- package/dist/project-config.js +10 -83
- package/dist/registry/context.js +0 -1
- package/dist/registry/options.js +6 -40
- package/dist/registry/resolve.d.ts +3 -4
- package/dist/registry/resolve.js +18 -108
- package/dist/registry/types.d.ts +1 -7
- package/dist/registry/usage.js +3 -9
- package/dist/runtime-policy.d.ts +0 -2
- package/dist/runtime-policy.js +0 -16
- package/dist/scaffold/backend.d.ts +0 -4
- package/dist/scaffold/backend.js +1 -189
- package/dist/scaffold/bootstrap.d.ts +2 -3
- package/dist/scaffold/bootstrap.js +37 -43
- package/dist/scaffold/compose.js +2 -14
- package/dist/scaffold/database.d.ts +1 -1
- package/dist/scaffold/database.js +19 -126
- package/dist/scaffold/documentation.d.ts +0 -1
- package/dist/scaffold/documentation.js +82 -84
- package/dist/scaffold/expo-runtime.d.ts +2 -2
- package/dist/scaffold/expo-runtime.js +9 -101
- package/dist/scaffold/native-ui.d.ts +2 -0
- package/dist/scaffold/native-ui.js +74 -0
- package/dist/scaffold/stack-documentation.d.ts +0 -1
- package/dist/scaffold/stack-documentation.js +3 -49
- package/dist/scaffold/storage.d.ts +2 -0
- package/dist/scaffold/storage.js +21 -0
- package/dist/scaffold/styling.d.ts +1 -1
- package/dist/scaffold/styling.js +20 -28
- package/dist/scaffold/workspace.js +63 -199
- package/dist/stack-registry.d.ts +2 -58
- package/dist/stack-registry.js +22 -446
- package/dist/standard.js +7 -24
- package/dist/ui-catalog.d.ts +26 -0
- package/dist/ui-catalog.js +31 -0
- package/dist/ui-command.d.ts +3 -0
- package/dist/ui-command.js +219 -0
- package/dist/ui-project.d.ts +22 -0
- package/dist/ui-project.js +110 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/anhedral-stack.md +4 -119
- package/docs/capabilities.md +110 -0
- package/docs/native-ui.md +102 -0
- package/docs/software-factory.md +16 -577
- package/docs/stack-standard.md +11 -307
- package/docs/ui.md +33 -0
- package/docs/verification.md +511 -0
- package/package.json +26 -27
- package/dist/access.d.ts +0 -10
- package/dist/access.js +0 -93
- package/dist/auth-schema-snapshot.d.ts +0 -346
- package/dist/auth-schema-snapshot.js +0 -347
- package/dist/auth-schema.d.ts +0 -1
- package/dist/auth-schema.js +0 -57
- package/dist/capability-contract.d.ts +0 -47
- package/dist/capability-contract.js +0 -168
- package/dist/catalog-model.d.ts +0 -24
- package/dist/catalog-model.js +0 -1
- package/dist/catalog-registration.d.ts +0 -16
- package/dist/catalog-registration.js +0 -22
- package/dist/catalog-snapshot.d.ts +0 -5
- package/dist/catalog-snapshot.js +0 -97
- package/dist/cli-delivery.d.ts +0 -3
- package/dist/cli-delivery.js +0 -172
- package/dist/cloudflare.d.ts +0 -25
- package/dist/cloudflare.js +0 -226
- package/dist/delivery-evidence.d.ts +0 -62
- package/dist/delivery-evidence.js +0 -186
- package/dist/delivery.d.ts +0 -88
- package/dist/delivery.js +0 -570
- package/dist/inspector-model.d.ts +0 -123
- package/dist/inspector-model.js +0 -1
- package/dist/integration-service-readers.d.ts +0 -13
- package/dist/integration-service-readers.js +0 -173
- package/dist/lifecycle-model.d.ts +0 -15
- package/dist/lifecycle-model.js +0 -20
- package/dist/lifecycle.d.ts +0 -11
- package/dist/lifecycle.js +0 -91
- package/dist/management.d.ts +0 -3
- package/dist/management.js +0 -47
- package/dist/mobile-delivery.d.ts +0 -77
- package/dist/mobile-delivery.js +0 -366
- package/dist/neon-service-data.d.ts +0 -8
- package/dist/neon-service-data.js +0 -117
- package/dist/platforms/desktop.d.ts +0 -2
- package/dist/platforms/desktop.js +0 -415
- package/dist/platforms/extension.d.ts +0 -2
- package/dist/platforms/extension.js +0 -328
- package/dist/project-catalog.d.ts +0 -41
- package/dist/project-catalog.js +0 -288
- package/dist/project-inspector.d.ts +0 -4
- package/dist/project-inspector.js +0 -702
- package/dist/project-lifecycle.d.ts +0 -25
- package/dist/project-lifecycle.js +0 -57
- package/dist/project-state.d.ts +0 -49
- package/dist/project-state.js +0 -563
- package/dist/provider-auth.d.ts +0 -41
- package/dist/provider-auth.js +0 -215
- package/dist/provider-readiness.d.ts +0 -30
- package/dist/provider-readiness.js +0 -104
- package/dist/providers/adapters.d.ts +0 -17
- package/dist/providers/adapters.js +0 -278
- package/dist/providers/api.d.ts +0 -29
- package/dist/providers/api.js +0 -253
- package/dist/providers/config.d.ts +0 -15
- package/dist/providers/config.js +0 -182
- package/dist/providers/definitions.d.ts +0 -318
- package/dist/providers/definitions.js +0 -127
- package/dist/providers/provision.d.ts +0 -24
- package/dist/providers/provision.js +0 -76
- package/dist/providers/receipts.d.ts +0 -20
- package/dist/providers/receipts.js +0 -66
- package/dist/providers/recovery-verification.d.ts +0 -7
- package/dist/providers/recovery-verification.js +0 -112
- package/dist/providers/recovery.d.ts +0 -30
- package/dist/providers/recovery.js +0 -34
- package/dist/providers/runtime.d.ts +0 -10
- package/dist/providers/runtime.js +0 -265
- package/dist/providers/schema.d.ts +0 -28
- package/dist/providers/schema.js +0 -49
- package/dist/providers/state.d.ts +0 -55
- package/dist/providers/state.js +0 -289
- package/dist/provision.d.ts +0 -55
- package/dist/provision.js +0 -284
- package/dist/r2-service-data.d.ts +0 -2
- package/dist/r2-service-data.js +0 -136
- package/dist/readiness.d.ts +0 -23
- package/dist/readiness.js +0 -122
- package/dist/registry/add.d.ts +0 -24
- package/dist/registry/add.js +0 -270
- package/dist/registry/bootstrap.d.ts +0 -2
- package/dist/registry/bootstrap.js +0 -14
- package/dist/registry/commands.d.ts +0 -3
- package/dist/registry/commands.js +0 -85
- package/dist/registry/presets.d.ts +0 -4
- package/dist/registry/presets.js +0 -41
- package/dist/registry/preview.d.ts +0 -11
- package/dist/registry/preview.js +0 -91
- package/dist/registry/receipt.d.ts +0 -3
- package/dist/registry/receipt.js +0 -68
- package/dist/repository.d.ts +0 -24
- package/dist/repository.js +0 -96
- package/dist/scaffold/auth.d.ts +0 -3
- package/dist/scaffold/auth.js +0 -151
- package/dist/scaffold/billing-config.d.ts +0 -1
- package/dist/scaffold/billing-config.js +0 -73
- package/dist/scaffold/billing-contracts.d.ts +0 -2
- package/dist/scaffold/billing-contracts.js +0 -48
- package/dist/scaffold/billing-providers.d.ts +0 -1
- package/dist/scaffold/billing-providers.js +0 -249
- package/dist/scaffold/billing-schema.d.ts +0 -1
- package/dist/scaffold/billing-schema.js +0 -34
- package/dist/scaffold/billing-security.d.ts +0 -1
- package/dist/scaffold/billing-security.js +0 -46
- package/dist/scaffold/billing-server.d.ts +0 -1
- package/dist/scaffold/billing-server.js +0 -139
- package/dist/scaffold/billing-store.d.ts +0 -1
- package/dist/scaffold/billing-store.js +0 -72
- package/dist/scaffold/billing.d.ts +0 -2
- package/dist/scaffold/billing.js +0 -216
- package/dist/scaffold/cloudflare-services.d.ts +0 -8
- package/dist/scaffold/cloudflare-services.js +0 -198
- package/dist/scaffold/expo-auth.d.ts +0 -3
- package/dist/scaffold/expo-auth.js +0 -192
- package/dist/scaffold/expo-billing.d.ts +0 -3
- package/dist/scaffold/expo-billing.js +0 -292
- package/dist/scaffold/integrations.d.ts +0 -4
- package/dist/scaffold/integrations.js +0 -12
- package/dist/scaffold/lint.d.ts +0 -4
- package/dist/scaffold/lint.js +0 -56
- package/dist/scaffold/neon-realtime.d.ts +0 -2
- package/dist/scaffold/neon-realtime.js +0 -97
- package/dist/scaffold/services.d.ts +0 -5
- package/dist/scaffold/services.js +0 -108
- package/dist/scaffold/stream.d.ts +0 -2
- package/dist/scaffold/stream.js +0 -114
- package/dist/scaffold/void.d.ts +0 -4
- package/dist/scaffold/void.js +0 -264
- package/dist/scaffold/web.d.ts +0 -2
- package/dist/scaffold/web.js +0 -130
- package/dist/service-deletion.d.ts +0 -29
- package/dist/service-deletion.js +0 -195
- package/dist/service-descriptor.d.ts +0 -10
- package/dist/service-descriptor.js +0 -78
- package/dist/service-model.d.ts +0 -49
- package/dist/service-model.js +0 -8
- package/dist/service-operations.d.ts +0 -29
- package/dist/service-operations.js +0 -78
- package/dist/service-readers.d.ts +0 -8
- package/dist/service-readers.js +0 -247
- package/dist/services-command.d.ts +0 -39
- package/dist/services-command.js +0 -102
- package/dist/ship.d.ts +0 -348
- package/dist/ship.js +0 -239
- package/dist/vercel-project.d.ts +0 -101
- package/dist/vercel-project.js +0 -305
- package/dist/vercel.d.ts +0 -67
- package/dist/vercel.js +0 -581
- package/dist/vinext.d.ts +0 -2
- package/dist/vinext.js +0 -86
- package/dist/void-execution.d.ts +0 -10
- package/dist/void-execution.js +0 -94
- package/dist/void-migrations.d.ts +0 -6
- package/dist/void-migrations.js +0 -110
- package/dist/void-state.d.ts +0 -16
- package/dist/void-state.js +0 -65
- package/dist/void.d.ts +0 -3
- package/dist/void.js +0 -5
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { NATIVE_ESLINT_VERSION } from '../dependencies.js';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { writeReactLintConfig } from './lint.js';
|
|
4
|
-
import { writeFile } from '../util.js';
|
|
5
|
-
import { EXTENSION_DEPENDENCIES } from '../dependencies.js';
|
|
6
|
-
import { childPackageName, htmlText, jsString, markdownHeading } from '../render.js';
|
|
7
|
-
export async function scaffoldWxt({ root, options }) {
|
|
8
|
-
const projectName = options.name;
|
|
9
|
-
const displayName = options.name;
|
|
10
|
-
const dir = path.join(root, 'apps/extension');
|
|
11
|
-
writePackageJson(dir, projectName);
|
|
12
|
-
writeFile(path.join(dir, 'tsconfig.json'), JSON.stringify({
|
|
13
|
-
extends: './.wxt/tsconfig.json',
|
|
14
|
-
compilerOptions: { strict: true, jsx: 'react-jsx', paths: { '@/*': ['./src/*'] } },
|
|
15
|
-
}, null, 2) + '\n');
|
|
16
|
-
writeReactLintConfig(dir);
|
|
17
|
-
writeWxtConfig(dir, displayName);
|
|
18
|
-
writeEnvExample(dir);
|
|
19
|
-
writePostcssConfig(dir);
|
|
20
|
-
writeTailwindConfig(dir);
|
|
21
|
-
writeShadcnConfig(dir);
|
|
22
|
-
writeReadme(dir, displayName);
|
|
23
|
-
writeCnUtil(dir);
|
|
24
|
-
writeButtonComponent(dir);
|
|
25
|
-
writeBackground(dir);
|
|
26
|
-
writeSidepanelEntry(dir);
|
|
27
|
-
writeSidepanelHtml(dir, displayName);
|
|
28
|
-
writeSidepanelApp(dir);
|
|
29
|
-
writeStyles(dir);
|
|
30
|
-
}
|
|
31
|
-
function writePackageJson(dir, projectName) {
|
|
32
|
-
writeFile(path.join(dir, 'package.json'), JSON.stringify({
|
|
33
|
-
name: childPackageName(projectName, 'chrome-ext'),
|
|
34
|
-
version: '0.1.0',
|
|
35
|
-
private: true,
|
|
36
|
-
type: 'module',
|
|
37
|
-
scripts: {
|
|
38
|
-
dev: 'wxt',
|
|
39
|
-
build: 'wxt build',
|
|
40
|
-
postinstall: 'wxt prepare',
|
|
41
|
-
zip: 'wxt zip',
|
|
42
|
-
typecheck: 'tsc --noEmit',
|
|
43
|
-
lint: 'eslint src --max-warnings 0',
|
|
44
|
-
},
|
|
45
|
-
dependencies: {
|
|
46
|
-
...EXTENSION_DEPENDENCIES.dependencies,
|
|
47
|
-
'@workspace/styling': 'workspace:*',
|
|
48
|
-
},
|
|
49
|
-
devDependencies: {
|
|
50
|
-
...EXTENSION_DEPENDENCIES.devDependencies,
|
|
51
|
-
'@workspace/eslint-config': 'workspace:*',
|
|
52
|
-
eslint: NATIVE_ESLINT_VERSION,
|
|
53
|
-
},
|
|
54
|
-
}, null, 2) + '\n');
|
|
55
|
-
}
|
|
56
|
-
function writeWxtConfig(dir, displayName) {
|
|
57
|
-
const nameLiteral = jsString(displayName);
|
|
58
|
-
const descriptionLiteral = jsString(`${displayName} Chrome Extension`);
|
|
59
|
-
const actionTitleLiteral = jsString(`Open ${displayName}`);
|
|
60
|
-
writeFile(path.join(dir, 'wxt.config.ts'), `import { defineConfig } from 'wxt';
|
|
61
|
-
|
|
62
|
-
export default defineConfig({
|
|
63
|
-
srcDir: 'src',
|
|
64
|
-
dev: { server: { port: 3001, strictPort: true } },
|
|
65
|
-
manifest: () => {
|
|
66
|
-
const crxPublicKey = import.meta.env.VITE_CRX_PUBLIC_KEY || '';
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
name: ${nameLiteral},
|
|
70
|
-
description: ${descriptionLiteral},
|
|
71
|
-
version: '0.1.0',
|
|
72
|
-
...(crxPublicKey ? { key: crxPublicKey } : {}),
|
|
73
|
-
minimum_chrome_version: '114',
|
|
74
|
-
permissions: ['activeTab', 'scripting', 'sidePanel'],
|
|
75
|
-
host_permissions: [],
|
|
76
|
-
action: {
|
|
77
|
-
default_title: ${actionTitleLiteral},
|
|
78
|
-
},
|
|
79
|
-
side_panel: {
|
|
80
|
-
default_path: 'sidepanel.html',
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
},
|
|
84
|
-
modules: ['@wxt-dev/module-react'],
|
|
85
|
-
vite: () => ({
|
|
86
|
-
build: {
|
|
87
|
-
chunkSizeWarningLimit: 3000,
|
|
88
|
-
},
|
|
89
|
-
}),
|
|
90
|
-
});
|
|
91
|
-
`);
|
|
92
|
-
}
|
|
93
|
-
function extensionEnvContents() {
|
|
94
|
-
const sections = [];
|
|
95
|
-
sections.push(`# Chrome Extension CRX public key (optional, for stable extension ID)
|
|
96
|
-
VITE_CRX_PUBLIC_KEY=`);
|
|
97
|
-
return `${sections.join('\n\n')}\n`;
|
|
98
|
-
}
|
|
99
|
-
function writeEnvExample(dir) {
|
|
100
|
-
writeFile(path.join(dir, '.env.example'), extensionEnvContents());
|
|
101
|
-
}
|
|
102
|
-
function writePostcssConfig(dir) {
|
|
103
|
-
writeFile(path.join(dir, 'postcss.config.cjs'), `module.exports = {
|
|
104
|
-
plugins: {
|
|
105
|
-
tailwindcss: {},
|
|
106
|
-
autoprefixer: {},
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
`);
|
|
110
|
-
}
|
|
111
|
-
function writeShadcnConfig(dir) {
|
|
112
|
-
writeFile(path.join(dir, 'components.json'), JSON.stringify({
|
|
113
|
-
$schema: 'https://ui.shadcn.com/schema.json',
|
|
114
|
-
style: 'new-york',
|
|
115
|
-
rsc: false,
|
|
116
|
-
tsx: true,
|
|
117
|
-
tailwind: {
|
|
118
|
-
config: '',
|
|
119
|
-
css: 'src/styles/main.css',
|
|
120
|
-
baseColor: 'neutral',
|
|
121
|
-
cssVariables: true,
|
|
122
|
-
prefix: '',
|
|
123
|
-
},
|
|
124
|
-
aliases: {
|
|
125
|
-
components: '@/components',
|
|
126
|
-
utils: '@/lib/utils',
|
|
127
|
-
ui: '@/components/ui',
|
|
128
|
-
lib: '@/lib',
|
|
129
|
-
hooks: '@/hooks',
|
|
130
|
-
},
|
|
131
|
-
iconLibrary: 'lucide',
|
|
132
|
-
}, null, 2) + '\n');
|
|
133
|
-
}
|
|
134
|
-
function writeCnUtil(dir) {
|
|
135
|
-
writeFile(path.join(dir, 'src/lib/utils.ts'), `import { clsx, type ClassValue } from 'clsx';
|
|
136
|
-
import { twMerge } from 'tailwind-merge';
|
|
137
|
-
|
|
138
|
-
export function cn(...inputs: ClassValue[]) {
|
|
139
|
-
return twMerge(clsx(inputs));
|
|
140
|
-
}
|
|
141
|
-
`);
|
|
142
|
-
}
|
|
143
|
-
function writeButtonComponent(dir) {
|
|
144
|
-
writeFile(path.join(dir, 'src/components/ui/button.tsx'), `import * as React from 'react';
|
|
145
|
-
import { cn } from '@/lib/utils';
|
|
146
|
-
|
|
147
|
-
type ButtonVariant = 'default' | 'outline';
|
|
148
|
-
|
|
149
|
-
type ButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
150
|
-
variant?: ButtonVariant;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const variantClasses: Record<ButtonVariant, string> = {
|
|
154
|
-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
|
|
155
|
-
outline: 'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
159
|
-
({ className, variant = 'default', type = 'button', ...props }, ref) => {
|
|
160
|
-
return (
|
|
161
|
-
<button
|
|
162
|
-
ref={ref}
|
|
163
|
-
type={type}
|
|
164
|
-
className={cn(
|
|
165
|
-
'inline-flex h-9 items-center justify-center whitespace-nowrap rounded-md px-4 py-2 text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50',
|
|
166
|
-
variantClasses[variant],
|
|
167
|
-
className,
|
|
168
|
-
)}
|
|
169
|
-
{...props}
|
|
170
|
-
/>
|
|
171
|
-
);
|
|
172
|
-
},
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
Button.displayName = 'Button';
|
|
176
|
-
`);
|
|
177
|
-
}
|
|
178
|
-
function writeTailwindConfig(dir) {
|
|
179
|
-
writeFile(path.join(dir, 'tailwind.config.cjs'), `/** @type {import('tailwindcss').Config} */
|
|
180
|
-
module.exports = {
|
|
181
|
-
content: ['./src/**/*.{ts,tsx,html}'],
|
|
182
|
-
presets: [require('@workspace/styling/tailwind')],
|
|
183
|
-
};
|
|
184
|
-
`);
|
|
185
|
-
}
|
|
186
|
-
function writeReadme(dir, displayName) {
|
|
187
|
-
writeFile(path.join(dir, 'README.md'), `# ${markdownHeading(displayName)} Chrome Extension
|
|
188
|
-
|
|
189
|
-
WXT side-panel extension generated by anhedral.
|
|
190
|
-
|
|
191
|
-
## Development
|
|
192
|
-
|
|
193
|
-
\`\`\`bash
|
|
194
|
-
cp .env.example .env
|
|
195
|
-
pnpm dev
|
|
196
|
-
pnpm build
|
|
197
|
-
pnpm zip
|
|
198
|
-
\`\`\`
|
|
199
|
-
|
|
200
|
-
Run these commands from \`apps/extension\`. Anhedral generates only \`.env.example\`; keep the local \`.env\` file uncommitted. Set \`VITE_CRX_PUBLIC_KEY\` only when you need a stable Chrome extension ID.
|
|
201
|
-
|
|
202
|
-
## Chrome
|
|
203
|
-
|
|
204
|
-
Run \`pnpm build\`, then load \`.output/chrome-mv3\` as an unpacked extension from \`chrome://extensions\`.
|
|
205
|
-
|
|
206
|
-
The extension uses Chrome's Side Panel API. The browser action opens \`sidepanel.html\`, \`wxt.config.ts\` declares the \`sidePanel\` permission and Chrome 114+ minimum version, and active-page reads use a user-triggered \`activeTab\` + \`scripting\` grant instead of persistent site access.
|
|
207
|
-
`);
|
|
208
|
-
}
|
|
209
|
-
function writeBackground(dir) {
|
|
210
|
-
writeFile(path.join(dir, 'src/entrypoints/background.ts'), `type ChromeWithSidePanel = typeof chrome & {
|
|
211
|
-
sidePanel: {
|
|
212
|
-
setPanelBehavior: (behavior: { openPanelOnActionClick: boolean }) => Promise<void>;
|
|
213
|
-
};
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export default defineBackground(() => {
|
|
217
|
-
|
|
218
|
-
// Open the side panel when the extension icon is clicked.
|
|
219
|
-
(chrome as ChromeWithSidePanel).sidePanel
|
|
220
|
-
.setPanelBehavior({ openPanelOnActionClick: true })
|
|
221
|
-
.catch((error) => console.error('Unable to configure the side panel:', error));
|
|
222
|
-
});
|
|
223
|
-
`);
|
|
224
|
-
}
|
|
225
|
-
function writeSidepanelEntry(dir) {
|
|
226
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/main.tsx'), `import * as React from 'react';
|
|
227
|
-
import { createRoot } from 'react-dom/client';
|
|
228
|
-
import { SidePanelApp } from './app';
|
|
229
|
-
import '../../styles/main.css';
|
|
230
|
-
|
|
231
|
-
const container = document.getElementById('root');
|
|
232
|
-
if (container) {
|
|
233
|
-
const root = createRoot(container);
|
|
234
|
-
root.render(
|
|
235
|
-
<React.StrictMode>
|
|
236
|
-
<SidePanelApp />
|
|
237
|
-
</React.StrictMode>
|
|
238
|
-
);
|
|
239
|
-
}
|
|
240
|
-
`);
|
|
241
|
-
}
|
|
242
|
-
function writeSidepanelHtml(dir, displayName) {
|
|
243
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/index.html'), `<!DOCTYPE html>
|
|
244
|
-
<html lang="en">
|
|
245
|
-
<head>
|
|
246
|
-
<meta charset="UTF-8" />
|
|
247
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
248
|
-
<title>${htmlText(displayName)}</title>
|
|
249
|
-
</head>
|
|
250
|
-
<body>
|
|
251
|
-
<div id="root"></div>
|
|
252
|
-
<script type="module" src="./main.tsx"></script>
|
|
253
|
-
</body>
|
|
254
|
-
</html>
|
|
255
|
-
`);
|
|
256
|
-
}
|
|
257
|
-
function writeSidepanelApp(dir) {
|
|
258
|
-
writeFile(path.join(dir, 'src/entrypoints/sidepanel/app.tsx'), `import * as React from 'react';
|
|
259
|
-
import { Button } from '../../components/ui/button';
|
|
260
|
-
|
|
261
|
-
type PageSnapshot = {
|
|
262
|
-
title: string;
|
|
263
|
-
location: string;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
async function readPageSnapshot(): Promise<PageSnapshot> {
|
|
267
|
-
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
|
268
|
-
if (!tab?.id) throw new Error('No active tab is available.');
|
|
269
|
-
const [{ result }] = await chrome.scripting.executeScript({
|
|
270
|
-
target: { tabId: tab.id },
|
|
271
|
-
func: () => ({ title: document.title, location: window.location.href }),
|
|
272
|
-
});
|
|
273
|
-
if (!result) throw new Error('The active page did not return a snapshot.');
|
|
274
|
-
return result as PageSnapshot;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
export function SidePanelApp() {
|
|
278
|
-
const [page, setPage] = React.useState<PageSnapshot | null>(null);
|
|
279
|
-
const [pageError, setPageError] = React.useState<string | null>(null);
|
|
280
|
-
|
|
281
|
-
const readActivePage = React.useCallback(async () => {
|
|
282
|
-
setPageError(null);
|
|
283
|
-
try {
|
|
284
|
-
setPage(await readPageSnapshot());
|
|
285
|
-
} catch {
|
|
286
|
-
setPageError('Chrome does not allow this page to be inspected. Open a normal website and try again.');
|
|
287
|
-
}
|
|
288
|
-
}, []);
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<div style={{ padding: 24 }}>
|
|
292
|
-
<h2>Welcome!</h2>
|
|
293
|
-
<Button type="button" onClick={() => void readActivePage()}>Read active page</Button>
|
|
294
|
-
{page ? (
|
|
295
|
-
<div role="status" aria-live="polite" style={{ marginTop: 16 }}>
|
|
296
|
-
<strong>{page.title || 'Untitled page'}</strong>
|
|
297
|
-
<p style={{ overflowWrap: 'anywhere' }}>{page.location}</p>
|
|
298
|
-
</div>
|
|
299
|
-
) : null}
|
|
300
|
-
{pageError ? <p role="alert" aria-live="assertive" style={{ color: 'hsl(var(--destructive))' }}>{pageError}</p> : null}
|
|
301
|
-
</div>
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
`);
|
|
305
|
-
}
|
|
306
|
-
function writeStyles(dir) {
|
|
307
|
-
writeFile(path.join(dir, 'src/styles/main.css'), `@tailwind base;
|
|
308
|
-
@tailwind components;
|
|
309
|
-
@tailwind utilities;
|
|
310
|
-
|
|
311
|
-
@layer base {
|
|
312
|
-
|
|
313
|
-
* {
|
|
314
|
-
border-color: hsl(var(--border));
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
body {
|
|
318
|
-
background: hsl(var(--background));
|
|
319
|
-
color: hsl(var(--foreground));
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
body {
|
|
324
|
-
margin: 0;
|
|
325
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
326
|
-
}
|
|
327
|
-
`);
|
|
328
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import type { Dashboard, DashboardTool, ToolArguments } from './catalog-model.js';
|
|
3
|
-
export type CatalogErrorCode = 'CATALOG_BUSY' | 'CATALOG_INVALID' | 'PROJECT_NOT_FOUND' | 'PROJECT_UNAVAILABLE' | 'INVALID_INPUT' | 'CATALOG_FAILURE';
|
|
4
|
-
export declare class CatalogError extends Error {
|
|
5
|
-
readonly code: CatalogErrorCode;
|
|
6
|
-
constructor(code: CatalogErrorCode);
|
|
7
|
-
}
|
|
8
|
-
export declare function catalogFailure(error: unknown): {
|
|
9
|
-
message: string;
|
|
10
|
-
nextAction: string;
|
|
11
|
-
code: CatalogErrorCode;
|
|
12
|
-
};
|
|
13
|
-
declare const entrySchema: z.ZodObject<{
|
|
14
|
-
id: z.ZodString;
|
|
15
|
-
root: z.ZodString;
|
|
16
|
-
name: z.ZodString;
|
|
17
|
-
updatedAt: z.ZodString;
|
|
18
|
-
sourceIdentity: z.ZodOptional<z.ZodString>;
|
|
19
|
-
}, z.core.$strict>;
|
|
20
|
-
export type ProjectEntry = z.infer<typeof entrySchema>;
|
|
21
|
-
export declare class ProjectStore {
|
|
22
|
-
readonly directory: string;
|
|
23
|
-
readonly file: string;
|
|
24
|
-
constructor(directory: string);
|
|
25
|
-
private read;
|
|
26
|
-
private write;
|
|
27
|
-
register(root: string, displayName?: string): string;
|
|
28
|
-
private mutate;
|
|
29
|
-
/** Explicit local operator recovery only; uncertain ownership never removes a lock. */
|
|
30
|
-
recoverCatalogLock(): {
|
|
31
|
-
recovered: boolean;
|
|
32
|
-
};
|
|
33
|
-
context(id: string): {
|
|
34
|
-
id: string;
|
|
35
|
-
name: string;
|
|
36
|
-
directory: string;
|
|
37
|
-
};
|
|
38
|
-
snapshot(selectedId?: string | null): Dashboard;
|
|
39
|
-
call(tool: DashboardTool, raw: ToolArguments): Dashboard;
|
|
40
|
-
}
|
|
41
|
-
export {};
|
package/dist/project-catalog.js
DELETED
|
@@ -1,288 +0,0 @@
|
|
|
1
|
-
import { existsSync, lstatSync, openSync, closeSync, mkdirSync, realpathSync, renameSync, rmSync, statSync, writeFileSync, } from 'node:fs';
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { hostname } from 'node:os';
|
|
5
|
-
import { z } from 'zod';
|
|
6
|
-
import { projectSnapshot, readCatalogSourceIdentity } from './catalog-snapshot.js';
|
|
7
|
-
import { readBoundedFile } from './bounded-file.js';
|
|
8
|
-
const catalogErrors = {
|
|
9
|
-
CATALOG_BUSY: {
|
|
10
|
-
message: 'The catalog is busy. Retry when the other operation has finished.',
|
|
11
|
-
nextAction: 'If an operation was interrupted, inspect the catalog lock and use the local recover-catalog-lock command.',
|
|
12
|
-
},
|
|
13
|
-
CATALOG_INVALID: {
|
|
14
|
-
message: 'Project catalog is invalid. Restore the local catalog before continuing.',
|
|
15
|
-
nextAction: 'Restore a valid catalog backup; no project files were changed.',
|
|
16
|
-
},
|
|
17
|
-
PROJECT_NOT_FOUND: {
|
|
18
|
-
message: 'This project is not in your catalog.',
|
|
19
|
-
nextAction: 'Refresh the project list and select a registered project.',
|
|
20
|
-
},
|
|
21
|
-
PROJECT_UNAVAILABLE: {
|
|
22
|
-
message: 'Registered source is unavailable.',
|
|
23
|
-
nextAction: 'Restore the registered source directory, then refresh.',
|
|
24
|
-
},
|
|
25
|
-
INVALID_INPUT: {
|
|
26
|
-
message: 'The catalog input is invalid.',
|
|
27
|
-
nextAction: 'Check the project ID and requested input, then retry.',
|
|
28
|
-
},
|
|
29
|
-
CATALOG_FAILURE: {
|
|
30
|
-
message: 'The catalog operation could not complete.',
|
|
31
|
-
nextAction: 'Check local catalog access and retry.',
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
export class CatalogError extends Error {
|
|
35
|
-
code;
|
|
36
|
-
constructor(code) {
|
|
37
|
-
super(catalogErrors[code].message);
|
|
38
|
-
this.code = code;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export function catalogFailure(error) {
|
|
42
|
-
const code = error instanceof CatalogError ? error.code : 'CATALOG_FAILURE';
|
|
43
|
-
return { code, ...catalogErrors[code] };
|
|
44
|
-
}
|
|
45
|
-
const entrySchema = z
|
|
46
|
-
.object({
|
|
47
|
-
id: z.string().uuid(),
|
|
48
|
-
root: z.string().min(1),
|
|
49
|
-
name: z.string().trim().min(1).max(80),
|
|
50
|
-
updatedAt: z.string().datetime(),
|
|
51
|
-
sourceIdentity: z.string().uuid().optional(),
|
|
52
|
-
})
|
|
53
|
-
.strict();
|
|
54
|
-
const catalogSchema = z
|
|
55
|
-
.object({
|
|
56
|
-
schemaVersion: z.literal(1),
|
|
57
|
-
projects: z.array(entrySchema).max(200),
|
|
58
|
-
view: z.enum(['list', 'grid']),
|
|
59
|
-
})
|
|
60
|
-
.strict();
|
|
61
|
-
const projectId = z.string().uuid();
|
|
62
|
-
const toolSchema = z.enum([
|
|
63
|
-
'list_projects',
|
|
64
|
-
'get_project',
|
|
65
|
-
'rename_project',
|
|
66
|
-
'forget_project',
|
|
67
|
-
'set_view',
|
|
68
|
-
]);
|
|
69
|
-
const inputSchemas = {
|
|
70
|
-
list_projects: z.object({}).strict(),
|
|
71
|
-
get_project: z.object({ id: projectId }).strict(),
|
|
72
|
-
rename_project: z.object({ id: projectId, name: z.string().trim().min(1).max(80) }).strict(),
|
|
73
|
-
forget_project: z.object({ id: projectId }).strict(),
|
|
74
|
-
set_view: z.object({ view: z.enum(['list', 'grid']) }).strict(),
|
|
75
|
-
};
|
|
76
|
-
const CATALOG_LIMIT = 1024 * 1024;
|
|
77
|
-
export class ProjectStore {
|
|
78
|
-
directory;
|
|
79
|
-
file;
|
|
80
|
-
constructor(directory) {
|
|
81
|
-
mkdirSync(directory, { recursive: true, mode: 0o700 });
|
|
82
|
-
this.directory = realpathSync(directory);
|
|
83
|
-
this.file = path.join(this.directory, 'projects.json');
|
|
84
|
-
}
|
|
85
|
-
read() {
|
|
86
|
-
if (!existsSync(this.file))
|
|
87
|
-
return { schemaVersion: 1, projects: [], view: 'list' };
|
|
88
|
-
try {
|
|
89
|
-
const value = catalogSchema.parse(JSON.parse(readBoundedFile(this.file, CATALOG_LIMIT).toString('utf8')));
|
|
90
|
-
if (new Set(value.projects.map((project) => project.id)).size !== value.projects.length)
|
|
91
|
-
throw new Error();
|
|
92
|
-
return value;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
throw new CatalogError('CATALOG_INVALID');
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
write(catalog) {
|
|
99
|
-
const temporary = path.join(this.directory, `${randomUUID()}.tmp`);
|
|
100
|
-
const bytes = JSON.stringify(catalogSchema.parse(catalog), null, 2) + '\n';
|
|
101
|
-
if (Buffer.byteLength(bytes) > CATALOG_LIMIT)
|
|
102
|
-
throw new Error('Project catalog exceeds its storage limit.');
|
|
103
|
-
writeFileSync(temporary, bytes, {
|
|
104
|
-
mode: 0o600,
|
|
105
|
-
flag: 'wx',
|
|
106
|
-
});
|
|
107
|
-
try {
|
|
108
|
-
renameSync(temporary, this.file);
|
|
109
|
-
}
|
|
110
|
-
finally {
|
|
111
|
-
rmSync(temporary, { force: true });
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
register(root, displayName) {
|
|
115
|
-
const resolved = realpathSync(root);
|
|
116
|
-
if (!statSync(resolved).isDirectory())
|
|
117
|
-
throw new Error('Choose a project directory.');
|
|
118
|
-
// Registration is an operator action; MCP tools cannot add arbitrary filesystem paths.
|
|
119
|
-
let packageName;
|
|
120
|
-
try {
|
|
121
|
-
packageName = z
|
|
122
|
-
.string()
|
|
123
|
-
.min(1)
|
|
124
|
-
.parse(JSON.parse(readBoundedFile(path.join(resolved, 'package.json'), 1024 * 1024).toString('utf8')).name);
|
|
125
|
-
}
|
|
126
|
-
catch {
|
|
127
|
-
throw new Error('Choose a project with a valid package.json name.');
|
|
128
|
-
}
|
|
129
|
-
const sourceIdentity = readCatalogSourceIdentity(resolved);
|
|
130
|
-
return this.mutate((catalog) => {
|
|
131
|
-
const previous = catalog.projects.find((project) => project.root === resolved && project.sourceIdentity === sourceIdentity);
|
|
132
|
-
if (previous)
|
|
133
|
-
return previous.id;
|
|
134
|
-
const entry = entrySchema.parse({
|
|
135
|
-
id: randomUUID(),
|
|
136
|
-
root: resolved,
|
|
137
|
-
name: displayName ?? packageName,
|
|
138
|
-
updatedAt: new Date().toISOString(),
|
|
139
|
-
...(sourceIdentity ? { sourceIdentity } : {}),
|
|
140
|
-
});
|
|
141
|
-
catalog.projects.push(entry);
|
|
142
|
-
return entry.id;
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
mutate(operation) {
|
|
146
|
-
const lock = path.join(this.directory, 'projects.lock');
|
|
147
|
-
let descriptor;
|
|
148
|
-
try {
|
|
149
|
-
if (existsSync(path.join(this.directory, 'projects.recovery.lock')))
|
|
150
|
-
throw new Error();
|
|
151
|
-
descriptor = openSync(lock, 'wx', 0o600);
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
155
|
-
}
|
|
156
|
-
try {
|
|
157
|
-
writeFileSync(descriptor, JSON.stringify({
|
|
158
|
-
schemaVersion: 1,
|
|
159
|
-
pid: process.pid,
|
|
160
|
-
host: hostname(),
|
|
161
|
-
token: randomUUID(),
|
|
162
|
-
createdAt: new Date().toISOString(),
|
|
163
|
-
}));
|
|
164
|
-
if (existsSync(path.join(this.directory, 'projects.recovery.lock')))
|
|
165
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
166
|
-
const catalog = this.read();
|
|
167
|
-
const result = operation(catalog);
|
|
168
|
-
this.write(catalog);
|
|
169
|
-
return result;
|
|
170
|
-
}
|
|
171
|
-
finally {
|
|
172
|
-
closeSync(descriptor);
|
|
173
|
-
rmSync(lock, { force: true });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/** Explicit local operator recovery only; uncertain ownership never removes a lock. */
|
|
177
|
-
recoverCatalogLock() {
|
|
178
|
-
const guard = path.join(this.directory, 'projects.recovery.lock');
|
|
179
|
-
let descriptor;
|
|
180
|
-
try {
|
|
181
|
-
descriptor = openSync(guard, 'wx', 0o600);
|
|
182
|
-
}
|
|
183
|
-
catch {
|
|
184
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
185
|
-
}
|
|
186
|
-
try {
|
|
187
|
-
const lock = path.join(this.directory, 'projects.lock');
|
|
188
|
-
if (!existsSync(lock))
|
|
189
|
-
return { recovered: false };
|
|
190
|
-
let owner;
|
|
191
|
-
try {
|
|
192
|
-
if (!lstatSync(lock).isFile() || lstatSync(lock).isSymbolicLink())
|
|
193
|
-
throw new Error();
|
|
194
|
-
owner = z
|
|
195
|
-
.object({
|
|
196
|
-
schemaVersion: z.literal(1),
|
|
197
|
-
pid: z.number().int().positive(),
|
|
198
|
-
host: z.string(),
|
|
199
|
-
token: z.string().uuid(),
|
|
200
|
-
createdAt: z.string().datetime(),
|
|
201
|
-
})
|
|
202
|
-
.strict()
|
|
203
|
-
.parse(JSON.parse(readBoundedFile(lock, 4096).toString('utf8')));
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
207
|
-
}
|
|
208
|
-
if (owner.host !== hostname())
|
|
209
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
210
|
-
try {
|
|
211
|
-
process.kill(owner.pid, 0);
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
if (error.code === 'ESRCH') {
|
|
215
|
-
rmSync(lock);
|
|
216
|
-
return { recovered: true };
|
|
217
|
-
}
|
|
218
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
219
|
-
}
|
|
220
|
-
throw new CatalogError('CATALOG_BUSY');
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
closeSync(descriptor);
|
|
224
|
-
rmSync(guard, { force: true });
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
context(id) {
|
|
228
|
-
const project = this.read().projects.find((project) => project.id === id);
|
|
229
|
-
if (!project)
|
|
230
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
231
|
-
try {
|
|
232
|
-
if (realpathSync(project.root) !== project.root ||
|
|
233
|
-
project.sourceIdentity !== readCatalogSourceIdentity(project.root))
|
|
234
|
-
throw new Error();
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
throw new CatalogError('PROJECT_UNAVAILABLE');
|
|
238
|
-
}
|
|
239
|
-
return { id: project.id, name: project.name, directory: project.root };
|
|
240
|
-
}
|
|
241
|
-
snapshot(selectedId = null) {
|
|
242
|
-
const catalog = this.read();
|
|
243
|
-
return {
|
|
244
|
-
projects: catalog.projects
|
|
245
|
-
.map((entry) => projectSnapshot(entry, entry.id === selectedId))
|
|
246
|
-
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt)),
|
|
247
|
-
selectedId,
|
|
248
|
-
preferences: { view: catalog.view },
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
call(tool, raw) {
|
|
252
|
-
let args;
|
|
253
|
-
try {
|
|
254
|
-
args = inputSchemas[toolSchema.parse(tool)].parse(raw);
|
|
255
|
-
}
|
|
256
|
-
catch {
|
|
257
|
-
throw new CatalogError('INVALID_INPUT');
|
|
258
|
-
}
|
|
259
|
-
if (tool === 'list_projects')
|
|
260
|
-
return this.snapshot();
|
|
261
|
-
if (tool === 'get_project') {
|
|
262
|
-
if (!this.read().projects.some((project) => project.id === args.id))
|
|
263
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
264
|
-
return this.snapshot(args.id);
|
|
265
|
-
}
|
|
266
|
-
const selectedId = this.mutate((catalog) => {
|
|
267
|
-
if (tool === 'set_view') {
|
|
268
|
-
if (!args.view)
|
|
269
|
-
throw new Error('Choose list or grid view.');
|
|
270
|
-
catalog.view = args.view;
|
|
271
|
-
return null;
|
|
272
|
-
}
|
|
273
|
-
const project = catalog.projects.find((project) => project.id === args.id);
|
|
274
|
-
if (!project)
|
|
275
|
-
throw new CatalogError('PROJECT_NOT_FOUND');
|
|
276
|
-
if (tool === 'rename_project') {
|
|
277
|
-
if (!args.name)
|
|
278
|
-
throw new Error('Enter a project name.');
|
|
279
|
-
project.name = args.name;
|
|
280
|
-
project.updatedAt = new Date().toISOString();
|
|
281
|
-
return project.id;
|
|
282
|
-
}
|
|
283
|
-
catalog.projects = catalog.projects.filter((entry) => entry.id !== project.id);
|
|
284
|
-
return null;
|
|
285
|
-
});
|
|
286
|
-
return this.snapshot(selectedId);
|
|
287
|
-
}
|
|
288
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ProjectInspection } from './inspector-model.js';
|
|
2
|
-
/** Local read-only inspection. Each section has bounded allowlisted inputs and an
|
|
3
|
-
* independent error state. No secrets, commands, provider calls, or migrations. */
|
|
4
|
-
export declare function inspectApplication(root: string): ProjectInspection;
|