connore 0.1.0 → 0.2.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 +58 -46
- package/package.json +36 -33
- package/packs/CONTRIBUTING.md +32 -0
- package/packs/base/catalog/README.md +24 -0
- package/packs/base/catalog/api.md +46 -0
- package/packs/base/catalog/auth.md +46 -0
- package/packs/base/catalog/backend.md +46 -0
- package/packs/base/catalog/blueprints.md +46 -0
- package/packs/base/catalog/components.md +46 -0
- package/packs/base/catalog/database.md +46 -0
- package/packs/base/catalog/docs.md +46 -0
- package/packs/base/catalog/github.md +46 -0
- package/packs/base/catalog/golden.md +46 -0
- package/packs/base/catalog/motion.md +46 -0
- package/packs/base/catalog/plan.md +46 -0
- package/packs/base/catalog/screenshots.md +46 -0
- package/packs/base/catalog/skills.md +46 -0
- package/packs/base/catalog/tokens.md +47 -0
- package/packs/base/planning/START.md +29 -0
- package/packs/base/planning/blueprint-template.md +46 -0
- package/packs/base/planning/plan-template.md +46 -0
- package/packs/base/rules/anti-patterns.md +46 -0
- package/packs/base/rules/code-style.md +46 -0
- package/packs/base/rules/definition-of-done.md +47 -0
- package/packs/base/rules/dependency-policy.md +46 -0
- package/packs/base/rules/error-handling.md +46 -0
- package/packs/base/rules/security-audit.md +47 -0
- package/packs/base/rules/security-baseline.md +46 -0
- package/packs/base/templates/bug-report.md +46 -0
- package/packs/base/templates/feature-spec.md +46 -0
- package/packs/base/templates/handoff.md +46 -0
- package/packs/base/templates/project-brief.md +46 -0
- package/packs/base/workflow/build-loop.md +48 -0
- package/packs/base/workflow/code-review.md +46 -0
- package/packs/base/workflow/debugging.md +47 -0
- package/packs/base/workflow/git-and-commits.md +46 -0
- package/packs/base/workflow/idea-to-spec.md +46 -0
- package/packs/base/workflow/session-handoff.md +46 -0
- package/packs/base/workflow/spec-to-plan.md +46 -0
- package/packs/knowledge/backend/api/conventions.md +21 -0
- package/packs/knowledge/backend/architecture/local-sqlite.md +20 -0
- package/packs/knowledge/backend/authentication/session-and-engine.md +24 -0
- package/packs/knowledge/backend/database/schema.md +21 -0
- package/packs/knowledge/components/custom/ambient-background.md +26 -0
- package/packs/knowledge/components/custom/ambient-background.tsx +12 -0
- package/packs/knowledge/components/custom/corner-frame.md +26 -0
- package/packs/knowledge/components/custom/corner-frame.tsx +48 -0
- package/packs/knowledge/components/custom/cta-button.md +26 -0
- package/packs/knowledge/components/custom/cta-button.tsx +10 -0
- package/packs/knowledge/components/custom/page-transition.md +26 -0
- package/packs/knowledge/components/custom/page-transition.tsx +10 -0
- package/packs/knowledge/components/custom/smooth-scroll.md +26 -0
- package/packs/knowledge/components/custom/smooth-scroll.tsx +32 -0
- package/packs/knowledge/components/motion-effects/README.md +30 -0
- package/packs/knowledge/components/ui-primitives/LICENSE +21 -0
- package/packs/knowledge/components/ui-primitives/README.md +22 -0
- package/packs/knowledge/components/ui-primitives/badge.md +26 -0
- package/packs/knowledge/components/ui-primitives/badge.tsx +48 -0
- package/packs/knowledge/components/ui-primitives/button.md +27 -0
- package/packs/knowledge/components/ui-primitives/button.tsx +66 -0
- package/packs/knowledge/components/ui-primitives/card.md +26 -0
- package/packs/knowledge/components/ui-primitives/card.tsx +102 -0
- package/packs/knowledge/components/ui-primitives/checkbox.md +26 -0
- package/packs/knowledge/components/ui-primitives/checkbox.tsx +32 -0
- package/packs/knowledge/components/ui-primitives/dialog.md +26 -0
- package/packs/knowledge/components/ui-primitives/dialog.tsx +168 -0
- package/packs/knowledge/components/ui-primitives/dropdown-menu.md +26 -0
- package/packs/knowledge/components/ui-primitives/dropdown-menu.tsx +268 -0
- package/packs/knowledge/components/ui-primitives/input.md +27 -0
- package/packs/knowledge/components/ui-primitives/input.tsx +18 -0
- package/packs/knowledge/components/ui-primitives/label.md +26 -0
- package/packs/knowledge/components/ui-primitives/label.tsx +23 -0
- package/packs/knowledge/components/ui-primitives/progress.md +26 -0
- package/packs/knowledge/components/ui-primitives/progress.tsx +30 -0
- package/packs/knowledge/components/ui-primitives/scroll-area.md +26 -0
- package/packs/knowledge/components/ui-primitives/scroll-area.tsx +54 -0
- package/packs/knowledge/components/ui-primitives/select.md +26 -0
- package/packs/knowledge/components/ui-primitives/select.tsx +191 -0
- package/packs/knowledge/components/ui-primitives/separator.md +26 -0
- package/packs/knowledge/components/ui-primitives/separator.tsx +27 -0
- package/packs/knowledge/components/ui-primitives/sonner.md +26 -0
- package/packs/knowledge/components/ui-primitives/sonner.tsx +49 -0
- package/packs/knowledge/components/ui-primitives/switch.md +26 -0
- package/packs/knowledge/components/ui-primitives/switch.tsx +32 -0
- package/packs/knowledge/components/ui-primitives/tabs.md +26 -0
- package/packs/knowledge/components/ui-primitives/tabs.tsx +89 -0
- package/packs/knowledge/components/ui-primitives/textarea.md +26 -0
- package/packs/knowledge/components/ui-primitives/textarea.tsx +17 -0
- package/packs/knowledge/components/ui-primitives/tooltip.md +26 -0
- package/packs/knowledge/components/ui-primitives/tooltip.tsx +56 -0
- package/packs/knowledge/design/aesthetics/app-shell.md +41 -0
- package/packs/knowledge/design/aesthetics/code-neutral.md +40 -0
- package/packs/knowledge/design/aesthetics/match.md +46 -0
- package/packs/knowledge/design/aesthetics/ruled-outline.md +40 -0
- package/packs/knowledge/design/aesthetics/solid-accent.md +43 -0
- package/packs/knowledge/design/animations/motion.md +40 -0
- package/packs/knowledge/design/project-style.md +50 -0
- package/packs/knowledge/design/references/benefit-card-grid.md +27 -0
- package/packs/knowledge/design/references/benefit-card-grid.png +0 -0
- package/packs/knowledge/design/references/cta-centered.md +27 -0
- package/packs/knowledge/design/references/cta-centered.png +0 -0
- package/packs/knowledge/design/references/cta-split-media.md +27 -0
- package/packs/knowledge/design/references/cta-split-media.png +0 -0
- package/packs/knowledge/design/references/dashboard-overview.md +31 -0
- package/packs/knowledge/design/references/dashboard-overview.png +0 -0
- package/packs/knowledge/design/references/faq-split-accordion.md +27 -0
- package/packs/knowledge/design/references/faq-split-accordion.png +0 -0
- package/packs/knowledge/design/references/feature-split-checklist.md +27 -0
- package/packs/knowledge/design/references/feature-split-checklist.png +0 -0
- package/packs/knowledge/design/references/footer-four-column.md +27 -0
- package/packs/knowledge/design/references/footer-four-column.png +0 -0
- package/packs/knowledge/design/references/footer-two-column.md +27 -0
- package/packs/knowledge/design/references/footer-two-column.png +0 -0
- package/packs/knowledge/design/references/hero-accent-curtain.md +27 -0
- package/packs/knowledge/design/references/hero-accent-curtain.png +0 -0
- package/packs/knowledge/design/references/hero-split-media.md +27 -0
- package/packs/knowledge/design/references/hero-split-media.png +0 -0
- package/packs/knowledge/design/references/logo-cloud-grid.md +27 -0
- package/packs/knowledge/design/references/logo-cloud-grid.png +0 -0
- package/packs/knowledge/design/references/logo-row-ruled.md +27 -0
- package/packs/knowledge/design/references/logo-row-ruled.png +0 -0
- package/packs/knowledge/design/references/pricing-three-card.md +27 -0
- package/packs/knowledge/design/references/pricing-three-card.png +0 -0
- package/packs/knowledge/design/references/steps-ruled-grid.md +27 -0
- package/packs/knowledge/design/references/steps-ruled-grid.png +0 -0
- package/packs/knowledge/design/rules.md +35 -0
- package/packs/knowledge/design/token-structure.md +46 -0
- package/packs/knowledge/design/tokens.md +55 -0
- package/packs/knowledge/frontend/README.md +50 -0
- package/packs/knowledge/frontend/SOURCES.md +40 -0
- package/packs/knowledge/frontend/accessibility/focus-and-dialogs.md +47 -0
- package/packs/knowledge/frontend/accessibility/semantics-and-keyboard.md +45 -0
- package/packs/knowledge/frontend/accessibility/wcag-targets.md +43 -0
- package/packs/knowledge/frontend/architecture/agent-context-files.md +43 -0
- package/packs/knowledge/frontend/architecture/app-foundations.md +43 -0
- package/packs/knowledge/frontend/architecture/error-handling.md +47 -0
- package/packs/knowledge/frontend/architecture/feature-modules.md +49 -0
- package/packs/knowledge/frontend/architecture/import-boundaries.md +44 -0
- package/packs/knowledge/frontend/architecture/naming.md +43 -0
- package/packs/knowledge/frontend/architecture/project-structure.md +48 -0
- package/packs/knowledge/frontend/architecture/routing.md +45 -0
- package/packs/knowledge/frontend/architecture/security.md +44 -0
- package/packs/knowledge/frontend/architecture/typescript.md +44 -0
- package/packs/knowledge/frontend/components/composition.md +45 -0
- package/packs/knowledge/frontend/components/data-display.md +47 -0
- package/packs/knowledge/frontend/components/library-choice.md +45 -0
- package/packs/knowledge/frontend/components/variants.md +44 -0
- package/packs/knowledge/frontend/forms/form-architecture.md +49 -0
- package/packs/knowledge/frontend/forms/multi-step.md +43 -0
- package/packs/knowledge/frontend/forms/validation.md +47 -0
- package/packs/knowledge/frontend/layout/responsive.md +41 -0
- package/packs/knowledge/frontend/page-blueprints/app-shell.md +16 -0
- package/packs/knowledge/frontend/page-blueprints/faq-footer.md +22 -0
- package/packs/knowledge/frontend/page-blueprints/feature-grid.md +22 -0
- package/packs/knowledge/frontend/page-blueprints/pricing.md +16 -0
- package/packs/knowledge/frontend/page-blueprints/saas-hero.md +24 -0
- package/packs/knowledge/frontend/patterns/dark-marketing.md +18 -0
- package/packs/knowledge/frontend/patterns/status-pill.md +19 -0
- package/packs/knowledge/frontend/performance/code-splitting.md +47 -0
- package/packs/knowledge/frontend/performance/images-and-vitals.md +44 -0
- package/packs/knowledge/frontend/performance/rendering.md +40 -0
- package/packs/knowledge/frontend/rendering/server-and-client.md +50 -0
- package/packs/knowledge/frontend/state/api-layer.md +49 -0
- package/packs/knowledge/frontend/state/async-ui-states.md +43 -0
- package/packs/knowledge/frontend/state/client-store.md +46 -0
- package/packs/knowledge/frontend/state/server-cache.md +42 -0
- package/packs/knowledge/frontend/state/state-categories.md +50 -0
- package/packs/knowledge/frontend/testing/component-tests.md +44 -0
- package/packs/knowledge/frontend/testing/strategy.md +46 -0
- package/packs/knowledge/inbox/README.md +14 -0
- package/packs/knowledge/workflows/authentication.md +18 -0
- package/packs/knowledge/workflows/crud.md +20 -0
- package/packs/knowledge/workflows/dashboard.md +22 -0
- package/packs/nextjs-fullstack/backend/api-conventions.md +48 -0
- package/packs/nextjs-fullstack/backend/auth-and-roles.md +46 -0
- package/packs/nextjs-fullstack/backend/background-jobs.md +46 -0
- package/packs/nextjs-fullstack/backend/caching.md +46 -0
- package/packs/nextjs-fullstack/backend/database.md +46 -0
- package/packs/nextjs-fullstack/backend/file-uploads.md +46 -0
- package/packs/nextjs-fullstack/backend/logging.md +46 -0
- package/packs/nextjs-fullstack/backend/migrations.md +46 -0
- package/packs/nextjs-fullstack/backend/rate-limiting.md +46 -0
- package/packs/nextjs-fullstack/backend/secrets-and-env.md +46 -0
- package/packs/nextjs-fullstack/backend/validation.md +46 -0
- package/packs/nextjs-fullstack/blueprints/ai-app.md +84 -0
- package/packs/nextjs-fullstack/blueprints/internal-tool.md +83 -0
- package/packs/nextjs-fullstack/blueprints/saas-app.md +83 -0
- package/packs/nextjs-fullstack/build-deploy/ci.md +45 -0
- package/packs/nextjs-fullstack/build-deploy/deploy.md +46 -0
- package/packs/nextjs-fullstack/build-deploy/monitoring.md +45 -0
- package/packs/nextjs-fullstack/build-deploy/performance.md +46 -0
- package/packs/nextjs-fullstack/build-deploy/project-structure.md +45 -0
- package/packs/nextjs-fullstack/build-deploy/release-checklist.md +47 -0
- package/packs/nextjs-fullstack/build-deploy/testing.md +46 -0
- package/packs/nextjs-fullstack/evals/README.md +46 -0
- package/packs/nextjs-fullstack/examples/golden-app/README.md +45 -0
- package/packs/nextjs-fullstack/frontend/accessibility.md +46 -0
- package/packs/nextjs-fullstack/frontend/components.md +46 -0
- package/packs/nextjs-fullstack/frontend/copy.md +46 -0
- package/packs/nextjs-fullstack/frontend/data-fetching.md +46 -0
- package/packs/nextjs-fullstack/frontend/forms.md +46 -0
- package/packs/nextjs-fullstack/frontend/layout.md +46 -0
- package/packs/nextjs-fullstack/frontend/loading-empty-error.md +46 -0
- package/packs/nextjs-fullstack/frontend/motion.md +46 -0
- package/packs/nextjs-fullstack/frontend/responsive.md +46 -0
- package/packs/nextjs-fullstack/frontend/seo.md +47 -0
- package/packs/nextjs-fullstack/frontend/tables.md +46 -0
- package/packs/nextjs-fullstack/frontend/tokens.md +45 -0
- package/packs/nextjs-fullstack/integrations/analytics.md +46 -0
- package/packs/nextjs-fullstack/integrations/email.md +46 -0
- package/packs/nextjs-fullstack/integrations/llm-apis.md +46 -0
- package/packs/nextjs-fullstack/integrations/oauth.md +46 -0
- package/packs/nextjs-fullstack/integrations/object-storage.md +46 -0
- package/packs/nextjs-fullstack/integrations/payments.md +46 -0
- package/packs/nextjs-fullstack/integrations/queues.md +46 -0
- package/packs/nextjs-fullstack/integrations/search.md +46 -0
- package/packs/nextjs-fullstack/integrations/webhooks.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-ai-feature.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-auth.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-billing.md +50 -0
- package/packs/nextjs-fullstack/playbooks/add-crud.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-email.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-file-upload.md +46 -0
- package/packs/nextjs-fullstack/playbooks/add-webhook.md +46 -0
- package/packs/nextjs-fullstack/playbooks/ship-to-prod.md +47 -0
- package/plugins/connore/.claude-plugin/plugin.json +10 -0
- package/plugins/connore/hooks/hooks.json +16 -0
- package/plugins/connore/skills/connore-backend/SKILL.md +32 -0
- package/plugins/connore/skills/connore-handoff/SKILL.md +15 -0
- package/plugins/connore/skills/connore-routes/SKILL.md +16 -0
- package/plugins/connore/skills/connore-validate/SKILL.md +15 -0
- package/src/cli.js +377 -90
- package/src/commands/add.js +61 -57
- package/src/commands/catalog.js +21 -0
- package/src/commands/doctor.js +44 -0
- package/src/commands/edit.js +88 -0
- package/src/commands/graph.js +20 -0
- package/src/commands/handoff.js +45 -0
- package/src/commands/hook.js +67 -50
- package/src/commands/init.js +74 -55
- package/src/commands/learn.js +39 -0
- package/src/commands/lint.js +13 -0
- package/src/commands/list.js +10 -10
- package/src/commands/log.js +49 -0
- package/src/commands/memory.js +14 -0
- package/src/commands/packs.js +21 -0
- package/src/commands/plan.js +41 -0
- package/src/commands/reindex.js +8 -8
- package/src/commands/review.js +31 -0
- package/src/commands/routes.js +13 -0
- package/src/commands/search.js +26 -0
- package/src/commands/stats.js +35 -0
- package/src/commands/undo.js +7 -0
- package/src/commands/update.js +20 -14
- package/src/lib/catalog.js +32 -0
- package/src/lib/config.js +67 -0
- package/src/lib/fs-safe.js +36 -11
- package/src/lib/gitlog.js +75 -0
- package/src/lib/graph.js +96 -0
- package/src/lib/ignore.js +47 -0
- package/src/lib/index.js +88 -57
- package/src/lib/lessons.js +173 -0
- package/src/lib/lint.js +185 -0
- package/src/lib/lock.js +47 -0
- package/src/lib/memory.js +49 -0
- package/src/lib/mutate.js +26 -0
- package/src/lib/packs.js +25 -0
- package/src/lib/paths.js +6 -2
- package/src/lib/plan.js +156 -0
- package/src/lib/pointers.js +3 -3
- package/src/lib/prompts.js +66 -0
- package/src/lib/provider.js +27 -0
- package/src/lib/report.js +41 -17
- package/src/lib/routes.js +59 -0
- package/src/lib/run.js +116 -0
- package/src/lib/search.js +64 -0
- package/src/lib/secrets.js +25 -0
- package/src/lib/signals.js +55 -0
- package/src/lib/sync.js +20 -12
- package/src/lib/tokens.js +8 -0
package/src/cli.js
CHANGED
|
@@ -1,90 +1,377 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
1
|
+
import { readFile } from "node:fs/promises"
|
|
2
|
+
import { join } from "node:path"
|
|
3
|
+
import { add } from "./commands/add.js"
|
|
4
|
+
import { catalog } from "./commands/catalog.js"
|
|
5
|
+
import { doctor } from "./commands/doctor.js"
|
|
6
|
+
import { edit, remove } from "./commands/edit.js"
|
|
7
|
+
import { graph } from "./commands/graph.js"
|
|
8
|
+
import { handoff } from "./commands/handoff.js"
|
|
9
|
+
import { packs } from "./commands/packs.js"
|
|
10
|
+
import { printIndex } from "./commands/hook.js"
|
|
11
|
+
import { init } from "./commands/init.js"
|
|
12
|
+
import { learn } from "./commands/learn.js"
|
|
13
|
+
import { lint } from "./commands/lint.js"
|
|
14
|
+
import { list } from "./commands/list.js"
|
|
15
|
+
import { memory } from "./commands/memory.js"
|
|
16
|
+
import { log } from "./commands/log.js"
|
|
17
|
+
import { plan } from "./commands/plan.js"
|
|
18
|
+
import { search } from "./commands/search.js"
|
|
19
|
+
import { reindex } from "./commands/reindex.js"
|
|
20
|
+
import { routes } from "./commands/routes.js"
|
|
21
|
+
import { review } from "./commands/review.js"
|
|
22
|
+
import { stats } from "./commands/stats.js"
|
|
23
|
+
import { undo } from "./commands/undo.js"
|
|
24
|
+
import { update } from "./commands/update.js"
|
|
25
|
+
import { ensureConfig } from "./lib/config.js"
|
|
26
|
+
import { readOptional } from "./lib/fs-safe.js"
|
|
27
|
+
import { withLock } from "./lib/lock.js"
|
|
28
|
+
import { packDir } from "./lib/packs.js"
|
|
29
|
+
import { packRoot } from "./lib/paths.js"
|
|
30
|
+
import { parseTools } from "./lib/pointers.js"
|
|
31
|
+
import { createReport } from "./lib/report.js"
|
|
32
|
+
import { closeRun, openRun, sealRun } from "./lib/run.js"
|
|
33
|
+
|
|
34
|
+
const USAGE = `connore <command> [options]
|
|
35
|
+
|
|
36
|
+
init [--tools all|claude,cursor,codex,copilot,windsurf,gemini] [--pack knowledge] [--hooks] [--include-drafts] [--dry-run] [--json]
|
|
37
|
+
add <path> [--type t] [--tags a,b] [--dry-run] [--json]
|
|
38
|
+
edit mine/<file>.md [--title t] [--description d] [--tags a,b] [--text body] [--json]
|
|
39
|
+
remove mine/<file>.md [--json]
|
|
40
|
+
update [--pack name] [--include-drafts] [--dry-run] [--json]
|
|
41
|
+
list [--json]
|
|
42
|
+
index [--include-drafts] [--dry-run] [--json]
|
|
43
|
+
hook [--json]
|
|
44
|
+
lint [--strict] [--json]
|
|
45
|
+
doctor [--json]
|
|
46
|
+
graph [--include-drafts] [--json]
|
|
47
|
+
packs [--json]
|
|
48
|
+
undo [--json]
|
|
49
|
+
log <decision|fix|failure|note> "text" [--files a,b] [--json]
|
|
50
|
+
memory [project|architecture|decision|agent|preferences|task|knowledge] ["text"] [--json]
|
|
51
|
+
catalog [--json]
|
|
52
|
+
learn [--input file] [--yes] [--json]
|
|
53
|
+
review [accept|reject|edit <id>] [--mistake text] [--fix text] [--json]
|
|
54
|
+
stats [--json]
|
|
55
|
+
search "query" [--related] [--include-drafts] [--json]
|
|
56
|
+
routes [--include-drafts] [--dry-run] [--json]
|
|
57
|
+
handoff ["note"] [--json]
|
|
58
|
+
plan init <blueprint> | status | next | done <task> [--json]
|
|
59
|
+
|
|
60
|
+
--version print the package version
|
|
61
|
+
--help print this message
|
|
62
|
+
`
|
|
63
|
+
|
|
64
|
+
const VALUE_FLAGS = new Set(["--tools", "--pack", "--type", "--tags", "--files", "--mistake", "--fix", "--input", "--title", "--description", "--text"])
|
|
65
|
+
const WRITES = new Set(["init", "add", "update", "index", "undo", "log", "learn", "review", "plan", "memory", "routes", "handoff", "edit", "remove"])
|
|
66
|
+
|
|
67
|
+
function usage(message) {
|
|
68
|
+
const error = new Error(message)
|
|
69
|
+
error.exitCode = 2
|
|
70
|
+
return error
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function parse(argv) {
|
|
74
|
+
const flags = { dryRun: false, hooks: false, json: false, includeDrafts: false, yes: false, strict: false }
|
|
75
|
+
const positionals = []
|
|
76
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
77
|
+
const arg = argv[index]
|
|
78
|
+
if (arg === "--dry-run") flags.dryRun = true
|
|
79
|
+
else if (arg === "--hooks") flags.hooks = true
|
|
80
|
+
else if (arg === "--json") flags.json = true
|
|
81
|
+
else if (arg === "--include-drafts") flags.includeDrafts = true
|
|
82
|
+
else if (arg === "--yes") flags.yes = true
|
|
83
|
+
else if (arg === "--strict") flags.strict = true
|
|
84
|
+
else if (arg === "--related") flags.related = true
|
|
85
|
+
else if (arg === "--version" || arg === "-v") flags.version = true
|
|
86
|
+
else if (arg === "--help" || arg === "-h") flags.help = true
|
|
87
|
+
else if (VALUE_FLAGS.has(arg)) {
|
|
88
|
+
const value = argv[index + 1]
|
|
89
|
+
if (!value || value.startsWith("--")) throw usage(`Missing value for ${arg}.`)
|
|
90
|
+
flags[arg.slice(2)] = value
|
|
91
|
+
index += 1
|
|
92
|
+
} else if (arg.startsWith("--")) throw usage(`Unknown flag ${arg}.`)
|
|
93
|
+
else positionals.push(arg)
|
|
94
|
+
}
|
|
95
|
+
return { command: positionals[0], args: positionals.slice(1), flags }
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function printJson(stdout, payload) {
|
|
99
|
+
stdout.write(`${JSON.stringify(payload)}\n`)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export async function run(argv, io = {}) {
|
|
103
|
+
const stdout = io.stdout || process.stdout
|
|
104
|
+
const stderr = io.stderr || process.stderr
|
|
105
|
+
const cwd = io.cwd || process.cwd()
|
|
106
|
+
let flags = { json: argv.includes("--json") }
|
|
107
|
+
try {
|
|
108
|
+
const parsed = parse(argv)
|
|
109
|
+
flags = parsed.flags
|
|
110
|
+
const { command, args } = parsed
|
|
111
|
+
if (flags.version) {
|
|
112
|
+
const pkg = JSON.parse(await readFile(join(packRoot, "package.json"), "utf8"))
|
|
113
|
+
if (flags.json) printJson(stdout, { ok: true, version: pkg.version })
|
|
114
|
+
else stdout.write(`${pkg.version}\n`)
|
|
115
|
+
return 0
|
|
116
|
+
}
|
|
117
|
+
if (flags.help) {
|
|
118
|
+
stdout.write(USAGE)
|
|
119
|
+
return 0
|
|
120
|
+
}
|
|
121
|
+
if (!command) {
|
|
122
|
+
if (flags.json) printJson(stdout, { ok: false, error: "Missing command." })
|
|
123
|
+
else stdout.write(USAGE)
|
|
124
|
+
return 2
|
|
125
|
+
}
|
|
126
|
+
if (command === "init") {
|
|
127
|
+
if (args.length) throw usage("init does not take a path. Run it inside the project.")
|
|
128
|
+
if (flags.tools) {
|
|
129
|
+
try {
|
|
130
|
+
parseTools(flags.tools)
|
|
131
|
+
} catch (error) {
|
|
132
|
+
error.exitCode = 2
|
|
133
|
+
throw error
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
await packDir(flags.pack || "knowledge")
|
|
138
|
+
} catch (error) {
|
|
139
|
+
error.exitCode = 2
|
|
140
|
+
throw error
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const report = createReport(flags.dryRun, { json: flags.json })
|
|
144
|
+
const body = async () => {
|
|
145
|
+
if (command !== "init" && WRITES.has(command)) {
|
|
146
|
+
if (!(await readOptional(join(cwd, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
|
|
147
|
+
await ensureConfig(cwd, report)
|
|
148
|
+
}
|
|
149
|
+
if (command === "init") {
|
|
150
|
+
await init(cwd, flags, report)
|
|
151
|
+
report.print(stdout)
|
|
152
|
+
return
|
|
153
|
+
}
|
|
154
|
+
if (flags.hooks) throw usage("--hooks is only valid with init.")
|
|
155
|
+
if (flags.tools) throw usage("--tools is only valid with init.")
|
|
156
|
+
if (command === "edit") {
|
|
157
|
+
if (args.length !== 1) throw usage("Usage: connore edit mine/<file>.md [--title t] [--description d] [--tags a,b] [--text body].")
|
|
158
|
+
const result = await edit(cwd, args[0], flags, report)
|
|
159
|
+
if (flags.json) printJson(stdout, { ok: true, ...result, summary: countEvents(report) })
|
|
160
|
+
else report.print(stdout)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
if (command === "remove") {
|
|
164
|
+
if (args.length !== 1) throw usage("Usage: connore remove mine/<file>.md.")
|
|
165
|
+
const result = await remove(cwd, args[0], report)
|
|
166
|
+
if (flags.json) printJson(stdout, { ok: true, ...result, summary: countEvents(report) })
|
|
167
|
+
else report.print(stdout)
|
|
168
|
+
return
|
|
169
|
+
}
|
|
170
|
+
if (command === "add") {
|
|
171
|
+
if (flags.pack) throw usage("--pack is only valid with init and update.")
|
|
172
|
+
if (args.length !== 1) throw usage("Usage: connore add <path>.")
|
|
173
|
+
await add(cwd, args[0], flags, report)
|
|
174
|
+
report.print(stdout)
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
if (flags.type || flags.tags) throw usage("--type and --tags are only valid with add.")
|
|
178
|
+
if (flags.title || flags.description || flags.text) throw usage("--title, --description, and --text are only valid with edit.")
|
|
179
|
+
if (command === "update") {
|
|
180
|
+
if (args.length) throw usage("update does not take a path.")
|
|
181
|
+
await update(cwd, flags, report)
|
|
182
|
+
report.print(stdout)
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
if (flags.pack) throw usage("--pack is only valid with init and update.")
|
|
186
|
+
if (command === "list") {
|
|
187
|
+
if (flags.json) {
|
|
188
|
+
const { collectEntries } = await import("./lib/index.js")
|
|
189
|
+
if (!(await readOptional(join(cwd, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
|
|
190
|
+
printJson(stdout, { ok: true, entries: await collectEntries(cwd, { includeDrafts: flags.includeDrafts }) })
|
|
191
|
+
} else await list(cwd, stdout)
|
|
192
|
+
return
|
|
193
|
+
}
|
|
194
|
+
if (command === "index") {
|
|
195
|
+
await reindex(cwd, flags, report)
|
|
196
|
+
report.print(stdout)
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
if (command === "hook") {
|
|
200
|
+
let output = ""
|
|
201
|
+
await printIndex(cwd, { write(chunk) { output += chunk } })
|
|
202
|
+
if (flags.json) printJson(stdout, { ok: true, output })
|
|
203
|
+
else stdout.write(output)
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
if (command === "lint") {
|
|
207
|
+
const { errors, warnings, scope } = await lint(cwd, { includeDrafts: flags.includeDrafts })
|
|
208
|
+
const failed = errors.length > 0 || (flags.strict && warnings.length > 0)
|
|
209
|
+
printJsonish(stdout, flags, { ok: !failed, scope, errors, warnings }, () => {
|
|
210
|
+
for (const problem of errors) stdout.write(`error ${problem}\n`)
|
|
211
|
+
for (const problem of warnings) stdout.write(`warn ${problem}\n`)
|
|
212
|
+
if (!errors.length && !warnings.length) stdout.write(`lint clean (${scope})\n`)
|
|
213
|
+
else stdout.write(`${errors.length} errors, ${warnings.length} warnings (${scope})\n`)
|
|
214
|
+
})
|
|
215
|
+
if (failed) throw Object.assign(new Error("lint failed"), { exitCode: 1, handled: true })
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
if (command === "graph") {
|
|
219
|
+
if (args.length) throw usage("graph does not take a path.")
|
|
220
|
+
if (!(await readOptional(join(cwd, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
|
|
221
|
+
const code = await graph(cwd, flags, stdout)
|
|
222
|
+
if (code) throw Object.assign(new Error("graph found broken references"), { exitCode: 1, handled: true })
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
if (command === "packs") {
|
|
226
|
+
if (args.length) throw usage("packs does not take a path.")
|
|
227
|
+
await packs(cwd, flags, stdout)
|
|
228
|
+
return
|
|
229
|
+
}
|
|
230
|
+
if (command === "doctor") {
|
|
231
|
+
const problems = await doctor(cwd)
|
|
232
|
+
printJsonish(stdout, flags, { ok: problems.length === 0, problems }, () => {
|
|
233
|
+
for (const problem of problems) stdout.write(`${problem}\n`)
|
|
234
|
+
stdout.write(problems.length ? `${problems.length} problems\n` : "doctor clean\n")
|
|
235
|
+
})
|
|
236
|
+
if (problems.length) throw Object.assign(new Error("doctor failed"), { exitCode: 1, handled: true })
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
if (command === "undo") {
|
|
240
|
+
if (args.length) throw usage("undo does not take a path.")
|
|
241
|
+
await undo(cwd, report)
|
|
242
|
+
report.print(stdout)
|
|
243
|
+
return
|
|
244
|
+
}
|
|
245
|
+
if (command === "catalog") {
|
|
246
|
+
if (args.length) throw usage("catalog does not take a path.")
|
|
247
|
+
await catalog(cwd, flags, stdout)
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
if (command === "memory") {
|
|
251
|
+
await memory(cwd, args, report, stdout, flags)
|
|
252
|
+
if (args.length) report.print(stdout)
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
if (command === "log") {
|
|
256
|
+
if (args.length !== 2) throw usage('Usage: connore log <decision|fix|failure|note> "text".')
|
|
257
|
+
await log(cwd, args[0], args[1], flags, report)
|
|
258
|
+
report.print(stdout)
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
if (command === "learn") {
|
|
262
|
+
const result = await learn(cwd, flags, report, io)
|
|
263
|
+
if (flags.json) printJson(stdout, { ok: true, ...result, summary: countEvents(report) })
|
|
264
|
+
else {
|
|
265
|
+
if (!result.proposals) stdout.write("No pattern has 3 occurrences yet.\n")
|
|
266
|
+
else if (!result.wrote) stdout.write(`${result.preview}\nRe-run with --yes to write proposals.\n`)
|
|
267
|
+
report.print(stdout)
|
|
268
|
+
}
|
|
269
|
+
return
|
|
270
|
+
}
|
|
271
|
+
if (command === "review") {
|
|
272
|
+
const result = await review(cwd, args, flags, report)
|
|
273
|
+
if (!args[0]) {
|
|
274
|
+
if (flags.json) printJson(stdout, { ok: true, proposals: result.proposals })
|
|
275
|
+
else if (!result.proposals.length) stdout.write("No proposals.\n")
|
|
276
|
+
else {
|
|
277
|
+
for (const lesson of result.proposals) {
|
|
278
|
+
stdout.write(`${lesson.id}\t${lesson.evidence}\t${lesson.mistake}\n`)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
report.print(stdout)
|
|
284
|
+
return
|
|
285
|
+
}
|
|
286
|
+
if (command === "routes") {
|
|
287
|
+
if (args.length) throw usage("routes does not take a path.")
|
|
288
|
+
const text = await routes(cwd, flags, report)
|
|
289
|
+
if (flags.json) printJson(stdout, { ok: true, output: text, summary: countEvents(report) })
|
|
290
|
+
else {
|
|
291
|
+
stdout.write(text)
|
|
292
|
+
report.print(stdout)
|
|
293
|
+
}
|
|
294
|
+
return
|
|
295
|
+
}
|
|
296
|
+
if (command === "handoff") {
|
|
297
|
+
if (args.length > 1) throw usage('Usage: connore handoff "note".')
|
|
298
|
+
const result = await handoff(cwd, args[0] || "", report)
|
|
299
|
+
if (flags.json) printJson(stdout, { ok: true, ...result, summary: countEvents(report) })
|
|
300
|
+
else report.print(stdout)
|
|
301
|
+
return
|
|
302
|
+
}
|
|
303
|
+
if (command === "search") {
|
|
304
|
+
if (!args.length) throw usage('Usage: connore search "query".')
|
|
305
|
+
const results = await search(cwd, args.join(" "), flags)
|
|
306
|
+
if (flags.json) printJson(stdout, { ok: true, results })
|
|
307
|
+
else if (!results.length) stdout.write("No entries match.\n")
|
|
308
|
+
else {
|
|
309
|
+
for (const hit of results) stdout.write(`${hit.score}\t${hit.path}\t${hit.description}\n`)
|
|
310
|
+
}
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
if (command === "plan") {
|
|
314
|
+
if (!args.length) throw usage("Usage: connore plan init <blueprint> | status | next | done <task>.")
|
|
315
|
+
const view = await plan(cwd, args, report)
|
|
316
|
+
if (flags.json) printJson(stdout, { ok: true, ...view })
|
|
317
|
+
else {
|
|
318
|
+
stdout.write(`Phase ${view.phase}\nNext: ${view.next}\n`)
|
|
319
|
+
if (view.failedGate) stdout.write(`Failed gate: ${view.failedGate}\n`)
|
|
320
|
+
stdout.write(`${view.done}/${view.total} done\n`)
|
|
321
|
+
}
|
|
322
|
+
return
|
|
323
|
+
}
|
|
324
|
+
if (command === "stats") {
|
|
325
|
+
const data = await stats(cwd)
|
|
326
|
+
if (flags.json) printJson(stdout, { ok: true, ...data })
|
|
327
|
+
else if (!data.weeks.length) stdout.write("No signals yet.\n")
|
|
328
|
+
else {
|
|
329
|
+
for (const week of data.weeks) {
|
|
330
|
+
stdout.write(`${week.week}\tsignals ${week.signals}\taccepted ${week.accepted}\trecurring ${week.recurring}\n`)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return
|
|
334
|
+
}
|
|
335
|
+
throw usage(`Unknown command "${command}".`)
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// undo restores from a manifest, so it must not open one of its own: that
|
|
339
|
+
// manifest would be the newest and undo would read its own empty record.
|
|
340
|
+
const writeAhead = !flags.dryRun && WRITES.has(command) && command !== "undo"
|
|
341
|
+
const guarded = async () => {
|
|
342
|
+
const handle = writeAhead ? await openRun(cwd, command, report) : null
|
|
343
|
+
try {
|
|
344
|
+
await body()
|
|
345
|
+
} finally {
|
|
346
|
+
await closeRun(cwd, handle)
|
|
347
|
+
}
|
|
348
|
+
if (!writeAhead && !flags.dryRun && WRITES.has(command)) await sealRun(cwd, command, report)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
if (!flags.dryRun && WRITES.has(command) && (command === "init" || (await readOptional(join(cwd, ".ctx", "PROCESS.md"))))) {
|
|
352
|
+
await withLock(cwd, guarded)
|
|
353
|
+
} else {
|
|
354
|
+
await guarded()
|
|
355
|
+
}
|
|
356
|
+
return 0
|
|
357
|
+
} catch (error) {
|
|
358
|
+
if (error.handled) return error.exitCode || 1
|
|
359
|
+
const code = error.exitCode || 1
|
|
360
|
+
if (flags.json) printJson(stdout, { ok: false, error: error.message })
|
|
361
|
+
else stderr.write(`${error.message}\n`)
|
|
362
|
+
return code
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// Tests and embedders call this with a captured io.
|
|
367
|
+
export const main = run
|
|
368
|
+
|
|
369
|
+
function countEvents(report) {
|
|
370
|
+
const count = (kind) => report.events.filter((event) => event.kind === kind).length
|
|
371
|
+
return { created: count("created"), changed: count("changed"), skipped: count("skipped"), removed: count("removed") }
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function printJsonish(stdout, flags, payload, text) {
|
|
375
|
+
if (flags.json) printJson(stdout, payload)
|
|
376
|
+
else text()
|
|
377
|
+
}
|
package/src/commands/add.js
CHANGED
|
@@ -1,57 +1,61 @@
|
|
|
1
|
-
import { readFile, stat } from "node:fs/promises"
|
|
2
|
-
import { basename, join, relative, resolve } from "node:path"
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
1
|
+
import { readFile, stat } from "node:fs/promises"
|
|
2
|
+
import { basename, join, relative, resolve } from "node:path"
|
|
3
|
+
import { readConfig } from "../lib/config.js"
|
|
4
|
+
import { readOptional, walkFiles } from "../lib/fs-safe.js"
|
|
5
|
+
import { twinStub, today } from "../lib/frontmatter.js"
|
|
6
|
+
import { ignoreNames } from "../lib/ignore.js"
|
|
7
|
+
import { rebuildIndex } from "../lib/index.js"
|
|
8
|
+
import { commitWrite } from "../lib/mutate.js"
|
|
9
|
+
import { ctxPath, fromRoot } from "../lib/paths.js"
|
|
10
|
+
import { secretHits } from "../lib/secrets.js"
|
|
11
|
+
|
|
12
|
+
const TYPES = new Set(["design-token", "component", "rule", "screenshot", "flow", "doc"])
|
|
13
|
+
const IMAGE = /\.(png|jpe?g|webp|gif|svg)$/i
|
|
14
|
+
const CODE = /\.(tsx|jsx|ts|js|mjs|cjs|css)$/i
|
|
15
|
+
|
|
16
|
+
function defaultType(name) {
|
|
17
|
+
if (IMAGE.test(name)) return "screenshot"
|
|
18
|
+
if (CODE.test(name)) return "component"
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async function placeFile(source, target, root, flags, report) {
|
|
23
|
+
const display = fromRoot(root, target)
|
|
24
|
+
const bytes = await readFile(source)
|
|
25
|
+
const hits = secretHits(bytes.toString("utf8"))
|
|
26
|
+
if (hits.length) throw new Error(`Refusing to copy ${display} because it looks like a secret (${hits.join(", ")}).`)
|
|
27
|
+
if (await readOptional(target)) report.add("skipped", display)
|
|
28
|
+
else await commitWrite(target, bytes, report, display)
|
|
29
|
+
const type = flags.type || defaultType(basename(target))
|
|
30
|
+
if (!type || target.endsWith(".md")) return
|
|
31
|
+
const twin = target.replace(/\.[^.]+$/, ".md")
|
|
32
|
+
const twinDisplay = fromRoot(root, twin)
|
|
33
|
+
if (await readOptional(twin)) {
|
|
34
|
+
report.add("skipped", twinDisplay)
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
const tags = flags.tags ? flags.tags.split(",").map((tag) => tag.trim()).filter(Boolean) : []
|
|
38
|
+
const body = twinStub({ title: basename(twin, ".md"), type, tags, date: today() })
|
|
39
|
+
await commitWrite(twin, body, report, twinDisplay)
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export async function add(root, sourceArg, flags, report) {
|
|
43
|
+
if (flags.type && !TYPES.has(flags.type)) throw new Error(`Unknown type "${flags.type}".`)
|
|
44
|
+
if (!(await readOptional(join(root, ".ctx", "INDEX.md"))) && !(await readOptional(join(root, ".ctx", "PROCESS.md")))) {
|
|
45
|
+
throw new Error("No .ctx/ folder. Run connore init first.")
|
|
46
|
+
}
|
|
47
|
+
const source = resolve(root, sourceArg)
|
|
48
|
+
let info
|
|
49
|
+
try {
|
|
50
|
+
info = await stat(source)
|
|
51
|
+
} catch {
|
|
52
|
+
throw new Error(`Cannot read ${sourceArg}.`)
|
|
53
|
+
}
|
|
54
|
+
const mine = ctxPath(root, "mine")
|
|
55
|
+
const ignore = await ignoreNames(root, (await readConfig(root)).config)
|
|
56
|
+
if (info.isDirectory()) {
|
|
57
|
+
const files = await walkFiles(source, ignore)
|
|
58
|
+
for (const file of files) await placeFile(file, join(mine, basename(source), relative(source, file)), root, flags, report)
|
|
59
|
+
} else await placeFile(source, join(mine, basename(source)), root, flags, report)
|
|
60
|
+
await rebuildIndex(root, report, { includeDrafts: flags.includeDrafts })
|
|
61
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { join } from "node:path"
|
|
2
|
+
import { readOptional } from "../lib/fs-safe.js"
|
|
3
|
+
import { GROUPS, countGroup } from "../lib/catalog.js"
|
|
4
|
+
|
|
5
|
+
export async function catalog(root, flags, stdout) {
|
|
6
|
+
if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
|
|
7
|
+
const groups = []
|
|
8
|
+
for (const group of GROUPS) {
|
|
9
|
+
const count = await countGroup(root, group.id)
|
|
10
|
+
groups.push({ ...group, count, met: count >= group.target })
|
|
11
|
+
}
|
|
12
|
+
const started = groups.filter((group) => group.count > 0).length
|
|
13
|
+
if (flags.json) {
|
|
14
|
+
stdout.write(`${JSON.stringify({ ok: true, started, total: groups.length, groups })}\n`)
|
|
15
|
+
return
|
|
16
|
+
}
|
|
17
|
+
stdout.write(`${started}/${groups.length} groups started\n`)
|
|
18
|
+
for (const group of groups) {
|
|
19
|
+
stdout.write(`${group.count}/${group.target}\t${group.label}\t.ctx/mine/catalog/${group.id}\n`)
|
|
20
|
+
}
|
|
21
|
+
}
|