@open-press/cli 0.8.0 → 1.1.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 +33 -23
- package/dist/cli.js +320 -252
- package/package.json +9 -8
- package/template/core/AGENTS.md +0 -126
- package/template/core/CHANGELOG.md +0 -215
- package/template/core/README.md +0 -40
- package/template/core/engine/cli.mjs +0 -96
- package/template/core/engine/commands/_shared.mjs +0 -177
- package/template/core/engine/commands/deploy.mjs +0 -31
- package/template/core/engine/commands/dev.mjs +0 -49
- package/template/core/engine/commands/doctor.mjs +0 -229
- package/template/core/engine/commands/export.mjs +0 -8
- package/template/core/engine/commands/init.mjs +0 -24
- package/template/core/engine/commands/inspect.mjs +0 -35
- package/template/core/engine/commands/pdf.mjs +0 -26
- package/template/core/engine/commands/preview.mjs +0 -26
- package/template/core/engine/commands/render.mjs +0 -17
- package/template/core/engine/commands/replace.mjs +0 -41
- package/template/core/engine/commands/search.mjs +0 -33
- package/template/core/engine/commands/typecheck.mjs +0 -5
- package/template/core/engine/commands/upgrade.mjs +0 -159
- package/template/core/engine/commands/validate.mjs +0 -17
- package/template/core/engine/document-export.mjs +0 -15
- package/template/core/engine/init.mjs +0 -90
- package/template/core/engine/output/chrome-pdf.d.mts +0 -34
- package/template/core/engine/output/chrome-pdf.mjs +0 -358
- package/template/core/engine/output/deploy-sync.mjs +0 -15
- package/template/core/engine/output/fonts.mjs +0 -62
- package/template/core/engine/output/katex-assets.mjs +0 -45
- package/template/core/engine/output/page-block.mjs +0 -30
- package/template/core/engine/output/pdf-media.mjs +0 -45
- package/template/core/engine/output/public-assets.mjs +0 -19
- package/template/core/engine/output/static-server.mjs +0 -532
- package/template/core/engine/react/caption-numbering.mjs +0 -73
- package/template/core/engine/react/comment-endpoint.d.mts +0 -11
- package/template/core/engine/react/comment-endpoint.mjs +0 -102
- package/template/core/engine/react/comment-marker.mjs +0 -374
- package/template/core/engine/react/document-entry.mjs +0 -324
- package/template/core/engine/react/document-export.mjs +0 -373
- package/template/core/engine/react/http-json.mjs +0 -24
- package/template/core/engine/react/mdx-compile.mjs +0 -599
- package/template/core/engine/react/measurement-css.mjs +0 -136
- package/template/core/engine/react/object-entities.mjs +0 -119
- package/template/core/engine/react/pagination/allocator.mjs +0 -122
- package/template/core/engine/react/pagination/regions.mjs +0 -81
- package/template/core/engine/react/pagination-constants.mjs +0 -3
- package/template/core/engine/react/pagination.mjs +0 -9
- package/template/core/engine/react/pipeline/allocate.mjs +0 -251
- package/template/core/engine/react/pipeline/final-render.mjs +0 -94
- package/template/core/engine/react/pipeline/frame-measurement.mjs +0 -302
- package/template/core/engine/react/pipeline/press-tree.mjs +0 -135
- package/template/core/engine/react/project-asset-endpoint.d.mts +0 -10
- package/template/core/engine/react/project-asset-endpoint.mjs +0 -361
- package/template/core/engine/react/section-css.mjs +0 -56
- package/template/core/engine/react/source-edit-endpoint.d.mts +0 -10
- package/template/core/engine/react/source-edit-endpoint.mjs +0 -75
- package/template/core/engine/react/sources/heading-numbering.mjs +0 -132
- package/template/core/engine/react/sources/mdx-resolver.mjs +0 -439
- package/template/core/engine/react/style-discovery.mjs +0 -142
- package/template/core/engine/runtime/config.d.mts +0 -40
- package/template/core/engine/runtime/config.mjs +0 -175
- package/template/core/engine/runtime/file-utils.mjs +0 -106
- package/template/core/engine/runtime/file-walk.mjs +0 -22
- package/template/core/engine/runtime/inspection.mjs +0 -328
- package/template/core/engine/runtime/issue-report.mjs +0 -44
- package/template/core/engine/runtime/path-utils.mjs +0 -20
- package/template/core/engine/runtime/source-text-tools.d.mts +0 -102
- package/template/core/engine/runtime/source-text-tools.mjs +0 -832
- package/template/core/engine/runtime/source-workspace.mjs +0 -159
- package/template/core/engine/runtime/validation.mjs +0 -174
- package/template/core/index.html +0 -13
- package/template/core/openpress.config.mjs +0 -12
- package/template/core/package.json +0 -91
- package/template/core/src/main.tsx +0 -16
- package/template/core/src/openpress/app/OpenPressApp.tsx +0 -140
- package/template/core/src/openpress/app/OpenPressRuntime.tsx +0 -94
- package/template/core/src/openpress/app/index.ts +0 -2
- package/template/core/src/openpress/core/Frame.tsx +0 -78
- package/template/core/src/openpress/core/FrameContext.tsx +0 -24
- package/template/core/src/openpress/core/MdxArea.tsx +0 -34
- package/template/core/src/openpress/core/Press.tsx +0 -34
- package/template/core/src/openpress/core/cn.ts +0 -4
- package/template/core/src/openpress/core/index.tsx +0 -40
- package/template/core/src/openpress/core/primitives.tsx +0 -44
- package/template/core/src/openpress/core/types.ts +0 -191
- package/template/core/src/openpress/core/useSource.ts +0 -28
- package/template/core/src/openpress/document-model/anchorMapModel.ts +0 -27
- package/template/core/src/openpress/document-model/documentIndexes.ts +0 -329
- package/template/core/src/openpress/document-model/documentTypes.ts +0 -138
- package/template/core/src/openpress/document-model/index.ts +0 -6
- package/template/core/src/openpress/document-model/objectEntityModel.ts +0 -51
- package/template/core/src/openpress/document-model/projectIdentityModel.ts +0 -15
- package/template/core/src/openpress/document-model/reactDocumentMetadataModel.ts +0 -27
- package/template/core/src/openpress/manuscript/index.tsx +0 -238
- package/template/core/src/openpress/mdx/index.ts +0 -88
- package/template/core/src/openpress/numbering/index.ts +0 -294
- package/template/core/src/openpress/reader/PublicReaderPage.tsx +0 -267
- package/template/core/src/openpress/reader/ReaderNavigationPanel.tsx +0 -123
- package/template/core/src/openpress/reader/index.ts +0 -10
- package/template/core/src/openpress/reader/pageViewportScaleModel.ts +0 -73
- package/template/core/src/openpress/reader/readerPageRegistry.ts +0 -41
- package/template/core/src/openpress/reader/readerPageRoute.ts +0 -21
- package/template/core/src/openpress/reader/readerScroll.ts +0 -92
- package/template/core/src/openpress/reader/readerStateModel.ts +0 -15
- package/template/core/src/openpress/reader/readerTypes.ts +0 -4
- package/template/core/src/openpress/reader/usePageViewportScale.ts +0 -119
- package/template/core/src/openpress/reader/usePanelState.ts +0 -56
- package/template/core/src/openpress/reader/useReaderHashSync.ts +0 -61
- package/template/core/src/openpress/reader/useReaderKeyboardNav.ts +0 -48
- package/template/core/src/openpress/reader/useReaderRuntime.ts +0 -146
- package/template/core/src/openpress/reader/useReaderScrollAnchor.ts +0 -64
- package/template/core/src/openpress/shared/Panel.tsx +0 -77
- package/template/core/src/openpress/shared/frameScheduler.ts +0 -32
- package/template/core/src/openpress/shared/index.ts +0 -4
- package/template/core/src/openpress/shared/numberUtils.ts +0 -3
- package/template/core/src/openpress/shared/runtimeMode.ts +0 -11
- package/template/core/src/openpress/workbench/Workbench.tsx +0 -407
- package/template/core/src/openpress/workbench/actions/DeploymentControl.tsx +0 -157
- package/template/core/src/openpress/workbench/actions/PageZoomControl.tsx +0 -182
- package/template/core/src/openpress/workbench/actions/SearchControl.tsx +0 -345
- package/template/core/src/openpress/workbench/actions/deploymentStatusModel.ts +0 -112
- package/template/core/src/openpress/workbench/actions/index.ts +0 -5
- package/template/core/src/openpress/workbench/actions/useDeploymentWorkbench.ts +0 -136
- package/template/core/src/openpress/workbench/dialog/WorkbenchDialog.tsx +0 -72
- package/template/core/src/openpress/workbench/dialog/index.ts +0 -1
- package/template/core/src/openpress/workbench/document/components/DocumentPanel.tsx +0 -127
- package/template/core/src/openpress/workbench/document/components/InlineSourceEditorLayer.tsx +0 -207
- package/template/core/src/openpress/workbench/document/components/ReaderStage.tsx +0 -9
- package/template/core/src/openpress/workbench/document/hooks/useDocumentWorkbenchModel.ts +0 -34
- package/template/core/src/openpress/workbench/document/hooks/useInlineDocumentEditor.ts +0 -525
- package/template/core/src/openpress/workbench/document/index.ts +0 -10
- package/template/core/src/openpress/workbench/index.ts +0 -2
- package/template/core/src/openpress/workbench/inspector/InlineInspectorLayer.tsx +0 -459
- package/template/core/src/openpress/workbench/inspector/index.ts +0 -5
- package/template/core/src/openpress/workbench/inspector/inlineCommentModel.ts +0 -125
- package/template/core/src/openpress/workbench/inspector/inspectorGeometryModel.ts +0 -160
- package/template/core/src/openpress/workbench/inspector/inspectorModel.ts +0 -408
- package/template/core/src/openpress/workbench/inspector/useInspectorComments.ts +0 -248
- package/template/core/src/openpress/workbench/mentions/MentionSuggestionList.tsx +0 -41
- package/template/core/src/openpress/workbench/mentions/index.ts +0 -2
- package/template/core/src/openpress/workbench/mentions/useComposerMentions.ts +0 -185
- package/template/core/src/openpress/workbench/panels/Panel.tsx +0 -1
- package/template/core/src/openpress/workbench/panels/PendingCommentsPanel.tsx +0 -76
- package/template/core/src/openpress/workbench/panels/WorkbenchControlPanel.tsx +0 -29
- package/template/core/src/openpress/workbench/panels/index.ts +0 -3
- package/template/core/src/openpress/workbench/project/ProjectEntryPanel.tsx +0 -523
- package/template/core/src/openpress/workbench/project/ProjectPreviewDialog.tsx +0 -35
- package/template/core/src/openpress/workbench/project/index.ts +0 -2
- package/template/core/src/openpress/workbench/project/projectPreviewTypes.ts +0 -11
- package/template/core/src/openpress/workbench/project/projectSourceModel.ts +0 -24
- package/template/core/src/openpress/workbench/shell/WorkbenchShell.tsx +0 -167
- package/template/core/src/openpress/workbench/shell/index.ts +0 -1
- package/template/core/src/openpress/workbench/workbenchFormatters.ts +0 -120
- package/template/core/src/openpress/workbench/workbenchTypes.ts +0 -35
- package/template/core/src/styles/openpress/app-shell.css +0 -251
- package/template/core/src/styles/openpress/media-workspace.css +0 -230
- package/template/core/src/styles/openpress/print-route.css +0 -184
- package/template/core/src/styles/openpress/project-preview-panel.css +0 -924
- package/template/core/src/styles/openpress/public-viewer.css +0 -688
- package/template/core/src/styles/openpress/reader-runtime.css +0 -980
- package/template/core/src/styles/openpress/responsive.css +0 -245
- package/template/core/src/styles/openpress/workbench-panels.css +0 -594
- package/template/core/src/styles/openpress/workbench.css +0 -1255
- package/template/core/src/styles/openpress.css +0 -14
- package/template/core/src/vite-env.d.ts +0 -9
- package/template/core/tsconfig.json +0 -40
- package/template/core/vite.config.ts +0 -584
- package/template/packs/academic-paper/document/chapters/01-introduction/content/01-introduction.mdx +0 -35
- package/template/packs/academic-paper/document/chapters/02-methods/content/01-methods.mdx +0 -50
- package/template/packs/academic-paper/document/chapters/03-results-and-discussion/content/01-results.mdx +0 -47
- package/template/packs/academic-paper/document/chapters/04-acknowledgment/content/01-acknowledgment.mdx +0 -26
- package/template/packs/academic-paper/document/chapters/05-references/content/01-references.mdx +0 -32
- package/template/packs/academic-paper/document/components/ChapterOpenerVisual/index.tsx +0 -76
- package/template/packs/academic-paper/document/components/Page.tsx +0 -60
- package/template/packs/academic-paper/document/components/TokenSwatchGrid/index.tsx +0 -46
- package/template/packs/academic-paper/document/components/TokenSwatchGrid/style.css +0 -63
- package/template/packs/academic-paper/document/components/TypeSpecimen/index.tsx +0 -38
- package/template/packs/academic-paper/document/components/TypeSpecimen/style.css +0 -111
- package/template/packs/academic-paper/document/design.md +0 -279
- package/template/packs/academic-paper/document/index.tsx +0 -123
- package/template/packs/academic-paper/document/media/README.md +0 -13
- package/template/packs/academic-paper/document/media/figure-placeholder.svg +0 -9
- package/template/packs/academic-paper/document/openpress.config.mjs +0 -26
- package/template/packs/academic-paper/document/theme/README.md +0 -11
- package/template/packs/academic-paper/document/theme/base/page-contract.css +0 -522
- package/template/packs/academic-paper/document/theme/base/print.css +0 -93
- package/template/packs/academic-paper/document/theme/base/typography.css +0 -333
- package/template/packs/academic-paper/document/theme/fonts.css +0 -3
- package/template/packs/academic-paper/document/theme/page-surfaces/back-cover.css +0 -43
- package/template/packs/academic-paper/document/theme/page-surfaces/chapter-opener.css +0 -205
- package/template/packs/academic-paper/document/theme/page-surfaces/cover.css +0 -294
- package/template/packs/academic-paper/document/theme/page-surfaces/toc.css +0 -149
- package/template/packs/academic-paper/document/theme/patterns/_chart-frame.css +0 -49
- package/template/packs/academic-paper/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/academic-paper/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/academic-paper/document/theme/shell/reader-controls.css +0 -761
- package/template/packs/academic-paper/document/theme/tokens.css +0 -80
- package/template/packs/academic-paper/openpress.config.mjs +0 -5
- package/template/packs/claude-document/document/chapters/01-document-shape/content/01-document-shape.mdx +0 -51
- package/template/packs/claude-document/document/chapters/02-review-loop/content/01-review-loop.mdx +0 -31
- package/template/packs/claude-document/document/components/ChapterOpenerVisual.tsx +0 -96
- package/template/packs/claude-document/document/components/Page.tsx +0 -37
- package/template/packs/claude-document/document/design.md +0 -142
- package/template/packs/claude-document/document/index.tsx +0 -94
- package/template/packs/claude-document/document/media/README.md +0 -13
- package/template/packs/claude-document/document/openpress.config.mjs +0 -26
- package/template/packs/claude-document/document/theme/README.md +0 -15
- package/template/packs/claude-document/document/theme/base/page-contract.css +0 -525
- package/template/packs/claude-document/document/theme/base/print.css +0 -93
- package/template/packs/claude-document/document/theme/base/typography.css +0 -612
- package/template/packs/claude-document/document/theme/fonts.css +0 -4
- package/template/packs/claude-document/document/theme/page-surfaces/back-cover.css +0 -72
- package/template/packs/claude-document/document/theme/page-surfaces/chapter-opener.css +0 -236
- package/template/packs/claude-document/document/theme/page-surfaces/cover.css +0 -309
- package/template/packs/claude-document/document/theme/page-surfaces/toc.css +0 -225
- package/template/packs/claude-document/document/theme/patterns/_chart-frame.css +0 -53
- package/template/packs/claude-document/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/claude-document/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/claude-document/document/theme/shell/reader-controls.css +0 -789
- package/template/packs/claude-document/document/theme/tokens.css +0 -89
- package/template/packs/claude-document/openpress.config.mjs +0 -5
- package/template/packs/editorial-monograph/document/chapters/01-product-and-use-cases/content/01-product-and-use-cases.mdx +0 -31
- package/template/packs/editorial-monograph/document/chapters/02-workflow/content/01-workflow.mdx +0 -89
- package/template/packs/editorial-monograph/document/chapters/03-agent-skills-contributors/content/01-agent-skills-contributors.mdx +0 -51
- package/template/packs/editorial-monograph/document/chapters/04-validation-deploy/content/01-validation-deploy.mdx +0 -39
- package/template/packs/editorial-monograph/document/components/ChapterOpenerVisual/index.tsx +0 -76
- package/template/packs/editorial-monograph/document/components/Page.tsx +0 -37
- package/template/packs/editorial-monograph/document/components/TokenSwatchGrid/index.tsx +0 -46
- package/template/packs/editorial-monograph/document/components/TokenSwatchGrid/style.css +0 -63
- package/template/packs/editorial-monograph/document/components/TypeSpecimen/index.tsx +0 -38
- package/template/packs/editorial-monograph/document/components/TypeSpecimen/style.css +0 -111
- package/template/packs/editorial-monograph/document/design.md +0 -279
- package/template/packs/editorial-monograph/document/index.tsx +0 -97
- package/template/packs/editorial-monograph/document/media/README.md +0 -13
- package/template/packs/editorial-monograph/document/openpress.config.mjs +0 -26
- package/template/packs/editorial-monograph/document/theme/README.md +0 -11
- package/template/packs/editorial-monograph/document/theme/base/page-contract.css +0 -505
- package/template/packs/editorial-monograph/document/theme/base/print.css +0 -93
- package/template/packs/editorial-monograph/document/theme/base/typography.css +0 -336
- package/template/packs/editorial-monograph/document/theme/fonts.css +0 -3
- package/template/packs/editorial-monograph/document/theme/page-surfaces/back-cover.css +0 -43
- package/template/packs/editorial-monograph/document/theme/page-surfaces/chapter-opener.css +0 -205
- package/template/packs/editorial-monograph/document/theme/page-surfaces/cover.css +0 -147
- package/template/packs/editorial-monograph/document/theme/page-surfaces/toc.css +0 -149
- package/template/packs/editorial-monograph/document/theme/patterns/_chart-frame.css +0 -49
- package/template/packs/editorial-monograph/document/theme/patterns/figure-grid.css +0 -68
- package/template/packs/editorial-monograph/document/theme/patterns/table-utilities.css +0 -66
- package/template/packs/editorial-monograph/document/theme/shell/reader-controls.css +0 -761
- package/template/packs/editorial-monograph/document/theme/tokens.css +0 -80
- package/template/packs/editorial-monograph/openpress.config.mjs +0 -5
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { searchSourceText } from "../runtime/source-text-tools.mjs";
|
|
2
|
-
|
|
3
|
-
export async function run({ config, options }) {
|
|
4
|
-
const query = searchQueryFromOptions(options);
|
|
5
|
-
if (!query) {
|
|
6
|
-
console.error("Usage: node engine/cli.mjs search [path] <query> [--json] [--scope content|all] [--case-sensitive]");
|
|
7
|
-
return 2;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const report = await searchSourceText({
|
|
11
|
-
config,
|
|
12
|
-
query,
|
|
13
|
-
scope: options.scope ?? "content",
|
|
14
|
-
caseSensitive: options.caseSensitive === true,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (options.json) {
|
|
18
|
-
console.log(JSON.stringify(report, null, 2));
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
console.log(`OpenPress search: "${query}" (${report.matchCount} matches)`);
|
|
23
|
-
for (const match of report.matches) {
|
|
24
|
-
console.log(`${match.id} ${match.path}:${match.line}:${match.column} ${match.preview}`);
|
|
25
|
-
}
|
|
26
|
-
return 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function searchQueryFromOptions(options) {
|
|
30
|
-
const positional = options.positional ?? [];
|
|
31
|
-
if (positional.length > 1) return positional.slice(1).join(" ");
|
|
32
|
-
return positional[0] ?? "";
|
|
33
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
|
-
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import { diagnose } from "./doctor.mjs";
|
|
5
|
-
import { runCommand } from "./_shared.mjs";
|
|
6
|
-
|
|
7
|
-
// Migration notes live in the framework repo, not in scaffolded workspaces.
|
|
8
|
-
// `npx open-press upgrade` fetches the notes for each pending version and
|
|
9
|
-
// caches them under `.openpress/migrations/` so agents can read locally.
|
|
10
|
-
const MIGRATION_REMOTE_BASE = "https://raw.githubusercontent.com/quan0715/open-press/main/docs/migrations";
|
|
11
|
-
const MIGRATION_CACHE_DIR = path.join(".openpress", "migrations");
|
|
12
|
-
|
|
13
|
-
export async function run({ root, options }) {
|
|
14
|
-
const dryRun = Boolean(options?.dryRun);
|
|
15
|
-
const skipSkills = Boolean(options?.noSkills);
|
|
16
|
-
const skipDeps = Boolean(options?.noDeps);
|
|
17
|
-
const json = Boolean(options?.json);
|
|
18
|
-
|
|
19
|
-
// 1. Fresh diagnose (force re-check, ignore cache).
|
|
20
|
-
const before = await diagnose(root, { noCache: true });
|
|
21
|
-
|
|
22
|
-
if (!before.stale) {
|
|
23
|
-
const message = "open-press is already up to date.";
|
|
24
|
-
if (json) {
|
|
25
|
-
process.stdout.write(JSON.stringify({ status: "noop", before }, null, 2) + "\n");
|
|
26
|
-
} else {
|
|
27
|
-
process.stdout.write(`✓ ${message}\n`);
|
|
28
|
-
}
|
|
29
|
-
return 0;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!json) {
|
|
33
|
-
process.stdout.write("○ open-press upgrade\n\n");
|
|
34
|
-
if (before.coreUpdateAvailable) {
|
|
35
|
-
process.stdout.write(
|
|
36
|
-
` @open-press/core: ${before.coreVersion} → ${before.coreLatest}\n`,
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
if (before.pendingMigrations.length > 0) {
|
|
40
|
-
process.stdout.write(` migration notes: ${before.pendingMigrations.join(", ")}\n`);
|
|
41
|
-
}
|
|
42
|
-
process.stdout.write("\n");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (dryRun) {
|
|
46
|
-
if (!json) {
|
|
47
|
-
process.stdout.write("dry run — nothing changed. The agent should:\n");
|
|
48
|
-
process.stdout.write(" 1. read each docs/migrations/<version>.md for document-level changes\n");
|
|
49
|
-
process.stdout.write(" 2. apply edits to document/ where needed\n");
|
|
50
|
-
process.stdout.write(" 3. re-run: npx open-press upgrade (without --dry-run)\n");
|
|
51
|
-
} else {
|
|
52
|
-
process.stdout.write(JSON.stringify({ status: "dry-run", before }, null, 2) + "\n");
|
|
53
|
-
}
|
|
54
|
-
return 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// 2. Refresh framework dep (only when workspace declares @open-press/core).
|
|
58
|
-
if (!skipDeps && (await hasCoreDep(root))) {
|
|
59
|
-
if (!json) process.stdout.write("▸ updating @open-press/core via npm…\n");
|
|
60
|
-
const code = runCommand("npm", ["update", "@open-press/core"], root);
|
|
61
|
-
if (code !== 0) {
|
|
62
|
-
if (!json) process.stdout.write(" ⚠ npm update returned non-zero; continuing\n");
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// 3. Refresh skills (npx skills upgrade respects skills-lock.json).
|
|
67
|
-
if (!skipSkills) {
|
|
68
|
-
if (!json) process.stdout.write("▸ refreshing skills via npx skills upgrade…\n");
|
|
69
|
-
runCommand("npx", ["-y", "skills@latest", "upgrade"], root);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// 4. Surface migration notes for the agent to read.
|
|
73
|
-
const migrationContents = await loadMigrations(root, before.pendingMigrations);
|
|
74
|
-
|
|
75
|
-
// 5. Re-diagnose to confirm the move.
|
|
76
|
-
const after = await diagnose(root, { noCache: true });
|
|
77
|
-
|
|
78
|
-
if (json) {
|
|
79
|
-
process.stdout.write(
|
|
80
|
-
JSON.stringify(
|
|
81
|
-
{ status: "applied", before, after, migrationContents: migrationContents.map((m) => m.path) },
|
|
82
|
-
null,
|
|
83
|
-
2,
|
|
84
|
-
) + "\n",
|
|
85
|
-
);
|
|
86
|
-
return 0;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
process.stdout.write("\n✓ upgrade applied. Now read these migration notes:\n\n");
|
|
90
|
-
if (migrationContents.length === 0) {
|
|
91
|
-
process.stdout.write(" (no migration docs in this version range)\n\n");
|
|
92
|
-
} else {
|
|
93
|
-
for (const m of migrationContents) {
|
|
94
|
-
if (m.path) {
|
|
95
|
-
process.stdout.write(` ─ ${m.path}${m.fetched ? " (fetched from github)" : ""}\n`);
|
|
96
|
-
} else {
|
|
97
|
-
process.stdout.write(` ─ ${m.version}.md (not found locally or on github — check the repo manually)\n`);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
process.stdout.write(
|
|
101
|
-
"\nAgent: open each file, identify document-level changes, grep document/ for affected patterns, propose edits before applying.\n",
|
|
102
|
-
);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
process.stdout.write("\nVerify with:\n npm run openpress:validate\n npm run openpress:render\n\n");
|
|
106
|
-
return 0;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function hasCoreDep(root) {
|
|
110
|
-
try {
|
|
111
|
-
const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8"));
|
|
112
|
-
return Boolean(pkg.dependencies?.["@open-press/core"] || pkg.devDependencies?.["@open-press/core"]);
|
|
113
|
-
} catch {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function loadMigrations(root, versions) {
|
|
119
|
-
const results = [];
|
|
120
|
-
const cacheDir = path.join(root, MIGRATION_CACHE_DIR);
|
|
121
|
-
await mkdir(cacheDir, { recursive: true });
|
|
122
|
-
|
|
123
|
-
for (const v of versions) {
|
|
124
|
-
// Framework repo has docs/migrations/ at root — prefer local if present
|
|
125
|
-
// (covers the open-press framework repo itself acting as a workspace).
|
|
126
|
-
const localDocsPath = path.join(root, "docs", "migrations", `${v}.md`);
|
|
127
|
-
if (existsSync(localDocsPath)) {
|
|
128
|
-
results.push({ version: v, path: path.relative(root, localDocsPath), fetched: false });
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Otherwise fetch from GitHub raw and cache to .openpress/migrations/.
|
|
133
|
-
const cachedPath = path.join(cacheDir, `${v}.md`);
|
|
134
|
-
if (existsSync(cachedPath)) {
|
|
135
|
-
results.push({ version: v, path: path.relative(root, cachedPath), fetched: false });
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const body = await fetchMigration(v);
|
|
140
|
-
if (body) {
|
|
141
|
-
await writeFile(cachedPath, body, "utf8");
|
|
142
|
-
results.push({ version: v, path: path.relative(root, cachedPath), fetched: true });
|
|
143
|
-
} else {
|
|
144
|
-
results.push({ version: v, path: null, fetched: false });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return results;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function fetchMigration(version) {
|
|
151
|
-
const url = `${MIGRATION_REMOTE_BASE}/${version}.md`;
|
|
152
|
-
try {
|
|
153
|
-
const res = await fetch(url, { headers: { Accept: "text/plain" } });
|
|
154
|
-
if (!res.ok) return null;
|
|
155
|
-
return await res.text();
|
|
156
|
-
} catch {
|
|
157
|
-
return null;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { validateWorkspace } from "../runtime/validation.mjs";
|
|
2
|
-
import { exitCodeForIssueReport } from "../runtime/issue-report.mjs";
|
|
3
|
-
|
|
4
|
-
export async function run({ root, options }) {
|
|
5
|
-
const report = await validateWorkspace(root);
|
|
6
|
-
if (options.json) {
|
|
7
|
-
console.log(JSON.stringify(report, null, 2));
|
|
8
|
-
return exitCodeForIssueReport(report);
|
|
9
|
-
}
|
|
10
|
-
if (report.ok) {
|
|
11
|
-
console.log("OpenPress validation OK");
|
|
12
|
-
console.log(`Checked: ${report.checked.join(", ")}`);
|
|
13
|
-
return 0;
|
|
14
|
-
}
|
|
15
|
-
console.log(report.format());
|
|
16
|
-
return 1;
|
|
17
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { exportReactDocument } from "./react/document-export.mjs";
|
|
4
|
-
|
|
5
|
-
const SELF_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const ROOT = path.resolve(SELF_DIR, "..");
|
|
7
|
-
|
|
8
|
-
export async function exportDocument(root = ROOT) {
|
|
9
|
-
const reactResult = await exportReactDocument(root);
|
|
10
|
-
if (reactResult) return reactResult;
|
|
11
|
-
|
|
12
|
-
throw new Error(
|
|
13
|
-
"React/MDX document entry not found. Expected document/index.tsx with a Press default export before exporting.",
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
|
|
5
|
-
const SELF_DIR = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
const ENGINE_ROOT = path.resolve(SELF_DIR, "..");
|
|
7
|
-
const SKILLS_DIR = path.join(ENGINE_ROOT, "skills");
|
|
8
|
-
|
|
9
|
-
const DEFAULT_SKILL = "editorial-monograph";
|
|
10
|
-
|
|
11
|
-
export async function initWorkspace({ target, skill = DEFAULT_SKILL, force = false }) {
|
|
12
|
-
if (!target) throw new Error("openpress init: target path is required");
|
|
13
|
-
const targetPath = path.resolve(target);
|
|
14
|
-
|
|
15
|
-
const starterPath = path.join(SKILLS_DIR, skill, "starter");
|
|
16
|
-
try {
|
|
17
|
-
const stat = await fs.stat(starterPath);
|
|
18
|
-
if (!stat.isDirectory()) {
|
|
19
|
-
throw new Error(`openpress init: skill "${skill}" has no starter/ directory at ${starterPath}`);
|
|
20
|
-
}
|
|
21
|
-
} catch (error) {
|
|
22
|
-
if (error?.code === "ENOENT") {
|
|
23
|
-
const available = await listStylePackSkills();
|
|
24
|
-
throw new Error(
|
|
25
|
-
`openpress init: skill "${skill}" not found or has no starter. ` +
|
|
26
|
-
`Available style packs: ${available.join(", ") || "(none)"}`,
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
throw error;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (!force) {
|
|
33
|
-
try {
|
|
34
|
-
const stat = await fs.stat(targetPath);
|
|
35
|
-
if (stat.isDirectory()) {
|
|
36
|
-
const entries = await fs.readdir(targetPath);
|
|
37
|
-
if (entries.length > 0) {
|
|
38
|
-
throw new Error(`openpress init: target ${targetPath} exists and is not empty. Pass --force to overwrite.`);
|
|
39
|
-
}
|
|
40
|
-
} else {
|
|
41
|
-
throw new Error(`openpress init: target ${targetPath} exists and is not a directory.`);
|
|
42
|
-
}
|
|
43
|
-
} catch (error) {
|
|
44
|
-
if (error?.code !== "ENOENT") throw error;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
await fs.mkdir(targetPath, { recursive: true });
|
|
49
|
-
await copyDirectory(starterPath, targetPath);
|
|
50
|
-
|
|
51
|
-
return { targetPath, skill };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export async function listStylePackSkills() {
|
|
55
|
-
try {
|
|
56
|
-
const entries = await fs.readdir(SKILLS_DIR, { withFileTypes: true });
|
|
57
|
-
const names = [];
|
|
58
|
-
for (const entry of entries) {
|
|
59
|
-
if (!entry.isDirectory()) continue;
|
|
60
|
-
const starter = path.join(SKILLS_DIR, entry.name, "starter");
|
|
61
|
-
try {
|
|
62
|
-
const stat = await fs.stat(starter);
|
|
63
|
-
if (stat.isDirectory()) names.push(entry.name);
|
|
64
|
-
} catch {
|
|
65
|
-
// skill without starter/ is not a style pack — skip
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return names.sort();
|
|
69
|
-
} catch (error) {
|
|
70
|
-
if (error?.code === "ENOENT") return [];
|
|
71
|
-
throw error;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function copyDirectory(source, destination) {
|
|
76
|
-
await fs.mkdir(destination, { recursive: true });
|
|
77
|
-
for (const entry of await fs.readdir(source, { withFileTypes: true })) {
|
|
78
|
-
if (entry.name === ".DS_Store") continue;
|
|
79
|
-
const sourcePath = path.join(source, entry.name);
|
|
80
|
-
const destPath = path.join(destination, entry.name);
|
|
81
|
-
if (entry.isDirectory()) {
|
|
82
|
-
await copyDirectory(sourcePath, destPath);
|
|
83
|
-
} else if (entry.isFile()) {
|
|
84
|
-
await fs.copyFile(sourcePath, destPath);
|
|
85
|
-
} else if (entry.isSymbolicLink()) {
|
|
86
|
-
const link = await fs.readlink(sourcePath);
|
|
87
|
-
await fs.symlink(link, destPath);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ChildProcess } from "node:child_process";
|
|
2
|
-
|
|
3
|
-
export interface ChromeDevToolsClient {
|
|
4
|
-
send(method: string, params?: Record<string, unknown>): Promise<any>;
|
|
5
|
-
close(): void;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export interface PrintUrlToPdfOptions {
|
|
9
|
-
root: string;
|
|
10
|
-
url: string;
|
|
11
|
-
outPath: string;
|
|
12
|
-
chrome?: string;
|
|
13
|
-
waitForReady?: (client: ChromeDevToolsClient) => Promise<unknown>;
|
|
14
|
-
printOptions?: Record<string, unknown>;
|
|
15
|
-
debuggingPortBase?: number;
|
|
16
|
-
debuggingPortRange?: number;
|
|
17
|
-
profilePrefix?: string;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export interface EvaluateUrlWithChromeOptions {
|
|
21
|
-
root: string;
|
|
22
|
-
url: string;
|
|
23
|
-
chrome?: string;
|
|
24
|
-
evaluate: (client: ChromeDevToolsClient) => Promise<unknown>;
|
|
25
|
-
emulatedMedia?: "screen" | "print" | "none";
|
|
26
|
-
debuggingPortBase?: number;
|
|
27
|
-
debuggingPortRange?: number;
|
|
28
|
-
profilePrefix?: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function printUrlToPdf(options: PrintUrlToPdfOptions): Promise<unknown>;
|
|
32
|
-
export function evaluateUrlWithChrome(options: EvaluateUrlWithChromeOptions): Promise<unknown>;
|
|
33
|
-
export function waitForPrintReady(client: ChromeDevToolsClient): Promise<number>;
|
|
34
|
-
export function stopChildProcess(child: ChildProcess): Promise<void>;
|