connore 0.1.1 → 0.2.1

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.
Files changed (238) hide show
  1. package/README.md +13 -8
  2. package/bin/ctxkit.js +5 -5
  3. package/package.json +2 -1
  4. package/packs/base/planning/START.md +29 -28
  5. package/packs/base/planning/blueprint-template.md +46 -46
  6. package/packs/base/planning/plan-template.md +46 -45
  7. package/packs/base/rules/anti-patterns.md +19 -16
  8. package/packs/base/rules/code-style.md +19 -16
  9. package/packs/base/rules/dependency-policy.md +19 -16
  10. package/packs/base/rules/error-handling.md +19 -16
  11. package/packs/base/rules/security-audit.md +47 -0
  12. package/packs/base/rules/security-baseline.md +19 -16
  13. package/packs/base/templates/bug-report.md +19 -16
  14. package/packs/base/templates/feature-spec.md +19 -16
  15. package/packs/base/templates/handoff.md +19 -16
  16. package/packs/base/templates/project-brief.md +19 -16
  17. package/packs/base/workflow/code-review.md +19 -16
  18. package/packs/base/workflow/debugging.md +18 -14
  19. package/packs/base/workflow/git-and-commits.md +19 -16
  20. package/packs/base/workflow/idea-to-spec.md +19 -16
  21. package/packs/base/workflow/session-handoff.md +19 -16
  22. package/packs/base/workflow/spec-to-plan.md +19 -16
  23. package/packs/knowledge/backend/api/conventions.md +21 -0
  24. package/packs/knowledge/backend/architecture/local-sqlite.md +20 -0
  25. package/packs/knowledge/backend/authentication/session-and-engine.md +24 -0
  26. package/packs/knowledge/backend/database/schema.md +21 -0
  27. package/packs/knowledge/components/custom/ambient-background.md +26 -0
  28. package/packs/knowledge/components/custom/ambient-background.tsx +12 -0
  29. package/packs/knowledge/components/custom/corner-frame.md +26 -0
  30. package/packs/knowledge/components/custom/corner-frame.tsx +48 -0
  31. package/packs/knowledge/components/custom/cta-button.md +26 -0
  32. package/packs/knowledge/components/custom/cta-button.tsx +10 -0
  33. package/packs/knowledge/components/custom/page-transition.md +26 -0
  34. package/packs/knowledge/components/custom/page-transition.tsx +10 -0
  35. package/packs/knowledge/components/custom/smooth-scroll.md +26 -0
  36. package/packs/knowledge/components/custom/smooth-scroll.tsx +32 -0
  37. package/packs/knowledge/components/motion-effects/README.md +30 -0
  38. package/packs/knowledge/components/ui-primitives/LICENSE +21 -0
  39. package/packs/knowledge/components/ui-primitives/README.md +22 -0
  40. package/packs/knowledge/components/ui-primitives/badge.md +26 -0
  41. package/packs/knowledge/components/ui-primitives/badge.tsx +48 -0
  42. package/packs/knowledge/components/ui-primitives/button.md +27 -0
  43. package/packs/knowledge/components/ui-primitives/button.tsx +66 -0
  44. package/packs/knowledge/components/ui-primitives/card.md +26 -0
  45. package/packs/knowledge/components/ui-primitives/card.tsx +102 -0
  46. package/packs/knowledge/components/ui-primitives/checkbox.md +26 -0
  47. package/packs/knowledge/components/ui-primitives/checkbox.tsx +32 -0
  48. package/packs/knowledge/components/ui-primitives/dialog.md +26 -0
  49. package/packs/knowledge/components/ui-primitives/dialog.tsx +168 -0
  50. package/packs/knowledge/components/ui-primitives/dropdown-menu.md +26 -0
  51. package/packs/knowledge/components/ui-primitives/dropdown-menu.tsx +268 -0
  52. package/packs/knowledge/components/ui-primitives/input.md +27 -0
  53. package/packs/knowledge/components/ui-primitives/input.tsx +18 -0
  54. package/packs/knowledge/components/ui-primitives/label.md +26 -0
  55. package/packs/knowledge/components/ui-primitives/label.tsx +23 -0
  56. package/packs/knowledge/components/ui-primitives/progress.md +26 -0
  57. package/packs/knowledge/components/ui-primitives/progress.tsx +30 -0
  58. package/packs/knowledge/components/ui-primitives/scroll-area.md +26 -0
  59. package/packs/knowledge/components/ui-primitives/scroll-area.tsx +54 -0
  60. package/packs/knowledge/components/ui-primitives/select.md +26 -0
  61. package/packs/knowledge/components/ui-primitives/select.tsx +191 -0
  62. package/packs/knowledge/components/ui-primitives/separator.md +26 -0
  63. package/packs/knowledge/components/ui-primitives/separator.tsx +27 -0
  64. package/packs/knowledge/components/ui-primitives/sonner.md +26 -0
  65. package/packs/knowledge/components/ui-primitives/sonner.tsx +49 -0
  66. package/packs/knowledge/components/ui-primitives/switch.md +26 -0
  67. package/packs/knowledge/components/ui-primitives/switch.tsx +32 -0
  68. package/packs/knowledge/components/ui-primitives/tabs.md +26 -0
  69. package/packs/knowledge/components/ui-primitives/tabs.tsx +89 -0
  70. package/packs/knowledge/components/ui-primitives/textarea.md +26 -0
  71. package/packs/knowledge/components/ui-primitives/textarea.tsx +17 -0
  72. package/packs/knowledge/components/ui-primitives/tooltip.md +26 -0
  73. package/packs/knowledge/components/ui-primitives/tooltip.tsx +56 -0
  74. package/packs/knowledge/design/aesthetics/app-shell.md +41 -0
  75. package/packs/knowledge/design/aesthetics/code-neutral.md +40 -0
  76. package/packs/knowledge/design/aesthetics/match.md +46 -0
  77. package/packs/knowledge/design/aesthetics/ruled-outline.md +40 -0
  78. package/packs/knowledge/design/aesthetics/solid-accent.md +43 -0
  79. package/packs/knowledge/design/animations/motion.md +40 -0
  80. package/packs/knowledge/design/project-style.md +50 -0
  81. package/packs/knowledge/design/references/benefit-card-grid.md +27 -0
  82. package/packs/knowledge/design/references/benefit-card-grid.png +0 -0
  83. package/packs/knowledge/design/references/cta-centered.md +27 -0
  84. package/packs/knowledge/design/references/cta-centered.png +0 -0
  85. package/packs/knowledge/design/references/cta-split-media.md +27 -0
  86. package/packs/knowledge/design/references/cta-split-media.png +0 -0
  87. package/packs/knowledge/design/references/dashboard-overview.md +31 -0
  88. package/packs/knowledge/design/references/dashboard-overview.png +0 -0
  89. package/packs/knowledge/design/references/faq-split-accordion.md +27 -0
  90. package/packs/knowledge/design/references/faq-split-accordion.png +0 -0
  91. package/packs/knowledge/design/references/feature-split-checklist.md +27 -0
  92. package/packs/knowledge/design/references/feature-split-checklist.png +0 -0
  93. package/packs/knowledge/design/references/footer-four-column.md +27 -0
  94. package/packs/knowledge/design/references/footer-four-column.png +0 -0
  95. package/packs/knowledge/design/references/footer-two-column.md +27 -0
  96. package/packs/knowledge/design/references/footer-two-column.png +0 -0
  97. package/packs/knowledge/design/references/hero-accent-curtain.md +27 -0
  98. package/packs/knowledge/design/references/hero-accent-curtain.png +0 -0
  99. package/packs/knowledge/design/references/hero-split-media.md +27 -0
  100. package/packs/knowledge/design/references/hero-split-media.png +0 -0
  101. package/packs/knowledge/design/references/logo-cloud-grid.md +27 -0
  102. package/packs/knowledge/design/references/logo-cloud-grid.png +0 -0
  103. package/packs/knowledge/design/references/logo-row-ruled.md +27 -0
  104. package/packs/knowledge/design/references/logo-row-ruled.png +0 -0
  105. package/packs/knowledge/design/references/pricing-three-card.md +27 -0
  106. package/packs/knowledge/design/references/pricing-three-card.png +0 -0
  107. package/packs/knowledge/design/references/steps-ruled-grid.md +27 -0
  108. package/packs/knowledge/design/references/steps-ruled-grid.png +0 -0
  109. package/packs/knowledge/design/rules.md +35 -0
  110. package/packs/knowledge/design/token-structure.md +46 -0
  111. package/packs/knowledge/design/tokens.md +55 -0
  112. package/packs/knowledge/frontend/README.md +50 -0
  113. package/packs/knowledge/frontend/SOURCES.md +40 -0
  114. package/packs/knowledge/frontend/accessibility/focus-and-dialogs.md +47 -0
  115. package/packs/knowledge/frontend/accessibility/semantics-and-keyboard.md +45 -0
  116. package/packs/knowledge/frontend/accessibility/wcag-targets.md +43 -0
  117. package/packs/knowledge/frontend/architecture/agent-context-files.md +43 -0
  118. package/packs/knowledge/frontend/architecture/app-foundations.md +43 -0
  119. package/packs/knowledge/frontend/architecture/error-handling.md +47 -0
  120. package/packs/knowledge/frontend/architecture/feature-modules.md +49 -0
  121. package/packs/knowledge/frontend/architecture/import-boundaries.md +44 -0
  122. package/packs/knowledge/frontend/architecture/naming.md +43 -0
  123. package/packs/knowledge/frontend/architecture/project-structure.md +48 -0
  124. package/packs/knowledge/frontend/architecture/routing.md +45 -0
  125. package/packs/knowledge/frontend/architecture/security.md +44 -0
  126. package/packs/knowledge/frontend/architecture/typescript.md +44 -0
  127. package/packs/knowledge/frontend/components/composition.md +45 -0
  128. package/packs/knowledge/frontend/components/data-display.md +47 -0
  129. package/packs/knowledge/frontend/components/library-choice.md +45 -0
  130. package/packs/knowledge/frontend/components/variants.md +44 -0
  131. package/packs/knowledge/frontend/forms/form-architecture.md +49 -0
  132. package/packs/knowledge/frontend/forms/multi-step.md +43 -0
  133. package/packs/knowledge/frontend/forms/validation.md +47 -0
  134. package/packs/knowledge/frontend/layout/responsive.md +41 -0
  135. package/packs/knowledge/frontend/page-blueprints/app-shell.md +16 -0
  136. package/packs/knowledge/frontend/page-blueprints/faq-footer.md +22 -0
  137. package/packs/knowledge/frontend/page-blueprints/feature-grid.md +22 -0
  138. package/packs/knowledge/frontend/page-blueprints/pricing.md +16 -0
  139. package/packs/knowledge/frontend/page-blueprints/saas-hero.md +24 -0
  140. package/packs/knowledge/frontend/patterns/dark-marketing.md +18 -0
  141. package/packs/knowledge/frontend/patterns/status-pill.md +19 -0
  142. package/packs/knowledge/frontend/performance/code-splitting.md +47 -0
  143. package/packs/knowledge/frontend/performance/images-and-vitals.md +44 -0
  144. package/packs/knowledge/frontend/performance/rendering.md +40 -0
  145. package/packs/knowledge/frontend/rendering/server-and-client.md +50 -0
  146. package/packs/knowledge/frontend/state/api-layer.md +49 -0
  147. package/packs/knowledge/frontend/state/async-ui-states.md +43 -0
  148. package/packs/knowledge/frontend/state/client-store.md +46 -0
  149. package/packs/knowledge/frontend/state/server-cache.md +42 -0
  150. package/packs/knowledge/frontend/state/state-categories.md +50 -0
  151. package/packs/knowledge/frontend/testing/component-tests.md +44 -0
  152. package/packs/knowledge/frontend/testing/strategy.md +46 -0
  153. package/packs/knowledge/inbox/README.md +14 -0
  154. package/packs/knowledge/workflows/authentication.md +18 -0
  155. package/packs/knowledge/workflows/crud.md +20 -0
  156. package/packs/knowledge/workflows/dashboard.md +22 -0
  157. package/packs/nextjs-fullstack/backend/auth-and-roles.md +19 -16
  158. package/packs/nextjs-fullstack/backend/background-jobs.md +19 -16
  159. package/packs/nextjs-fullstack/backend/caching.md +17 -14
  160. package/packs/nextjs-fullstack/backend/database.md +19 -16
  161. package/packs/nextjs-fullstack/backend/file-uploads.md +19 -16
  162. package/packs/nextjs-fullstack/backend/logging.md +17 -14
  163. package/packs/nextjs-fullstack/backend/migrations.md +17 -14
  164. package/packs/nextjs-fullstack/backend/rate-limiting.md +19 -16
  165. package/packs/nextjs-fullstack/backend/secrets-and-env.md +19 -16
  166. package/packs/nextjs-fullstack/backend/validation.md +19 -16
  167. package/packs/nextjs-fullstack/blueprints/ai-app.md +1 -1
  168. package/packs/nextjs-fullstack/blueprints/internal-tool.md +1 -1
  169. package/packs/nextjs-fullstack/blueprints/saas-app.md +1 -1
  170. package/packs/nextjs-fullstack/build-deploy/ci.md +18 -16
  171. package/packs/nextjs-fullstack/build-deploy/deploy.md +19 -16
  172. package/packs/nextjs-fullstack/build-deploy/monitoring.md +16 -14
  173. package/packs/nextjs-fullstack/build-deploy/performance.md +17 -14
  174. package/packs/nextjs-fullstack/build-deploy/project-structure.md +18 -16
  175. package/packs/nextjs-fullstack/build-deploy/release-checklist.md +20 -16
  176. package/packs/nextjs-fullstack/build-deploy/testing.md +19 -16
  177. package/packs/nextjs-fullstack/evals/README.md +18 -15
  178. package/packs/nextjs-fullstack/examples/golden-app/README.md +18 -16
  179. package/packs/nextjs-fullstack/frontend/accessibility.md +17 -14
  180. package/packs/nextjs-fullstack/frontend/components.md +19 -16
  181. package/packs/nextjs-fullstack/frontend/copy.md +46 -0
  182. package/packs/nextjs-fullstack/frontend/data-fetching.md +46 -0
  183. package/packs/nextjs-fullstack/frontend/forms.md +17 -14
  184. package/packs/nextjs-fullstack/frontend/layout.md +19 -16
  185. package/packs/nextjs-fullstack/frontend/loading-empty-error.md +19 -16
  186. package/packs/nextjs-fullstack/frontend/motion.md +17 -14
  187. package/packs/nextjs-fullstack/frontend/responsive.md +19 -16
  188. package/packs/nextjs-fullstack/frontend/seo.md +20 -16
  189. package/packs/nextjs-fullstack/frontend/tables.md +17 -14
  190. package/packs/nextjs-fullstack/frontend/tokens.md +18 -16
  191. package/packs/nextjs-fullstack/integrations/analytics.md +17 -14
  192. package/packs/nextjs-fullstack/integrations/email.md +17 -14
  193. package/packs/nextjs-fullstack/integrations/llm-apis.md +19 -16
  194. package/packs/nextjs-fullstack/integrations/oauth.md +19 -16
  195. package/packs/nextjs-fullstack/integrations/object-storage.md +19 -16
  196. package/packs/nextjs-fullstack/integrations/payments.md +17 -14
  197. package/packs/nextjs-fullstack/integrations/queues.md +17 -14
  198. package/packs/nextjs-fullstack/integrations/search.md +19 -16
  199. package/packs/nextjs-fullstack/integrations/webhooks.md +17 -14
  200. package/packs/nextjs-fullstack/playbooks/add-ai-feature.md +19 -16
  201. package/packs/nextjs-fullstack/playbooks/add-auth.md +19 -16
  202. package/packs/nextjs-fullstack/playbooks/add-crud.md +19 -16
  203. package/packs/nextjs-fullstack/playbooks/add-email.md +19 -16
  204. package/packs/nextjs-fullstack/playbooks/add-file-upload.md +19 -16
  205. package/packs/nextjs-fullstack/playbooks/add-webhook.md +19 -16
  206. package/packs/nextjs-fullstack/playbooks/ship-to-prod.md +20 -16
  207. package/plugins/connore/.claude-plugin/plugin.json +10 -0
  208. package/plugins/connore/hooks/hooks.json +16 -0
  209. package/plugins/connore/skills/connore-backend/SKILL.md +32 -0
  210. package/plugins/connore/skills/connore-handoff/SKILL.md +15 -0
  211. package/plugins/connore/skills/connore-routes/SKILL.md +16 -0
  212. package/plugins/connore/skills/connore-validate/SKILL.md +15 -0
  213. package/src/cli.js +110 -21
  214. package/src/commands/doctor.js +2 -0
  215. package/src/commands/edit.js +88 -0
  216. package/src/commands/graph.js +20 -0
  217. package/src/commands/handoff.js +45 -0
  218. package/src/commands/init.js +8 -3
  219. package/src/commands/lint.js +13 -5
  220. package/src/commands/log.js +49 -25
  221. package/src/commands/packs.js +21 -0
  222. package/src/commands/routes.js +13 -0
  223. package/src/commands/search.js +7 -2
  224. package/src/commands/update.js +5 -1
  225. package/src/lib/config.js +67 -64
  226. package/src/lib/graph.js +96 -0
  227. package/src/lib/index.js +88 -72
  228. package/src/lib/lessons.js +173 -173
  229. package/src/lib/lint.js +185 -67
  230. package/src/lib/mutate.js +26 -24
  231. package/src/lib/packs.js +25 -10
  232. package/src/lib/paths.js +1 -1
  233. package/src/lib/prompts.js +66 -0
  234. package/src/lib/report.js +41 -33
  235. package/src/lib/routes.js +59 -0
  236. package/src/lib/run.js +116 -73
  237. package/src/lib/search.js +24 -0
  238. package/src/lib/tokens.js +8 -0
