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.
- package/README.md +13 -8
- package/bin/ctxkit.js +5 -5
- package/package.json +2 -1
- package/packs/base/planning/START.md +29 -28
- package/packs/base/planning/blueprint-template.md +46 -46
- package/packs/base/planning/plan-template.md +46 -45
- package/packs/base/rules/anti-patterns.md +19 -16
- package/packs/base/rules/code-style.md +19 -16
- package/packs/base/rules/dependency-policy.md +19 -16
- package/packs/base/rules/error-handling.md +19 -16
- package/packs/base/rules/security-audit.md +47 -0
- package/packs/base/rules/security-baseline.md +19 -16
- package/packs/base/templates/bug-report.md +19 -16
- package/packs/base/templates/feature-spec.md +19 -16
- package/packs/base/templates/handoff.md +19 -16
- package/packs/base/templates/project-brief.md +19 -16
- package/packs/base/workflow/code-review.md +19 -16
- package/packs/base/workflow/debugging.md +18 -14
- package/packs/base/workflow/git-and-commits.md +19 -16
- package/packs/base/workflow/idea-to-spec.md +19 -16
- package/packs/base/workflow/session-handoff.md +19 -16
- package/packs/base/workflow/spec-to-plan.md +19 -16
- 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/auth-and-roles.md +19 -16
- package/packs/nextjs-fullstack/backend/background-jobs.md +19 -16
- package/packs/nextjs-fullstack/backend/caching.md +17 -14
- package/packs/nextjs-fullstack/backend/database.md +19 -16
- package/packs/nextjs-fullstack/backend/file-uploads.md +19 -16
- package/packs/nextjs-fullstack/backend/logging.md +17 -14
- package/packs/nextjs-fullstack/backend/migrations.md +17 -14
- package/packs/nextjs-fullstack/backend/rate-limiting.md +19 -16
- package/packs/nextjs-fullstack/backend/secrets-and-env.md +19 -16
- package/packs/nextjs-fullstack/backend/validation.md +19 -16
- package/packs/nextjs-fullstack/blueprints/ai-app.md +1 -1
- package/packs/nextjs-fullstack/blueprints/internal-tool.md +1 -1
- package/packs/nextjs-fullstack/blueprints/saas-app.md +1 -1
- package/packs/nextjs-fullstack/build-deploy/ci.md +18 -16
- package/packs/nextjs-fullstack/build-deploy/deploy.md +19 -16
- package/packs/nextjs-fullstack/build-deploy/monitoring.md +16 -14
- package/packs/nextjs-fullstack/build-deploy/performance.md +17 -14
- package/packs/nextjs-fullstack/build-deploy/project-structure.md +18 -16
- package/packs/nextjs-fullstack/build-deploy/release-checklist.md +20 -16
- package/packs/nextjs-fullstack/build-deploy/testing.md +19 -16
- package/packs/nextjs-fullstack/evals/README.md +18 -15
- package/packs/nextjs-fullstack/examples/golden-app/README.md +18 -16
- package/packs/nextjs-fullstack/frontend/accessibility.md +17 -14
- package/packs/nextjs-fullstack/frontend/components.md +19 -16
- 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 +17 -14
- package/packs/nextjs-fullstack/frontend/layout.md +19 -16
- package/packs/nextjs-fullstack/frontend/loading-empty-error.md +19 -16
- package/packs/nextjs-fullstack/frontend/motion.md +17 -14
- package/packs/nextjs-fullstack/frontend/responsive.md +19 -16
- package/packs/nextjs-fullstack/frontend/seo.md +20 -16
- package/packs/nextjs-fullstack/frontend/tables.md +17 -14
- package/packs/nextjs-fullstack/frontend/tokens.md +18 -16
- package/packs/nextjs-fullstack/integrations/analytics.md +17 -14
- package/packs/nextjs-fullstack/integrations/email.md +17 -14
- package/packs/nextjs-fullstack/integrations/llm-apis.md +19 -16
- package/packs/nextjs-fullstack/integrations/oauth.md +19 -16
- package/packs/nextjs-fullstack/integrations/object-storage.md +19 -16
- package/packs/nextjs-fullstack/integrations/payments.md +17 -14
- package/packs/nextjs-fullstack/integrations/queues.md +17 -14
- package/packs/nextjs-fullstack/integrations/search.md +19 -16
- package/packs/nextjs-fullstack/integrations/webhooks.md +17 -14
- package/packs/nextjs-fullstack/playbooks/add-ai-feature.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-auth.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-crud.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-email.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-file-upload.md +19 -16
- package/packs/nextjs-fullstack/playbooks/add-webhook.md +19 -16
- package/packs/nextjs-fullstack/playbooks/ship-to-prod.md +20 -16
- 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 +110 -21
- package/src/commands/doctor.js +2 -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/init.js +8 -3
- package/src/commands/lint.js +13 -5
- package/src/commands/log.js +49 -25
- package/src/commands/packs.js +21 -0
- package/src/commands/routes.js +13 -0
- package/src/commands/search.js +7 -2
- package/src/commands/update.js +5 -1
- package/src/lib/config.js +67 -64
- package/src/lib/graph.js +96 -0
- package/src/lib/index.js +88 -72
- package/src/lib/lessons.js +173 -173
- package/src/lib/lint.js +185 -67
- package/src/lib/mutate.js +26 -24
- package/src/lib/packs.js +25 -10
- package/src/lib/paths.js +1 -1
- package/src/lib/prompts.js +66 -0
- package/src/lib/report.js +41 -33
- package/src/lib/routes.js +59 -0
- package/src/lib/run.js +116 -73
- package/src/lib/search.js +24 -0
- package/src/lib/tokens.js +8 -0
package/src/lib/packs.js
CHANGED
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { readdir } from "node:fs/promises"
|
|
2
|
+
import { join } from "node:path"
|
|
3
|
+
import { walkFiles } from "./fs-safe.js"
|
|
4
|
+
import { packRoot } from "./paths.js"
|
|
5
|
+
|
|
6
|
+
export async function listPacks() {
|
|
7
|
+
const root = join(packRoot, "packs")
|
|
8
|
+
const names = (await readdir(root, { withFileTypes: true }))
|
|
9
|
+
.filter((entry) => entry.isDirectory())
|
|
10
|
+
.map((entry) => entry.name)
|
|
11
|
+
.sort()
|
|
12
|
+
const packs = []
|
|
13
|
+
for (const name of names) {
|
|
14
|
+
const files = (await walkFiles(join(root, name))).filter((file) => file.endsWith(".md"))
|
|
15
|
+
if (files.length) packs.push({ name, entries: files.length })
|
|
16
|
+
}
|
|
17
|
+
return packs
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export async function packDir(name) {
|
|
21
|
+
const dir = join(packRoot, "packs", name)
|
|
22
|
+
const files = await walkFiles(dir)
|
|
23
|
+
if (!files.some((file) => file.endsWith(".md"))) throw new Error(`Unknown pack "${name}".`)
|
|
24
|
+
return dir
|
|
25
|
+
}
|
package/src/lib/paths.js
CHANGED
|
@@ -6,7 +6,7 @@ export const packRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..", "
|
|
|
6
6
|
export const TOOLS = ["claude", "cursor", "codex", "copilot", "windsurf", "gemini"]
|
|
7
7
|
|
|
8
8
|
export const POINTER =
|
|
9
|
-
"Before building UI or backend features, read .ctx/INDEX.md and load only the entries relevant to the task. Prefer text specs over opening images. Before new work, read .ctx/START.md. When a
|
|
9
|
+
"Before building UI or backend features, read .ctx/INDEX.md and load only the entries relevant to the task. Prefer text specs over opening images. Before new work, read .ctx/START.md and .ctx/routes.md. When a moment matches a file in .ctx/prompts/, run that command. Record a decision with connore log. Edit user entries with connore edit under mine/. Do not open .ctx/vault."
|
|
10
10
|
|
|
11
11
|
export function toPosix(filePath) {
|
|
12
12
|
return filePath.split(sep).join("/")
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { join } from "node:path"
|
|
2
|
+
import { commitWrite } from "./mutate.js"
|
|
3
|
+
import { readOptional } from "./fs-safe.js"
|
|
4
|
+
|
|
5
|
+
// One file per command. The description is what the agent matches against the moment.
|
|
6
|
+
const COMMANDS = [
|
|
7
|
+
["init", "Run connore init only when the project has no .ctx folder."],
|
|
8
|
+
["update", "Run connore update when library entries are stale and mine must stay untouched."],
|
|
9
|
+
["add", "Run connore add when the user drops a reference file that should enter mine."],
|
|
10
|
+
["edit", "Run connore edit when a user-owned entry in mine needs a change."],
|
|
11
|
+
["remove", "Run connore remove when the user wants a mine entry gone. Never remove library."],
|
|
12
|
+
["list", "Run connore list when you need the catalog and search would be too narrow."],
|
|
13
|
+
["index", "Run connore index after entries change and the table looks out of date."],
|
|
14
|
+
["search", "Run connore search before opening the library. Use --related for neighbors."],
|
|
15
|
+
["routes", "Run connore routes after update or add so the task table matches the library."],
|
|
16
|
+
["graph", "Run connore graph when a reference looks broken or an entry seems unused."],
|
|
17
|
+
["lint", "Run connore lint before calling an entry finished."],
|
|
18
|
+
["doctor", "Run connore doctor when setup fails or before trusting a fresh clone."],
|
|
19
|
+
["plan", "Run connore plan before writing code on a multi-step build."],
|
|
20
|
+
["log", "Run connore log when a decision, fix, or failure should survive the session."],
|
|
21
|
+
["handoff", "Run connore handoff when the session is ending or work is pausing."],
|
|
22
|
+
["hook", "Run connore hook only from the session start hook, not by hand mid-task."],
|
|
23
|
+
["undo", "Run connore undo when the last connore command wrote the wrong files."],
|
|
24
|
+
["packs", "Run connore packs when choosing which library to install."],
|
|
25
|
+
["learn", "Run connore learn when the same failure has shown up again."],
|
|
26
|
+
["review", "Run connore review when a proposed lesson is waiting."],
|
|
27
|
+
["memory", "Run connore memory when a note belongs to the project memory, not the journal."],
|
|
28
|
+
["catalog", "Run connore catalog when counting references the user captured."],
|
|
29
|
+
["stats", "Run connore stats when asked how often the layer is used."],
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
export function promptFiles() {
|
|
33
|
+
return COMMANDS.map(([name, description]) => ({
|
|
34
|
+
name: `${name}.md`,
|
|
35
|
+
text: `---
|
|
36
|
+
title: ${name} command
|
|
37
|
+
type: protocol
|
|
38
|
+
tags: [prompt, ${name}]
|
|
39
|
+
source: library
|
|
40
|
+
updated: 2026-12-07
|
|
41
|
+
description: ${description}
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
# ${name} command
|
|
45
|
+
|
|
46
|
+
${description}
|
|
47
|
+
|
|
48
|
+
Run \`connore ${name}\` at that moment. Do not run it on every message. Read the matching rows from INDEX.md first when the command is search, routes, or plan.
|
|
49
|
+
|
|
50
|
+
## Do not
|
|
51
|
+
Do not point this command at .ctx/vault or at .ctx/library. Library changes come from connore update. User edits go to mine.
|
|
52
|
+
`,
|
|
53
|
+
}))
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function ensurePrompts(root, report) {
|
|
57
|
+
for (const prompt of promptFiles()) {
|
|
58
|
+
const file = join(root, ".ctx", "prompts", prompt.name)
|
|
59
|
+
const display = `.ctx/prompts/${prompt.name}`
|
|
60
|
+
if (await readOptional(file)) {
|
|
61
|
+
report.add("skipped", display)
|
|
62
|
+
continue
|
|
63
|
+
}
|
|
64
|
+
await commitWrite(file, prompt.text, report, display)
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/lib/report.js
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
export function createReport(dryRun, { json = false } = {}) {
|
|
2
|
-
const events = []
|
|
3
|
-
return {
|
|
4
|
-
dryRun,
|
|
5
|
-
json,
|
|
6
|
-
events,
|
|
7
|
-
mutations: [],
|
|
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
|
-
}
|
|
1
|
+
export function createReport(dryRun, { json = false } = {}) {
|
|
2
|
+
const events = []
|
|
3
|
+
return {
|
|
4
|
+
dryRun,
|
|
5
|
+
json,
|
|
6
|
+
events,
|
|
7
|
+
mutations: [],
|
|
8
|
+
// Set by openRun so each change reaches the manifest before the next write.
|
|
9
|
+
sink: null,
|
|
10
|
+
add(kind, file, meta) {
|
|
11
|
+
events.push({ kind, file })
|
|
12
|
+
if (meta && Object.prototype.hasOwnProperty.call(meta, "previous")) {
|
|
13
|
+
this.mutations.push({ kind, file, previous: meta.previous })
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
async record(kind, file, meta) {
|
|
17
|
+
this.add(kind, file, meta)
|
|
18
|
+
if (this.sink && meta && Object.prototype.hasOwnProperty.call(meta, "previous")) {
|
|
19
|
+
await this.sink({ kind, file, previous: meta.previous })
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
print(stdout) {
|
|
23
|
+
const count = (kind) => events.filter((event) => event.kind === kind).length
|
|
24
|
+
const summary = {
|
|
25
|
+
created: count("created"),
|
|
26
|
+
changed: count("changed"),
|
|
27
|
+
skipped: count("skipped"),
|
|
28
|
+
removed: count("removed"),
|
|
29
|
+
}
|
|
30
|
+
if (json) {
|
|
31
|
+
stdout.write(`${JSON.stringify({ ok: true, dryRun, events, summary })}\n`)
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
for (const event of events) stdout.write(`${event.kind} ${event.file}\n`)
|
|
35
|
+
const mode = dryRun ? " (dry-run)" : ""
|
|
36
|
+
stdout.write(
|
|
37
|
+
`summary: ${summary.created} created, ${summary.changed} changed, ${summary.skipped} skipped, ${summary.removed} removed${mode}\n`,
|
|
38
|
+
)
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// One row per task. `match` is matched against entry paths. `skip` names areas
|
|
2
|
+
// the agent should not open for that task. Paths come from the installed library,
|
|
3
|
+
// so a task with nothing installed says so instead of inventing entries.
|
|
4
|
+
export const TASKS = [
|
|
5
|
+
{
|
|
6
|
+
title: "Frontend and design",
|
|
7
|
+
match: ["/frontend/", "/design/"],
|
|
8
|
+
skip: ["Backend and architecture", "Integrations"],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: "Backend and architecture",
|
|
12
|
+
match: ["/backend/"],
|
|
13
|
+
skip: ["Frontend and design", "Growth and web"],
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
title: "Security and quality",
|
|
17
|
+
match: ["/rules/security", "/rules/definition-of-done", "/build-deploy/testing", "/build-deploy/release", "/rules/error-handling"],
|
|
18
|
+
skip: ["Growth and web"],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Integrations",
|
|
22
|
+
match: ["/integrations/"],
|
|
23
|
+
skip: ["Frontend and design"],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
title: "Growth and web",
|
|
27
|
+
match: ["/frontend/seo", "/frontend/copy"],
|
|
28
|
+
skip: ["Backend and architecture"],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
title: "Workflow",
|
|
32
|
+
match: ["/planning/", "/workflow/", "/blueprints/", "START.md"],
|
|
33
|
+
skip: [],
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
const HEAD = `---
|
|
38
|
+
title: Routes
|
|
39
|
+
type: process
|
|
40
|
+
tags: [routes, index]
|
|
41
|
+
updated: 2026-12-06
|
|
42
|
+
description: Per-task read and skip lists. Load the one task, not the library.
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
# Routes
|
|
46
|
+
|
|
47
|
+
Read INDEX.md, then open one task below. Leave every Skip area closed.
|
|
48
|
+
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
export function renderRoutes(paths) {
|
|
52
|
+
const blocks = TASKS.map((task) => {
|
|
53
|
+
const hits = paths.filter((path) => task.match.some((part) => path.includes(part))).slice(0, 3)
|
|
54
|
+
const read = hits.length ? hits.map((path) => `- \`${path}\``).join("\n") : "- none installed"
|
|
55
|
+
const skip = task.skip.length ? `\nSkip: ${task.skip.join(", ")}.` : ""
|
|
56
|
+
return `## ${task.title}\n\nRead:\n${read}${skip}`
|
|
57
|
+
})
|
|
58
|
+
return `${HEAD}${blocks.join("\n\n")}\n`
|
|
59
|
+
}
|
package/src/lib/run.js
CHANGED
|
@@ -1,73 +1,116 @@
|
|
|
1
|
-
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises"
|
|
2
|
-
import { dirname, join } from "node:path"
|
|
3
|
-
import { writeAtomic } from "./fs-safe.js"
|
|
4
|
-
import { absFromPosix } from "./paths.js"
|
|
5
|
-
|
|
6
|
-
function runStamp(date = new Date()) {
|
|
7
|
-
return date.toISOString().replace(/[:.]/g, "-")
|
|
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
|
-
return
|
|
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
|
-
await
|
|
71
|
-
await
|
|
72
|
-
return
|
|
73
|
-
}
|
|
1
|
+
import { mkdir, readdir, readFile, rm, writeFile } from "node:fs/promises"
|
|
2
|
+
import { dirname, join } from "node:path"
|
|
3
|
+
import { writeAtomic } from "./fs-safe.js"
|
|
4
|
+
import { absFromPosix } from "./paths.js"
|
|
5
|
+
|
|
6
|
+
function runStamp(date = new Date()) {
|
|
7
|
+
return date.toISOString().replace(/[:.]/g, "-")
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// The manifest is written when the run opens and rewritten after every change,
|
|
11
|
+
// so a run that is killed part-way through still leaves a record. Without this,
|
|
12
|
+
// undo would skip the interrupted writes and reverse an older run instead.
|
|
13
|
+
export async function openRun(root, command, report) {
|
|
14
|
+
if (report.dryRun) return null
|
|
15
|
+
const id = runStamp()
|
|
16
|
+
const runs = join(root, ".ctx", ".runs")
|
|
17
|
+
const dir = join(runs, id)
|
|
18
|
+
const json = join(runs, `${id}.json`)
|
|
19
|
+
const files = []
|
|
20
|
+
await mkdir(runs, { recursive: true })
|
|
21
|
+
const flush = async (complete) => {
|
|
22
|
+
await writeFile(json, `${JSON.stringify({ id, command, complete, files }, null, 2)}\n`)
|
|
23
|
+
}
|
|
24
|
+
await flush(false)
|
|
25
|
+
report.sink = async (change) => {
|
|
26
|
+
const action = change.kind === "changed" ? "updated" : change.kind
|
|
27
|
+
const entry = { path: change.file, action }
|
|
28
|
+
if (change.previous) {
|
|
29
|
+
const backup = absFromPosix(dir, change.file)
|
|
30
|
+
await mkdir(dirname(backup), { recursive: true })
|
|
31
|
+
await writeFile(backup, change.previous)
|
|
32
|
+
entry.backup = `.ctx/.runs/${id}/${change.file}`
|
|
33
|
+
}
|
|
34
|
+
files.push(entry)
|
|
35
|
+
await flush(false)
|
|
36
|
+
}
|
|
37
|
+
return { id, dir, json, files, flush, report }
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function closeRun(root, handle) {
|
|
41
|
+
if (!handle) return null
|
|
42
|
+
handle.report.sink = null
|
|
43
|
+
if (!handle.files.length) {
|
|
44
|
+
await rm(handle.json, { force: true })
|
|
45
|
+
await rm(handle.dir, { recursive: true, force: true })
|
|
46
|
+
return null
|
|
47
|
+
}
|
|
48
|
+
await handle.flush(true)
|
|
49
|
+
await pruneRuns(root, 10)
|
|
50
|
+
return handle.id
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function sealRun(root, command, report) {
|
|
54
|
+
if (report.dryRun || report.mutations.length === 0) return null
|
|
55
|
+
const id = runStamp()
|
|
56
|
+
const dir = join(root, ".ctx", ".runs", id)
|
|
57
|
+
const files = []
|
|
58
|
+
for (const change of report.mutations) {
|
|
59
|
+
const action = change.kind === "changed" ? "updated" : change.kind
|
|
60
|
+
const entry = { path: change.file, action }
|
|
61
|
+
if (change.previous) {
|
|
62
|
+
const backup = absFromPosix(dir, change.file)
|
|
63
|
+
await mkdir(dirname(backup), { recursive: true })
|
|
64
|
+
await writeFile(backup, change.previous)
|
|
65
|
+
entry.backup = `.ctx/.runs/${id}/${change.file}`
|
|
66
|
+
}
|
|
67
|
+
files.push(entry)
|
|
68
|
+
}
|
|
69
|
+
await mkdir(join(root, ".ctx", ".runs"), { recursive: true })
|
|
70
|
+
await writeFile(join(root, ".ctx", ".runs", `${id}.json`), `${JSON.stringify({ id, command, files }, null, 2)}\n`)
|
|
71
|
+
await pruneRuns(root, 10)
|
|
72
|
+
return id
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
async function listRuns(root) {
|
|
76
|
+
const dir = join(root, ".ctx", ".runs")
|
|
77
|
+
let names = []
|
|
78
|
+
try {
|
|
79
|
+
names = await readdir(dir)
|
|
80
|
+
} catch (error) {
|
|
81
|
+
if (error.code === "ENOENT") return []
|
|
82
|
+
throw error
|
|
83
|
+
}
|
|
84
|
+
return names
|
|
85
|
+
.filter((name) => name.endsWith(".json"))
|
|
86
|
+
.sort()
|
|
87
|
+
.map((name) => ({
|
|
88
|
+
id: name.slice(0, -5),
|
|
89
|
+
json: join(dir, name),
|
|
90
|
+
dir: join(dir, name.slice(0, -5)),
|
|
91
|
+
}))
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function pruneRuns(root, keep) {
|
|
95
|
+
const runs = await listRuns(root)
|
|
96
|
+
const extra = runs.slice(0, Math.max(0, runs.length - keep))
|
|
97
|
+
for (const run of extra) {
|
|
98
|
+
await rm(run.json, { force: true })
|
|
99
|
+
await rm(run.dir, { recursive: true, force: true })
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export async function undoLastRun(root) {
|
|
104
|
+
const runs = await listRuns(root)
|
|
105
|
+
const latest = runs.at(-1)
|
|
106
|
+
if (!latest) throw new Error("No run to undo.")
|
|
107
|
+
const manifest = JSON.parse(await readFile(latest.json, "utf8"))
|
|
108
|
+
for (const entry of [...manifest.files].reverse()) {
|
|
109
|
+
const abs = absFromPosix(root, entry.path)
|
|
110
|
+
if (entry.action === "created") await rm(abs, { force: true })
|
|
111
|
+
else if (entry.backup) await writeAtomic(abs, await readFile(absFromPosix(root, entry.backup)))
|
|
112
|
+
}
|
|
113
|
+
await rm(latest.json, { force: true })
|
|
114
|
+
await rm(latest.dir, { recursive: true, force: true })
|
|
115
|
+
return manifest
|
|
116
|
+
}
|
package/src/lib/search.js
CHANGED
|
@@ -38,3 +38,27 @@ export function rankEntries(entries, query) {
|
|
|
38
38
|
.filter((entry) => entry.score > 0)
|
|
39
39
|
.sort((a, b) => b.score - a.score || a.path.localeCompare(b.path))
|
|
40
40
|
}
|
|
41
|
+
|
|
42
|
+
// Direct refs and markdown links only. Shared tags connect too much to be useful here.
|
|
43
|
+
export function relatedHits(ranked, edges, byPath, limit = 5) {
|
|
44
|
+
const seen = new Set(ranked.map((hit) => hit.path))
|
|
45
|
+
const extra = []
|
|
46
|
+
for (const hit of ranked) {
|
|
47
|
+
for (const edge of edges) {
|
|
48
|
+
if (edge.kind !== "ref" && edge.kind !== "link") continue
|
|
49
|
+
const other = edge.from === hit.path ? edge.to : edge.to === hit.path ? edge.from : ""
|
|
50
|
+
if (!other || seen.has(other)) continue
|
|
51
|
+
seen.add(other)
|
|
52
|
+
const node = byPath.get(other)
|
|
53
|
+
extra.push({
|
|
54
|
+
path: other,
|
|
55
|
+
score: hit.score,
|
|
56
|
+
title: node?.title || "",
|
|
57
|
+
description: "related",
|
|
58
|
+
related: true,
|
|
59
|
+
})
|
|
60
|
+
if (extra.length >= limit) return extra
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return extra
|
|
64
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// A rough, deterministic size estimate so the index can show how much an entry
|
|
2
|
+
// costs to load. It is a character count, not a tokenizer: treat it as a
|
|
3
|
+
// relative guide, not as an exact number for any model.
|
|
4
|
+
export function estimateTokens(text) {
|
|
5
|
+
const normalized = String(text || "").replace(/\r\n/g, "\n").trim()
|
|
6
|
+
if (!normalized) return 0
|
|
7
|
+
return Math.ceil(normalized.length / 4)
|
|
8
|
+
}
|