@@ -0,0 +1,32 @@
1
+ ---
2
+ name: connore-backend
3
+ description: Use when working in a project that has a .ctx folder, or when asked what connore runs locally. Covers the content library, the folder layout, the commands and the tool connectors. There is no server.
4
+ allowed-tools: [Read, Bash]
5
+ ---
6
+
7
+ # Connore backend
8
+
9
+ Everything runs on the user's machine. Do not look for an API.
10
+
11
+ ## Four parts
12
+
13
+ 1. Content is the markdown under `.ctx/library/` and `.ctx/mine/`.
14
+ 2. Structure is `INDEX.md`, `routes.md`, `PROCESS.md`, `mine/`, `inbox/`, `vault/`.
15
+ 3. Engine is the `connore` command.
16
+ 4. Connectors are the pointer files and the SessionStart hook.
17
+
18
+ ## Order
19
+
20
+ 1. Read `.ctx/routes.md` and open only the task that matches the work. Leave the Skip areas closed.
21
+ 2. Read `.ctx/INDEX.md` and open the rows that task names.
22
+ 3. Prefer `.ctx/mine/` over `.ctx/library/` when both cover the same decision.
23
+ 4. Never open `.ctx/vault/`. It is raw and unindexed.
24
+
25
+ ## Commands
26
+
27
+ - `connore search "query" --related` finds entries and the ones they link to.
28
+ - `connore routes` rebuilds the task table after the library changes.
29
+ - `connore handoff "note"` writes where the session stopped.
30
+ - `connore doctor`, `connore lint` and `connore graph` check the setup.
31
+
32
+ `connore` must be on the PATH. The hook runs `connore hook`.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: connore-handoff
3
+ description: Use at the end of a session, or when the user asks to resume, hand off, or record where the work stopped.
4
+ allowed-tools: [Read, Bash]
5
+ ---
6
+
7
+ # Handoff
8
+
9
+ Write the stop point before the session ends.
10
+
11
+ 1. Run `connore handoff` with one sentence on what is unfinished.
12
+ 2. That writes `.ctx/mine/handoff.md` with the next plan task, the last journal lines, and the note.
13
+ 3. On the next session, read that file before writing code.
14
+
15
+ Decisions and failures made during the session belong in `connore log`, not only in the handoff note. The handoff points at them; it does not replace them.
@@ -0,0 +1,16 @@
1
+ ---
2
+ name: connore-routes
3
+ description: Use at the start of a coding task to decide which .ctx entries to read and which to skip. Do not load the whole library.
4
+ allowed-tools: [Read, Bash]
5
+ ---
6
+
7
+ # Routes
8
+
9
+ `.ctx/routes.md` is the task table. It is generated from the installed library.
10
+
11
+ 1. Match the user's task to one heading: frontend and design, backend and architecture, security and quality, integrations, growth and web, or workflow.
12
+ 2. Open the files under Read, and only those, plus anything they link.
13
+ 3. Do not open a Skip area to be thorough. That is how token use grows without helping.
14
+ 4. If the Read list says none installed, say so. Do not invent an entry.
15
+
16
+ Rebuild with `connore routes` after `connore update` or `connore add`.
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: connore-validate
3
+ description: Use when checking that a .ctx folder is healthy, that entries are valid, or that references resolve. Does not claim a quality score.
4
+ allowed-tools: [Read, Bash]
5
+ ---
6
+
7
+ # Validate the layer
8
+
9
+ Three checks, in this order. Report each result. Do not describe a failure as clean.
10
+
11
+ 1. `connore doctor` checks the folder, the lock, the vault and the ignore rules.
12
+ 2. `connore lint` checks frontmatter, secrets, staleness and broken refs.
13
+ 3. `connore graph` lists relationships and entries nothing links to.
14
+
15
+ A clean run means the structure is intact. It does not mean the content made an agent better. That needs a measured comparison, which this skill does not run.
package/src/cli.js CHANGED
@@ -1,7 +1,12 @@
1
+ import { readFile } from "node:fs/promises"
1
2
  import { join } from "node:path"
2
3
  import { add } from "./commands/add.js"
3
4
  import { catalog } from "./commands/catalog.js"
4
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"
5
10
  import { printIndex } from "./commands/hook.js"
6
11
  import { init } from "./commands/init.js"
7
12
  import { learn } from "./commands/learn.js"
@@ -12,6 +17,7 @@ import { log } from "./commands/log.js"
12
17
  import { plan } from "./commands/plan.js"
13
18
  import { search } from "./commands/search.js"
14
19
  import { reindex } from "./commands/reindex.js"
20
+ import { routes } from "./commands/routes.js"
15
21
  import { review } from "./commands/review.js"
16
22
  import { stats } from "./commands/stats.js"
17
23
  import { undo } from "./commands/undo.js"
@@ -20,33 +26,43 @@ import { ensureConfig } from "./lib/config.js"
20
26
  import { readOptional } from "./lib/fs-safe.js"
21
27
  import { withLock } from "./lib/lock.js"
22
28
  import { packDir } from "./lib/packs.js"
29
+ import { packRoot } from "./lib/paths.js"
23
30
  import { parseTools } from "./lib/pointers.js"
24
31
  import { createReport } from "./lib/report.js"
25
- import { sealRun } from "./lib/run.js"
32
+ import { closeRun, openRun, sealRun } from "./lib/run.js"
26
33
 
27
34
  const USAGE = `connore <command> [options]
28
35
 
29
- init [--tools all|claude,cursor,codex,copilot,windsurf,gemini] [--pack frontend] [--hooks] [--include-drafts] [--dry-run] [--json]
36
+ init [--tools all|claude,cursor,codex,copilot,windsurf,gemini] [--pack knowledge] [--hooks] [--include-drafts] [--dry-run] [--json]
30
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]
31
40
  update [--pack name] [--include-drafts] [--dry-run] [--json]
32
41
  list [--json]
33
42
  index [--include-drafts] [--dry-run] [--json]
34
43
  hook [--json]
35
- lint [--json]
44
+ lint [--strict] [--json]
36
45
  doctor [--json]
46
+ graph [--include-drafts] [--json]
47
+ packs [--json]
37
48
  undo [--json]
38
- log <fix|decision|failure> "text" [--files a,b] [--json]
49
+ log <decision|fix|failure|note> "text" [--files a,b] [--json]
39
50
  memory [project|architecture|decision|agent|preferences|task|knowledge] ["text"] [--json]
40
51
  catalog [--json]
41
52
  learn [--input file] [--yes] [--json]
42
53
  review [accept|reject|edit <id>] [--mistake text] [--fix text] [--json]
43
54
  stats [--json]
44
- search "query" [--include-drafts] [--json]
55
+ search "query" [--related] [--include-drafts] [--json]
56
+ routes [--include-drafts] [--dry-run] [--json]
57
+ handoff ["note"] [--json]
45
58
  plan init <blueprint> | status | next | done <task> [--json]
59
+
60
+ --version print the package version
61
+ --help print this message
46
62
  `
47
63
 
48
- const VALUE_FLAGS = new Set(["--tools", "--pack", "--type", "--tags", "--files", "--mistake", "--fix", "--input"])
49
- const WRITES = new Set(["init", "add", "update", "index", "undo", "log", "learn", "review", "plan", "memory"])
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"])
50
66
 
51
67
  function usage(message) {
52
68
  const error = new Error(message)
@@ -55,7 +71,7 @@ function usage(message) {
55
71
  }
56
72
 
57
73
  function parse(argv) {
58
- const flags = { dryRun: false, hooks: false, json: false, includeDrafts: false, yes: false }
74
+ const flags = { dryRun: false, hooks: false, json: false, includeDrafts: false, yes: false, strict: false }
59
75
  const positionals = []
60
76
  for (let index = 0; index < argv.length; index += 1) {
61
77
  const arg = argv[index]
@@ -64,6 +80,10 @@ function parse(argv) {
64
80
  else if (arg === "--json") flags.json = true
65
81
  else if (arg === "--include-drafts") flags.includeDrafts = true
66
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
67
87
  else if (VALUE_FLAGS.has(arg)) {
68
88
  const value = argv[index + 1]
69
89
  if (!value || value.startsWith("--")) throw usage(`Missing value for ${arg}.`)
@@ -88,6 +108,16 @@ export async function run(argv, io = {}) {
88
108
  const parsed = parse(argv)
89
109
  flags = parsed.flags
90
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
+ }
91
121
  if (!command) {
92
122
  if (flags.json) printJson(stdout, { ok: false, error: "Missing command." })
93
123
  else stdout.write(USAGE)
@@ -104,7 +134,7 @@ export async function run(argv, io = {}) {
104
134
  }
105
135
  }
106
136
  try {
107
- await packDir(flags.pack || "frontend")
137
+ await packDir(flags.pack || "knowledge")
108
138
  } catch (error) {
109
139
  error.exitCode = 2
110
140
  throw error
@@ -123,6 +153,20 @@ export async function run(argv, io = {}) {
123
153
  }
124
154
  if (flags.hooks) throw usage("--hooks is only valid with init.")
125
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
+ }
126
170
  if (command === "add") {
127
171
  if (flags.pack) throw usage("--pack is only valid with init and update.")
128
172
  if (args.length !== 1) throw usage("Usage: connore add <path>.")
@@ -131,6 +175,7 @@ export async function run(argv, io = {}) {
131
175
  return
132
176
  }
133
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.")
134
179
  if (command === "update") {
135
180
  if (args.length) throw usage("update does not take a path.")
136
181
  await update(cwd, flags, report)
@@ -159,12 +204,27 @@ export async function run(argv, io = {}) {
159
204
  return
160
205
  }
161
206
  if (command === "lint") {
162
- const problems = await lint()
163
- printJsonish(stdout, flags, problems.length ? { ok: false, problems } : { ok: true, problems }, () => {
164
- for (const problem of problems) stdout.write(`${problem}\n`)
165
- stdout.write(problems.length ? `${problems.length} problems\n` : "lint clean\n")
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`)
166
214
  })
167
- if (problems.length) throw Object.assign(new Error("lint failed"), { exitCode: 1, handled: true })
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)
168
228
  return
169
229
  }
170
230
  if (command === "doctor") {
@@ -193,7 +253,7 @@ export async function run(argv, io = {}) {
193
253
  return
194
254
  }
195
255
  if (command === "log") {
196
- if (args.length !== 2) throw usage('Usage: connore log <fix|decision|failure> "text".')
256
+ if (args.length !== 2) throw usage('Usage: connore log <decision|fix|failure|note> "text".')
197
257
  await log(cwd, args[0], args[1], flags, report)
198
258
  report.print(stdout)
199
259
  return
@@ -223,6 +283,23 @@ export async function run(argv, io = {}) {
223
283
  report.print(stdout)
224
284
  return
225
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
+ }
226
303
  if (command === "search") {
227
304
  if (!args.length) throw usage('Usage: connore search "query".')
228
305
  const results = await search(cwd, args.join(" "), flags)
@@ -258,14 +335,23 @@ export async function run(argv, io = {}) {
258
335
  throw usage(`Unknown command "${command}".`)
259
336
  }
260
337
 
261
- if (!flags.dryRun && WRITES.has(command) && (command === "init" || (await readOptional(join(cwd, ".ctx", "PROCESS.md"))))) {
262
- await withLock(cwd, async () => {
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 {
263
344
  await body()
264
- await sealRun(cwd, command, report)
265
- })
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)
266
353
  } else {
267
- await body()
268
- if (!flags.dryRun && WRITES.has(command)) await sealRun(cwd, command, report)
354
+ await guarded()
269
355
  }
270
356
  return 0
271
357
  } catch (error) {
@@ -277,6 +363,9 @@ export async function run(argv, io = {}) {
277
363
  }
278
364
  }
279
365
 
366
+ // Tests and embedders call this with a captured io.
367
+ export const main = run
368
+
280
369
  function countEvents(report) {
281
370
  const count = (kind) => report.events.filter((event) => event.kind === kind).length
282
371
  return { created: count("created"), changed: count("changed"), skipped: count("skipped"), removed: count("removed") }
@@ -27,6 +27,8 @@ export async function doctor(root) {
27
27
  }
28
28
  }
29
29
  if (!(await exists(join(root, ".ctx", "vault")))) problems.push("missing .ctx/vault")
30
+ if (!(await exists(join(root, ".ctx", "routes.md")))) problems.push("missing .ctx/routes.md. Run connore routes.")
31
+ if (!(await exists(join(root, ".ctx", "prompts", "search.md")))) problems.push("missing .ctx/prompts. Run connore init to add command prompts.")
30
32
  const gitignore = await readOptional(join(root, ".gitignore"))
31
33
  if (!gitignore || !gitignore.toString("utf8").includes(".ctx/.signals/")) {
32
34
  problems.push(".gitignore is missing the connore local-state block")
@@ -0,0 +1,88 @@
1
+ import { join, relative, resolve } from "node:path"
2
+ import { readOptional } from "../lib/fs-safe.js"
3
+ import { today } from "../lib/frontmatter.js"
4
+ import { rebuildIndex } from "../lib/index.js"
5
+ import { commitRemove, commitWrite } from "../lib/mutate.js"
6
+ import { ctxPath } from "../lib/paths.js"
7
+ import { secretHits } from "../lib/secrets.js"
8
+
9
+ function mineFile(root, input) {
10
+ const clean = String(input || "").replace(/\\/g, "/").replace(/^\.ctx\//, "").replace(/^\.\//, "")
11
+ if (!clean.startsWith("mine/") || clean.includes("..") || !clean.endsWith(".md")) {
12
+ throw new Error("Path must be a markdown file under mine/, for example mine/notes.md.")
13
+ }
14
+ const target = resolve(root, ".ctx", ...clean.split("/"))
15
+ const rel = relative(ctxPath(root, "mine"), target)
16
+ if (rel.startsWith("..") || rel.split(/[/\\]/).includes("..")) {
17
+ throw new Error("Path must stay inside .ctx/mine/.")
18
+ }
19
+ return { target, display: `.ctx/${clean}` }
20
+ }
21
+
22
+ function setField(text, key, value) {
23
+ const line = `${key}: ${value}`
24
+ const pattern = new RegExp(`^${key}:.*$`, "m")
25
+ if (pattern.test(text)) return text.replace(pattern, line)
26
+ return text.replace(/\n---/, `\n${line}\n---`)
27
+ }
28
+
29
+ function renderNew({ title, description, tags, text }) {
30
+ return `---
31
+ title: ${title}
32
+ type: doc
33
+ tags: [${tags || "user"}]
34
+ source: user
35
+ updated: ${today()}
36
+ description: ${description}
37
+ ---
38
+
39
+ # ${title}
40
+
41
+ ${text || "User entry."}
42
+ `
43
+ }
44
+
45
+ export async function edit(root, input, flags, report) {
46
+ if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
47
+ if (!flags.title && !flags.description && !flags.tags && !flags.text) {
48
+ throw Object.assign(new Error("Pass --title, --description, --tags, or --text."), { exitCode: 2 })
49
+ }
50
+ const { target, display } = mineFile(root, input)
51
+ const current = await readOptional(target)
52
+ let next
53
+ if (!current) {
54
+ const title = flags.title || input.split("/").pop().replace(/\.md$/, "")
55
+ next = renderNew({
56
+ title,
57
+ description: flags.description || "User entry.",
58
+ tags: flags.tags,
59
+ text: flags.text,
60
+ })
61
+ } else {
62
+ next = current.toString("utf8")
63
+ if (flags.title) next = setField(next, "title", flags.title)
64
+ if (flags.description) next = setField(next, "description", flags.description)
65
+ if (flags.tags) next = setField(next, "tags", `[${flags.tags}]`)
66
+ if (flags.text) {
67
+ const end = next.indexOf("\n---", 3)
68
+ if (end === -1) throw new Error("The entry has no frontmatter to keep.")
69
+ const title = flags.title || (next.match(/^title:\s*(.*)$/m)?.[1] ?? "Entry")
70
+ next = `${next.slice(0, end + 4)}\n\n# ${title}\n\n${flags.text.trim()}\n`
71
+ }
72
+ next = setField(next, "updated", today())
73
+ }
74
+ const hits = secretHits(next)
75
+ if (hits.length) throw new Error(`Refusing to write ${display} because it looks like a secret (${hits.join(", ")}).`)
76
+ await commitWrite(target, next, report, display)
77
+ await rebuildIndex(root, report)
78
+ return { path: display }
79
+ }
80
+
81
+ export async function remove(root, input, report) {
82
+ if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
83
+ const { target, display } = mineFile(root, input)
84
+ if (!(await readOptional(target))) throw new Error(`No entry at ${display}.`)
85
+ await commitRemove(target, report, display)
86
+ await rebuildIndex(root, report)
87
+ return { path: display }
88
+ }
@@ -0,0 +1,20 @@
1
+ import { buildGraph } from "../lib/graph.js"
2
+
3
+ export async function graph(root, flags, stdout) {
4
+ const { nodes, edges, broken, unconnected } = await buildGraph(root, { includeDrafts: flags.includeDrafts })
5
+ if (flags.json) {
6
+ stdout.write(`${JSON.stringify({ ok: broken.length === 0, entries: nodes.length, edges: edges.length, broken, unconnected })}\n`)
7
+ return broken.length ? 1 : 0
8
+ }
9
+ stdout.write(`${nodes.length} entries, ${edges.length} relationships\n`)
10
+ if (broken.length) {
11
+ stdout.write(`\nBroken references (${broken.length}):\n`)
12
+ for (const problem of broken) stdout.write(` ${problem}\n`)
13
+ }
14
+ if (unconnected.length) {
15
+ stdout.write(`\nNot linked to anything (${unconnected.length}):\n`)
16
+ for (const path of unconnected) stdout.write(` ${path}\n`)
17
+ }
18
+ if (!broken.length && !unconnected.length) stdout.write("Every entry is connected and every reference resolves.\n")
19
+ return broken.length ? 1 : 0
20
+ }
@@ -0,0 +1,45 @@
1
+ import { join } from "node:path"
2
+ import { readOptional } from "../lib/fs-safe.js"
3
+ import { today } from "../lib/frontmatter.js"
4
+ import { commitWrite } from "../lib/mutate.js"
5
+ import { planView } from "../lib/plan.js"
6
+ import { redactSecrets } from "../lib/secrets.js"
7
+
8
+ export async function handoff(root, note, report) {
9
+ if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
10
+ const planFile = await readOptional(join(root, ".ctx", "mine", "plan.md"))
11
+ let next = "No plan."
12
+ if (planFile) {
13
+ const view = planView(planFile.toString("utf8"))
14
+ next = view.next || "No open task."
15
+ }
16
+ const journal = await readOptional(join(root, ".ctx", "mine", "journal.md"))
17
+ const recent = journal
18
+ ? journal.toString("utf8").split("\n").filter((line) => line.startsWith("- ")).slice(-5)
19
+ : []
20
+ const safe = redactSecrets(String(note || "").trim())
21
+ const text = `---
22
+ title: Session handoff
23
+ type: log
24
+ tags: [handoff, session]
25
+ source: user
26
+ description: Where the last session stopped. Read this before continuing the work.
27
+ ---
28
+
29
+ # Session handoff
30
+
31
+ Written ${today()}.
32
+
33
+ Next: ${next}
34
+
35
+ ## Recent log
36
+
37
+ ${recent.length ? recent.join("\n") : "None."}
38
+
39
+ ## Note
40
+
41
+ ${safe || "None."}
42
+ `
43
+ await commitWrite(join(root, ".ctx", "mine", "handoff.md"), text, report, ".ctx/mine/handoff.md")
44
+ return { next, note: safe }
45
+ }
@@ -4,7 +4,9 @@ import { installHook } from "./hook.js"
4
4
  import { ensureConfig } from "../lib/config.js"
5
5
  import { ensureLocalIgnores } from "../lib/ignore.js"
6
6
  import { readOptional } from "../lib/fs-safe.js"
7
- import { rebuildIndex } from "../lib/index.js"
7
+ import { collectEntries, rebuildIndex } from "../lib/index.js"
8
+ import { ensurePrompts } from "../lib/prompts.js"
9
+ import { renderRoutes } from "../lib/routes.js"
8
10
  import { commitWrite } from "../lib/mutate.js"
9
11
  import { packRoot } from "../lib/paths.js"
10
12
  import { packDir } from "../lib/packs.js"
@@ -47,7 +49,7 @@ async function writeNew(file, contents, display, report) {
47
49
  }
48
50
 
49
51
  export async function init(root, flags, report) {
50
- const pack = flags.pack || "frontend"
52
+ const pack = flags.pack || "knowledge"
51
53
  const source = await packDir(pack)
52
54
  const detected = await detectTools(root)
53
55
  const tools = flags.tools ? parseTools(flags.tools) : detected.length ? detected : ["claude", "codex"]
@@ -59,11 +61,14 @@ export async function init(root, flags, report) {
59
61
  await writeNew(join(root, ".ctx", "inbox", ".gitkeep"), "", ".ctx/inbox/.gitkeep", report)
60
62
  await writeNew(join(root, ".ctx", "mine", ".gitkeep"), "", ".ctx/mine/.gitkeep", report)
61
63
  await writeNew(join(root, ".ctx", "vault", "README.md"), VAULT_README, ".ctx/vault/README.md", report)
62
- await ensureConfig(root, report, tools, { replaceTools: Boolean(flags.tools) })
64
+ await ensureConfig(root, report, tools, { replaceTools: Boolean(flags.tools), pack })
63
65
  await writeNew(join(root, ".ctx", "PROCESS.md"), PROCESS_MD, ".ctx/PROCESS.md", report)
64
66
  await writeNew(join(root, ".ctx", "START.md"), await readFile(join(packRoot, "packs", "base", "planning", "START.md")), ".ctx/START.md", report)
65
67
  await ensureLocalIgnores(root, report)
66
68
  await patchTools(root, tools, report)
67
69
  if (flags.hooks) await installHook(root, report)
70
+ await ensurePrompts(root, report)
68
71
  await rebuildIndex(root, report, { includeDrafts: flags.includeDrafts })
72
+ const entries = await collectEntries(root, { includeDrafts: flags.includeDrafts })
73
+ await writeNew(join(root, ".ctx", "routes.md"), renderRoutes(entries.map((entry) => entry.path)), ".ctx/routes.md", report)
69
74
  }
@@ -1,5 +1,13 @@
1
- import { lintPacks } from "../lib/lint.js"
2
-
3
- export async function lint() {
4
- return lintPacks()
5
- }
1
+ import { join } from "node:path"
2
+ import { readOptional } from "../lib/fs-safe.js"
3
+ import { lintPacks, lintProject } from "../lib/lint.js"
4
+
5
+ // Inside a project, lint the entries on disk. In this repo (no .ctx/), lint the
6
+ // packs that ship with the package.
7
+ export async function lint(root, options = {}) {
8
+ if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) {
9
+ return { errors: await lintPacks(), warnings: [], scope: "packs" }
10
+ }
11
+ const { errors, warnings } = await lintProject(root, options)
12
+ return { errors, warnings, scope: "project" }
13
+ }
@@ -1,25 +1,49 @@
1
- import { readOptional } from "../lib/fs-safe.js"
2
- import { join } from "node:path"
3
- import { appendSignal } from "../lib/signals.js"
4
- import { redactSecrets } from "../lib/secrets.js"
5
-
6
- const KINDS = new Set(["fix", "decision", "failure"])
7
-
8
- export async function log(root, kind, text, flags, report) {
9
- if (!KINDS.has(kind) || !text) {
10
- throw Object.assign(new Error('Usage: connore log <fix|decision|failure> "text".'), { exitCode: 2 })
11
- }
12
- if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
13
- const files = flags.files ? flags.files.split(",").map((file) => file.trim()).filter(Boolean) : []
14
- await appendSignal(
15
- root,
16
- {
17
- at: new Date().toISOString(),
18
- kind,
19
- text: redactSecrets(text),
20
- files,
21
- source: "log",
22
- },
23
- report,
24
- )
25
- }
1
+ import { readOptional } from "../lib/fs-safe.js"
2
+ import { join } from "node:path"
3
+ import { appendSignal } from "../lib/signals.js"
4
+ import { redactSecrets } from "../lib/secrets.js"
5
+ import { today } from "../lib/frontmatter.js"
6
+ import { commitWrite } from "../lib/mutate.js"
7
+
8
+ const KINDS = new Set(["fix", "decision", "failure", "note"])
9
+
10
+ const JOURNAL_HEAD = `---
11
+ title: Journal
12
+ type: log
13
+ tags: [journal]
14
+ source: user
15
+ description: Dated decisions, fixes and failures recorded with connore log.
16
+ ---
17
+
18
+ # Journal
19
+ `
20
+
21
+ export async function appendJournal(root, kind, text, files, report) {
22
+ const file = join(root, ".ctx", "mine", "journal.md")
23
+ const current = await readOptional(file)
24
+ const body = current ? current.toString("utf8").replace(/\s*$/, "\n") : JOURNAL_HEAD
25
+ const suffix = files.length ? ` (${files.join(", ")})` : ""
26
+ const next = `${body}\n- ${today()} ${kind}: ${text}${suffix}\n`
27
+ await commitWrite(file, next, report, ".ctx/mine/journal.md")
28
+ }
29
+
30
+ export async function log(root, kind, text, flags, report) {
31
+ if (!KINDS.has(kind) || !text) {
32
+ throw Object.assign(new Error('Usage: connore log <decision|fix|failure|note> "text".'), { exitCode: 2 })
33
+ }
34
+ if (!(await readOptional(join(root, ".ctx", "PROCESS.md")))) throw new Error("No .ctx/ folder. Run connore init first.")
35
+ const files = flags.files ? flags.files.split(",").map((file) => file.trim()).filter(Boolean) : []
36
+ const safe = redactSecrets(text)
37
+ await appendSignal(
38
+ root,
39
+ {
40
+ at: new Date().toISOString(),
41
+ kind,
42
+ text: safe,
43
+ files,
44
+ source: "log",
45
+ },
46
+ report,
47
+ )
48
+ await appendJournal(root, kind, safe, files, report)
49
+ }
@@ -0,0 +1,21 @@
1
+ import { readConfig } from "../lib/config.js"
2
+ import { listPacks } from "../lib/packs.js"
3
+
4
+ export async function packs(root, flags, stdout) {
5
+ const available = await listPacks()
6
+ let installed = null
7
+ try {
8
+ const { config } = await readConfig(root)
9
+ installed = config?.pack || null
10
+ } catch {
11
+ installed = null
12
+ }
13
+ if (flags.json) {
14
+ stdout.write(`${JSON.stringify({ ok: true, installed, packs: available })}\n`)
15
+ return
16
+ }
17
+ for (const pack of available) {
18
+ const mark = pack.name === installed ? " (installed)" : ""
19
+ stdout.write(`${pack.name}\t${pack.entries} entries${mark}\n`)
20
+ }
21
+ }