@ruverd/julius 0.0.0-stage → 0.24.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/CHANGELOG.md +31 -0
- package/CREDITS.md +25 -0
- package/LICENSE +21 -0
- package/PROVENANCE.md +9 -0
- package/README.md +225 -2
- package/dist/ai/crux.d.ts +60 -0
- package/dist/ai/crux.d.ts.map +1 -0
- package/dist/ai/crux.js +141 -0
- package/dist/ai/crux.js.map +1 -0
- package/dist/ai/failure.d.ts +60 -0
- package/dist/ai/failure.d.ts.map +1 -0
- package/dist/ai/failure.js +86 -0
- package/dist/ai/failure.js.map +1 -0
- package/dist/ai/llm/anthropic.d.ts +37 -0
- package/dist/ai/llm/anthropic.d.ts.map +1 -0
- package/dist/ai/llm/anthropic.js +144 -0
- package/dist/ai/llm/anthropic.js.map +1 -0
- package/dist/ai/llm/factory.d.ts +28 -0
- package/dist/ai/llm/factory.d.ts.map +1 -0
- package/dist/ai/llm/factory.js +36 -0
- package/dist/ai/llm/factory.js.map +1 -0
- package/dist/ai/llm/litellm.d.ts +34 -0
- package/dist/ai/llm/litellm.d.ts.map +1 -0
- package/dist/ai/llm/litellm.js +45 -0
- package/dist/ai/llm/litellm.js.map +1 -0
- package/dist/ai/llm/openai.d.ts +44 -0
- package/dist/ai/llm/openai.d.ts.map +1 -0
- package/dist/ai/llm/openai.js +239 -0
- package/dist/ai/llm/openai.js.map +1 -0
- package/dist/ai/llm/orcarouter.d.ts +34 -0
- package/dist/ai/llm/orcarouter.d.ts.map +1 -0
- package/dist/ai/llm/orcarouter.js +45 -0
- package/dist/ai/llm/orcarouter.js.map +1 -0
- package/dist/ai/llm/recover-tool.d.ts +19 -0
- package/dist/ai/llm/recover-tool.d.ts.map +1 -0
- package/dist/ai/llm/recover-tool.js +109 -0
- package/dist/ai/llm/recover-tool.js.map +1 -0
- package/dist/ai/llm/types.d.ts +122 -0
- package/dist/ai/llm/types.d.ts.map +1 -0
- package/dist/ai/llm/types.js +33 -0
- package/dist/ai/llm/types.js.map +1 -0
- package/dist/ai/providers.d.ts +59 -0
- package/dist/ai/providers.d.ts.map +1 -0
- package/dist/ai/providers.js +54 -0
- package/dist/ai/providers.js.map +1 -0
- package/dist/ai/summarize.d.ts +25 -0
- package/dist/ai/summarize.d.ts.map +1 -0
- package/dist/ai/summarize.js +34 -0
- package/dist/ai/summarize.js.map +1 -0
- package/dist/ai/synthesize.d.ts +40 -0
- package/dist/ai/synthesize.d.ts.map +1 -0
- package/dist/ai/synthesize.js +131 -0
- package/dist/ai/synthesize.js.map +1 -0
- package/dist/app/checkout.d.ts +46 -0
- package/dist/app/checkout.d.ts.map +1 -0
- package/dist/app/checkout.js +223 -0
- package/dist/app/checkout.js.map +1 -0
- package/dist/app/events.d.ts +44 -0
- package/dist/app/events.d.ts.map +1 -0
- package/dist/app/events.js +64 -0
- package/dist/app/events.js.map +1 -0
- package/dist/app/identity.d.ts +54 -0
- package/dist/app/identity.d.ts.map +1 -0
- package/dist/app/identity.js +96 -0
- package/dist/app/identity.js.map +1 -0
- package/dist/app/main.d.ts +2 -0
- package/dist/app/main.d.ts.map +1 -0
- package/dist/app/main.js +62 -0
- package/dist/app/main.js.map +1 -0
- package/dist/app/pages.d.ts +56 -0
- package/dist/app/pages.d.ts.map +1 -0
- package/dist/app/pages.js +193 -0
- package/dist/app/pages.js.map +1 -0
- package/dist/app/queue.d.ts +40 -0
- package/dist/app/queue.d.ts.map +1 -0
- package/dist/app/queue.js +68 -0
- package/dist/app/queue.js.map +1 -0
- package/dist/app/review-process.d.ts +66 -0
- package/dist/app/review-process.d.ts.map +1 -0
- package/dist/app/review-process.js +200 -0
- package/dist/app/review-process.js.map +1 -0
- package/dist/app/review-worker.d.ts +2 -0
- package/dist/app/review-worker.d.ts.map +1 -0
- package/dist/app/review-worker.js +108 -0
- package/dist/app/review-worker.js.map +1 -0
- package/dist/app/review.d.ts +23 -0
- package/dist/app/review.d.ts.map +1 -0
- package/dist/app/review.js +142 -0
- package/dist/app/review.js.map +1 -0
- package/dist/app/server.d.ts +49 -0
- package/dist/app/server.d.ts.map +1 -0
- package/dist/app/server.js +123 -0
- package/dist/app/server.js.map +1 -0
- package/dist/ask/ask.d.ts +195 -0
- package/dist/ask/ask.d.ts.map +1 -0
- package/dist/ask/ask.js +1252 -0
- package/dist/ask/ask.js.map +1 -0
- package/dist/ask/file-rank.d.ts +72 -0
- package/dist/ask/file-rank.d.ts.map +1 -0
- package/dist/ask/file-rank.js +160 -0
- package/dist/ask/file-rank.js.map +1 -0
- package/dist/ask/file-selection.d.ts +22 -0
- package/dist/ask/file-selection.d.ts.map +1 -0
- package/dist/ask/file-selection.js +66 -0
- package/dist/ask/file-selection.js.map +1 -0
- package/dist/ask/fuse.d.ts +195 -0
- package/dist/ask/fuse.d.ts.map +1 -0
- package/dist/ask/fuse.js +344 -0
- package/dist/ask/fuse.js.map +1 -0
- package/dist/ask/graphrank.d.ts +61 -0
- package/dist/ask/graphrank.d.ts.map +1 -0
- package/dist/ask/graphrank.js +130 -0
- package/dist/ask/graphrank.js.map +1 -0
- package/dist/ask/index-file.d.ts +44 -0
- package/dist/ask/index-file.d.ts.map +1 -0
- package/dist/ask/index-file.js +128 -0
- package/dist/ask/index-file.js.map +1 -0
- package/dist/bin/julius.d.ts +3 -0
- package/dist/bin/julius.d.ts.map +1 -0
- package/dist/bin/julius.js +4 -0
- package/dist/bin/julius.js.map +1 -0
- package/dist/blast/blast-cli.d.ts +35 -0
- package/dist/blast/blast-cli.d.ts.map +1 -0
- package/dist/blast/blast-cli.js +155 -0
- package/dist/blast/blast-cli.js.map +1 -0
- package/dist/blast/blast.d.ts +128 -0
- package/dist/blast/blast.d.ts.map +1 -0
- package/dist/blast/blast.js +383 -0
- package/dist/blast/blast.js.map +1 -0
- package/dist/blast/diff.d.ts +53 -0
- package/dist/blast/diff.d.ts.map +1 -0
- package/dist/blast/diff.js +193 -0
- package/dist/blast/diff.js.map +1 -0
- package/dist/blast/evidence.d.ts +51 -0
- package/dist/blast/evidence.d.ts.map +1 -0
- package/dist/blast/evidence.js +162 -0
- package/dist/blast/evidence.js.map +1 -0
- package/dist/blast/modules.d.ts +33 -0
- package/dist/blast/modules.d.ts.map +1 -0
- package/dist/blast/modules.js +83 -0
- package/dist/blast/modules.js.map +1 -0
- package/dist/blast/name.d.ts +74 -0
- package/dist/blast/name.d.ts.map +1 -0
- package/dist/blast/name.js +269 -0
- package/dist/blast/name.js.map +1 -0
- package/dist/blast/owners.d.ts +85 -0
- package/dist/blast/owners.d.ts.map +1 -0
- package/dist/blast/owners.js +272 -0
- package/dist/blast/owners.js.map +1 -0
- package/dist/blast/render.d.ts +46 -0
- package/dist/blast/render.d.ts.map +1 -0
- package/dist/blast/render.js +422 -0
- package/dist/blast/render.js.map +1 -0
- package/dist/blast/viz.d.ts +37 -0
- package/dist/blast/viz.d.ts.map +1 -0
- package/dist/blast/viz.js +180 -0
- package/dist/blast/viz.js.map +1 -0
- package/dist/brand.d.ts +13 -0
- package/dist/brand.d.ts.map +1 -0
- package/dist/brand.js +43 -0
- package/dist/brand.js.map +1 -0
- package/dist/check/learning-edits.d.ts +9 -0
- package/dist/check/learning-edits.d.ts.map +1 -0
- package/dist/check/learning-edits.js +62 -0
- package/dist/check/learning-edits.js.map +1 -0
- package/dist/check/local-check.d.ts +104 -0
- package/dist/check/local-check.d.ts.map +1 -0
- package/dist/check/local-check.js +830 -0
- package/dist/check/local-check.js.map +1 -0
- package/dist/check/types.d.ts +31 -0
- package/dist/check/types.d.ts.map +1 -0
- package/dist/check/types.js +2 -0
- package/dist/check/types.js.map +1 -0
- package/dist/claude/build-progress.d.ts +29 -0
- package/dist/claude/build-progress.d.ts.map +1 -0
- package/dist/claude/build-progress.js +76 -0
- package/dist/claude/build-progress.js.map +1 -0
- package/dist/claude/format.d.ts +131 -0
- package/dist/claude/format.d.ts.map +1 -0
- package/dist/claude/format.js +328 -0
- package/dist/claude/format.js.map +1 -0
- package/dist/claude/hook-layers.d.ts +8 -0
- package/dist/claude/hook-layers.d.ts.map +1 -0
- package/dist/claude/hook-layers.js +74 -0
- package/dist/claude/hook-layers.js.map +1 -0
- package/dist/claude/hooks.d.ts +101 -0
- package/dist/claude/hooks.d.ts.map +1 -0
- package/dist/claude/hooks.js +849 -0
- package/dist/claude/hooks.js.map +1 -0
- package/dist/claude/init.d.ts +70 -0
- package/dist/claude/init.d.ts.map +1 -0
- package/dist/claude/init.js +207 -0
- package/dist/claude/init.js.map +1 -0
- package/dist/claude/note-signals.d.ts +28 -0
- package/dist/claude/note-signals.d.ts.map +1 -0
- package/dist/claude/note-signals.js +325 -0
- package/dist/claude/note-signals.js.map +1 -0
- package/dist/claude/paths.d.ts +9 -0
- package/dist/claude/paths.d.ts.map +1 -0
- package/dist/claude/paths.js +22 -0
- package/dist/claude/paths.js.map +1 -0
- package/dist/claude/session-metrics.d.ts +73 -0
- package/dist/claude/session-metrics.d.ts.map +1 -0
- package/dist/claude/session-metrics.js +209 -0
- package/dist/claude/session-metrics.js.map +1 -0
- package/dist/claude/settings-merge.d.ts +66 -0
- package/dist/claude/settings-merge.d.ts.map +1 -0
- package/dist/claude/settings-merge.js +249 -0
- package/dist/claude/settings-merge.js.map +1 -0
- package/dist/claude/shim-template.d.ts +18 -0
- package/dist/claude/shim-template.d.ts.map +1 -0
- package/dist/claude/shim-template.js +226 -0
- package/dist/claude/shim-template.js.map +1 -0
- package/dist/claude/skill-template.d.ts +12 -0
- package/dist/claude/skill-template.d.ts.map +1 -0
- package/dist/claude/skill-template.js +294 -0
- package/dist/claude/skill-template.js.map +1 -0
- package/dist/claude/state.d.ts +73 -0
- package/dist/claude/state.d.ts.map +1 -0
- package/dist/claude/state.js +33 -0
- package/dist/claude/state.js.map +1 -0
- package/dist/claude/stats.d.ts +5 -0
- package/dist/claude/stats.d.ts.map +1 -0
- package/dist/claude/stats.js +24 -0
- package/dist/claude/stats.js.map +1 -0
- package/dist/claude/statusline.d.ts +14 -0
- package/dist/claude/statusline.d.ts.map +1 -0
- package/dist/claude/statusline.js +45 -0
- package/dist/claude/statusline.js.map +1 -0
- package/dist/claude/sync-run.d.ts +3 -0
- package/dist/claude/sync-run.d.ts.map +1 -0
- package/dist/claude/sync-run.js +46 -0
- package/dist/claude/sync-run.js.map +1 -0
- package/dist/claude/tally.d.ts +50 -0
- package/dist/claude/tally.d.ts.map +1 -0
- package/dist/claude/tally.js +211 -0
- package/dist/claude/tally.js.map +1 -0
- package/dist/cli-epilogue.d.ts +12 -0
- package/dist/cli-epilogue.d.ts.map +1 -0
- package/dist/cli-epilogue.js +55 -0
- package/dist/cli-epilogue.js.map +1 -0
- package/dist/cli-meta.d.ts +45 -0
- package/dist/cli-meta.d.ts.map +1 -0
- package/dist/cli-meta.js +145 -0
- package/dist/cli-meta.js.map +1 -0
- package/dist/cli-picker.d.ts +129 -0
- package/dist/cli-picker.d.ts.map +1 -0
- package/dist/cli-picker.js +432 -0
- package/dist/cli-picker.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2213 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud/diff.d.ts +20 -0
- package/dist/cloud/diff.d.ts.map +1 -0
- package/dist/cloud/diff.js +59 -0
- package/dist/cloud/diff.js.map +1 -0
- package/dist/cloud/nudge.d.ts +66 -0
- package/dist/cloud/nudge.d.ts.map +1 -0
- package/dist/cloud/nudge.js +268 -0
- package/dist/cloud/nudge.js.map +1 -0
- package/dist/cloud/workspace-sync.d.ts +58 -0
- package/dist/cloud/workspace-sync.d.ts.map +1 -0
- package/dist/cloud/workspace-sync.js +268 -0
- package/dist/cloud/workspace-sync.js.map +1 -0
- package/dist/cloud/workspace.d.ts +159 -0
- package/dist/cloud/workspace.d.ts.map +1 -0
- package/dist/cloud/workspace.js +134 -0
- package/dist/cloud/workspace.js.map +1 -0
- package/dist/context/build.d.ts +52 -0
- package/dist/context/build.d.ts.map +1 -0
- package/dist/context/build.js +362 -0
- package/dist/context/build.js.map +1 -0
- package/dist/context/check.d.ts +42 -0
- package/dist/context/check.d.ts.map +1 -0
- package/dist/context/check.js +162 -0
- package/dist/context/check.js.map +1 -0
- package/dist/context/map-dir.d.ts +4 -0
- package/dist/context/map-dir.d.ts.map +1 -0
- package/dist/context/map-dir.js +6 -0
- package/dist/context/map-dir.js.map +1 -0
- package/dist/context/node-file.d.ts +109 -0
- package/dist/context/node-file.d.ts.map +1 -0
- package/dist/context/node-file.js +362 -0
- package/dist/context/node-file.js.map +1 -0
- package/dist/context/price.d.ts +49 -0
- package/dist/context/price.d.ts.map +1 -0
- package/dist/context/price.js +83 -0
- package/dist/context/price.js.map +1 -0
- package/dist/context/savings.d.ts +26 -0
- package/dist/context/savings.d.ts.map +1 -0
- package/dist/context/savings.js +59 -0
- package/dist/context/savings.js.map +1 -0
- package/dist/economy/cli.d.ts +3 -0
- package/dist/economy/cli.d.ts.map +1 -0
- package/dist/economy/cli.js +52 -0
- package/dist/economy/cli.js.map +1 -0
- package/dist/economy/delivery.d.ts +49 -0
- package/dist/economy/delivery.d.ts.map +1 -0
- package/dist/economy/delivery.js +176 -0
- package/dist/economy/delivery.js.map +1 -0
- package/dist/economy/index.d.ts +67 -0
- package/dist/economy/index.d.ts.map +1 -0
- package/dist/economy/index.js +519 -0
- package/dist/economy/index.js.map +1 -0
- package/dist/engine.d.ts +83 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +122 -0
- package/dist/engine.js.map +1 -0
- package/dist/evaluation/index.d.ts +41 -0
- package/dist/evaluation/index.d.ts.map +1 -0
- package/dist/evaluation/index.js +61 -0
- package/dist/evaluation/index.js.map +1 -0
- package/dist/graph/bindings.d.ts +64 -0
- package/dist/graph/bindings.d.ts.map +1 -0
- package/dist/graph/bindings.js +713 -0
- package/dist/graph/bindings.js.map +1 -0
- package/dist/graph/build.d.ts +88 -0
- package/dist/graph/build.d.ts.map +1 -0
- package/dist/graph/build.js +375 -0
- package/dist/graph/build.js.map +1 -0
- package/dist/graph/cards.d.ts +46 -0
- package/dist/graph/cards.d.ts.map +1 -0
- package/dist/graph/cards.js +280 -0
- package/dist/graph/cards.js.map +1 -0
- package/dist/graph/check.d.ts +25 -0
- package/dist/graph/check.d.ts.map +1 -0
- package/dist/graph/check.js +192 -0
- package/dist/graph/check.js.map +1 -0
- package/dist/graph/container.d.ts +63 -0
- package/dist/graph/container.d.ts.map +1 -0
- package/dist/graph/container.js +190 -0
- package/dist/graph/container.js.map +1 -0
- package/dist/graph/enrich.d.ts +62 -0
- package/dist/graph/enrich.d.ts.map +1 -0
- package/dist/graph/enrich.js +253 -0
- package/dist/graph/enrich.js.map +1 -0
- package/dist/graph/extract-cache.d.ts +101 -0
- package/dist/graph/extract-cache.d.ts.map +1 -0
- package/dist/graph/extract-cache.js +199 -0
- package/dist/graph/extract-cache.js.map +1 -0
- package/dist/graph/extract.d.ts +85 -0
- package/dist/graph/extract.d.ts.map +1 -0
- package/dist/graph/extract.js +2376 -0
- package/dist/graph/extract.js.map +1 -0
- package/dist/graph/fingerprint.d.ts +76 -0
- package/dist/graph/fingerprint.d.ts.map +1 -0
- package/dist/graph/fingerprint.js +160 -0
- package/dist/graph/fingerprint.js.map +1 -0
- package/dist/graph/generic.d.ts +74 -0
- package/dist/graph/generic.d.ts.map +1 -0
- package/dist/graph/generic.js +580 -0
- package/dist/graph/generic.js.map +1 -0
- package/dist/graph/invariants.d.ts +33 -0
- package/dist/graph/invariants.d.ts.map +1 -0
- package/dist/graph/invariants.js +52 -0
- package/dist/graph/invariants.js.map +1 -0
- package/dist/graph/load.d.ts +29 -0
- package/dist/graph/load.d.ts.map +1 -0
- package/dist/graph/load.js +97 -0
- package/dist/graph/load.js.map +1 -0
- package/dist/graph/lsp/client.d.ts +43 -0
- package/dist/graph/lsp/client.d.ts.map +1 -0
- package/dist/graph/lsp/client.js +179 -0
- package/dist/graph/lsp/client.js.map +1 -0
- package/dist/graph/lsp/enrich.d.ts +11 -0
- package/dist/graph/lsp/enrich.d.ts.map +1 -0
- package/dist/graph/lsp/enrich.js +155 -0
- package/dist/graph/lsp/enrich.js.map +1 -0
- package/dist/graph/lsp/registry.d.ts +15 -0
- package/dist/graph/lsp/registry.d.ts.map +1 -0
- package/dist/graph/lsp/registry.js +46 -0
- package/dist/graph/lsp/registry.js.map +1 -0
- package/dist/graph/map.d.ts +107 -0
- package/dist/graph/map.d.ts.map +1 -0
- package/dist/graph/map.js +239 -0
- package/dist/graph/map.js.map +1 -0
- package/dist/graph/native.d.ts +38 -0
- package/dist/graph/native.d.ts.map +1 -0
- package/dist/graph/native.js +169 -0
- package/dist/graph/native.js.map +1 -0
- package/dist/graph/queries/c.scm +13 -0
- package/dist/graph/queries/c_sharp.scm +19 -0
- package/dist/graph/queries/clojure.scm +58 -0
- package/dist/graph/queries/cpp.scm +23 -0
- package/dist/graph/queries/dart.scm +42 -0
- package/dist/graph/queries/elixir.scm +54 -0
- package/dist/graph/queries/java.scm +20 -0
- package/dist/graph/queries/kotlin.scm +43 -0
- package/dist/graph/queries/lua.scm +36 -0
- package/dist/graph/queries/nix.scm +32 -0
- package/dist/graph/queries/php.scm +40 -0
- package/dist/graph/queries/ruby.scm +65 -0
- package/dist/graph/queries/rust.scm +41 -0
- package/dist/graph/queries/scala.scm +66 -0
- package/dist/graph/queries/solidity.scm +43 -0
- package/dist/graph/queries/swift.scm +51 -0
- package/dist/graph/refresh.d.ts +49 -0
- package/dist/graph/refresh.d.ts.map +1 -0
- package/dist/graph/refresh.js +255 -0
- package/dist/graph/refresh.js.map +1 -0
- package/dist/graph/relations.d.ts +14 -0
- package/dist/graph/relations.d.ts.map +1 -0
- package/dist/graph/relations.js +8 -0
- package/dist/graph/relations.js.map +1 -0
- package/dist/graph/resolve.d.ts +17 -0
- package/dist/graph/resolve.d.ts.map +1 -0
- package/dist/graph/resolve.js +654 -0
- package/dist/graph/resolve.js.map +1 -0
- package/dist/graph/root.d.ts +11 -0
- package/dist/graph/root.d.ts.map +1 -0
- package/dist/graph/root.js +40 -0
- package/dist/graph/root.js.map +1 -0
- package/dist/graph/scopes.d.ts +42 -0
- package/dist/graph/scopes.d.ts.map +1 -0
- package/dist/graph/scopes.js +342 -0
- package/dist/graph/scopes.js.map +1 -0
- package/dist/graph/seed.d.ts +38 -0
- package/dist/graph/seed.d.ts.map +1 -0
- package/dist/graph/seed.js +226 -0
- package/dist/graph/seed.js.map +1 -0
- package/dist/graph/source-files.d.ts +40 -0
- package/dist/graph/source-files.d.ts.map +1 -0
- package/dist/graph/source-files.js +85 -0
- package/dist/graph/source-files.js.map +1 -0
- package/dist/graph/traverse-cli.d.ts +55 -0
- package/dist/graph/traverse-cli.d.ts.map +1 -0
- package/dist/graph/traverse-cli.js +189 -0
- package/dist/graph/traverse-cli.js.map +1 -0
- package/dist/graph/traverse.d.ts +112 -0
- package/dist/graph/traverse.d.ts.map +1 -0
- package/dist/graph/traverse.js +192 -0
- package/dist/graph/traverse.js.map +1 -0
- package/dist/graph/types.d.ts +78 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +14 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/graph/workspace-cli.d.ts +48 -0
- package/dist/graph/workspace-cli.d.ts.map +1 -0
- package/dist/graph/workspace-cli.js +102 -0
- package/dist/graph/workspace-cli.js.map +1 -0
- package/dist/graph/workspace.d.ts +135 -0
- package/dist/graph/workspace.d.ts.map +1 -0
- package/dist/graph/workspace.js +598 -0
- package/dist/graph/workspace.js.map +1 -0
- package/dist/graph/write.d.ts +13 -0
- package/dist/graph/write.d.ts.map +1 -0
- package/dist/graph/write.js +86 -0
- package/dist/graph/write.js.map +1 -0
- package/dist/hosts/antigravity.d.ts +8 -0
- package/dist/hosts/antigravity.d.ts.map +1 -0
- package/dist/hosts/antigravity.js +42 -0
- package/dist/hosts/antigravity.js.map +1 -0
- package/dist/hosts/claude-global.d.ts +36 -0
- package/dist/hosts/claude-global.d.ts.map +1 -0
- package/dist/hosts/claude-global.js +153 -0
- package/dist/hosts/claude-global.js.map +1 -0
- package/dist/hosts/codex-hooks.d.ts +11 -0
- package/dist/hosts/codex-hooks.d.ts.map +1 -0
- package/dist/hosts/codex-hooks.js +80 -0
- package/dist/hosts/codex-hooks.js.map +1 -0
- package/dist/hosts/config-write.d.ts +36 -0
- package/dist/hosts/config-write.d.ts.map +1 -0
- package/dist/hosts/config-write.js +64 -0
- package/dist/hosts/config-write.js.map +1 -0
- package/dist/hosts/cursor-hooks.d.ts +21 -0
- package/dist/hosts/cursor-hooks.d.ts.map +1 -0
- package/dist/hosts/cursor-hooks.js +103 -0
- package/dist/hosts/cursor-hooks.js.map +1 -0
- package/dist/hosts/init.d.ts +26 -0
- package/dist/hosts/init.d.ts.map +1 -0
- package/dist/hosts/init.js +82 -0
- package/dist/hosts/init.js.map +1 -0
- package/dist/hosts/install.d.ts +12 -0
- package/dist/hosts/install.d.ts.map +1 -0
- package/dist/hosts/install.js +347 -0
- package/dist/hosts/install.js.map +1 -0
- package/dist/hosts/instructions.d.ts +7 -0
- package/dist/hosts/instructions.d.ts.map +1 -0
- package/dist/hosts/instructions.js +71 -0
- package/dist/hosts/instructions.js.map +1 -0
- package/dist/hosts/investigation-instructions.d.ts +2 -0
- package/dist/hosts/investigation-instructions.d.ts.map +1 -0
- package/dist/hosts/investigation-instructions.js +2 -0
- package/dist/hosts/investigation-instructions.js.map +1 -0
- package/dist/hosts/mcp-config.d.ts +59 -0
- package/dist/hosts/mcp-config.d.ts.map +1 -0
- package/dist/hosts/mcp-config.js +229 -0
- package/dist/hosts/mcp-config.js.map +1 -0
- package/dist/hosts/plan.d.ts +32 -0
- package/dist/hosts/plan.d.ts.map +1 -0
- package/dist/hosts/plan.js +77 -0
- package/dist/hosts/plan.js.map +1 -0
- package/dist/hosts/registry.d.ts +35 -0
- package/dist/hosts/registry.d.ts.map +1 -0
- package/dist/hosts/registry.js +157 -0
- package/dist/hosts/registry.js.map +1 -0
- package/dist/hosts/retract.d.ts +47 -0
- package/dist/hosts/retract.d.ts.map +1 -0
- package/dist/hosts/retract.js +541 -0
- package/dist/hosts/retract.js.map +1 -0
- package/dist/hosts/sections.d.ts +46 -0
- package/dist/hosts/sections.d.ts.map +1 -0
- package/dist/hosts/sections.js +126 -0
- package/dist/hosts/sections.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/ingest/fs.d.ts +79 -0
- package/dist/ingest/fs.d.ts.map +1 -0
- package/dist/ingest/fs.js +307 -0
- package/dist/ingest/fs.js.map +1 -0
- package/dist/init-guard.d.ts +11 -0
- package/dist/init-guard.d.ts.map +1 -0
- package/dist/init-guard.js +21 -0
- package/dist/init-guard.js.map +1 -0
- package/dist/investigation/index.d.ts +57 -0
- package/dist/investigation/index.d.ts.map +1 -0
- package/dist/investigation/index.js +315 -0
- package/dist/investigation/index.js.map +1 -0
- package/dist/mcp/compact.d.ts +9 -0
- package/dist/mcp/compact.d.ts.map +1 -0
- package/dist/mcp/compact.js +133 -0
- package/dist/mcp/compact.js.map +1 -0
- package/dist/mcp/instructions.d.ts +5 -0
- package/dist/mcp/instructions.d.ts.map +1 -0
- package/dist/mcp/instructions.js +57 -0
- package/dist/mcp/instructions.js.map +1 -0
- package/dist/mcp/server.d.ts +7 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +128 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tool-names.d.ts +20 -0
- package/dist/mcp/tool-names.d.ts.map +1 -0
- package/dist/mcp/tool-names.js +36 -0
- package/dist/mcp/tool-names.js.map +1 -0
- package/dist/mcp/tools.d.ts +22 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +300 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/notes/ask-notes.d.ts +8 -0
- package/dist/notes/ask-notes.d.ts.map +1 -0
- package/dist/notes/ask-notes.js +19 -0
- package/dist/notes/ask-notes.js.map +1 -0
- package/dist/notes/branches.d.ts +102 -0
- package/dist/notes/branches.d.ts.map +1 -0
- package/dist/notes/branches.js +304 -0
- package/dist/notes/branches.js.map +1 -0
- package/dist/notes/cold-start.d.ts +177 -0
- package/dist/notes/cold-start.d.ts.map +1 -0
- package/dist/notes/cold-start.js +537 -0
- package/dist/notes/cold-start.js.map +1 -0
- package/dist/notes/edit-overlap.d.ts +62 -0
- package/dist/notes/edit-overlap.d.ts.map +1 -0
- package/dist/notes/edit-overlap.js +202 -0
- package/dist/notes/edit-overlap.js.map +1 -0
- package/dist/notes/git-facts.d.ts +21 -0
- package/dist/notes/git-facts.d.ts.map +1 -0
- package/dist/notes/git-facts.js +121 -0
- package/dist/notes/git-facts.js.map +1 -0
- package/dist/notes/home.d.ts +87 -0
- package/dist/notes/home.d.ts.map +1 -0
- package/dist/notes/home.js +430 -0
- package/dist/notes/home.js.map +1 -0
- package/dist/notes/learning-fields.d.ts +102 -0
- package/dist/notes/learning-fields.d.ts.map +1 -0
- package/dist/notes/learning-fields.js +217 -0
- package/dist/notes/learning-fields.js.map +1 -0
- package/dist/notes/note-gate.d.ts +42 -0
- package/dist/notes/note-gate.d.ts.map +1 -0
- package/dist/notes/note-gate.js +181 -0
- package/dist/notes/note-gate.js.map +1 -0
- package/dist/notes/notes.d.ts +214 -0
- package/dist/notes/notes.d.ts.map +1 -0
- package/dist/notes/notes.js +591 -0
- package/dist/notes/notes.js.map +1 -0
- package/dist/notes/pr-reviews.d.ts +108 -0
- package/dist/notes/pr-reviews.d.ts.map +1 -0
- package/dist/notes/pr-reviews.js +325 -0
- package/dist/notes/pr-reviews.js.map +1 -0
- package/dist/notes/repo-julius.d.ts +18 -0
- package/dist/notes/repo-julius.d.ts.map +1 -0
- package/dist/notes/repo-julius.js +111 -0
- package/dist/notes/repo-julius.js.map +1 -0
- package/dist/notes/session-cost.d.ts +35 -0
- package/dist/notes/session-cost.d.ts.map +1 -0
- package/dist/notes/session-cost.js +276 -0
- package/dist/notes/session-cost.js.map +1 -0
- package/dist/search/grep-cli.d.ts +35 -0
- package/dist/search/grep-cli.d.ts.map +1 -0
- package/dist/search/grep-cli.js +115 -0
- package/dist/search/grep-cli.js.map +1 -0
- package/dist/search/grep.d.ts +60 -0
- package/dist/search/grep.d.ts.map +1 -0
- package/dist/search/grep.js +176 -0
- package/dist/search/grep.js.map +1 -0
- package/dist/search/ignored-code.d.ts +9 -0
- package/dist/search/ignored-code.d.ts.map +1 -0
- package/dist/search/ignored-code.js +73 -0
- package/dist/search/ignored-code.js.map +1 -0
- package/dist/skills/skills.d.ts +118 -0
- package/dist/skills/skills.d.ts.map +1 -0
- package/dist/skills/skills.js +370 -0
- package/dist/skills/skills.js.map +1 -0
- package/dist/telemetry/contract.d.ts +103 -0
- package/dist/telemetry/contract.d.ts.map +1 -0
- package/dist/telemetry/contract.js +270 -0
- package/dist/telemetry/contract.js.map +1 -0
- package/dist/telemetry/flush.d.ts +21 -0
- package/dist/telemetry/flush.d.ts.map +1 -0
- package/dist/telemetry/flush.js +85 -0
- package/dist/telemetry/flush.js.map +1 -0
- package/dist/telemetry/gate.d.ts +30 -0
- package/dist/telemetry/gate.d.ts.map +1 -0
- package/dist/telemetry/gate.js +81 -0
- package/dist/telemetry/gate.js.map +1 -0
- package/dist/telemetry/identity.d.ts +40 -0
- package/dist/telemetry/identity.d.ts.map +1 -0
- package/dist/telemetry/identity.js +80 -0
- package/dist/telemetry/identity.js.map +1 -0
- package/dist/telemetry/index.d.ts +18 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +16 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/key.d.ts +4 -0
- package/dist/telemetry/key.d.ts.map +1 -0
- package/dist/telemetry/key.js +4 -0
- package/dist/telemetry/key.js.map +1 -0
- package/dist/telemetry/notice.d.ts +19 -0
- package/dist/telemetry/notice.d.ts.map +1 -0
- package/dist/telemetry/notice.js +93 -0
- package/dist/telemetry/notice.js.map +1 -0
- package/dist/telemetry/queue.d.ts +35 -0
- package/dist/telemetry/queue.d.ts.map +1 -0
- package/dist/telemetry/queue.js +162 -0
- package/dist/telemetry/queue.js.map +1 -0
- package/dist/telemetry/send.d.ts +19 -0
- package/dist/telemetry/send.d.ts.map +1 -0
- package/dist/telemetry/send.js +84 -0
- package/dist/telemetry/send.js.map +1 -0
- package/dist/telemetry/sessions.d.ts +25 -0
- package/dist/telemetry/sessions.d.ts.map +1 -0
- package/dist/telemetry/sessions.js +104 -0
- package/dist/telemetry/sessions.js.map +1 -0
- package/dist/telemetry/track.d.ts +62 -0
- package/dist/telemetry/track.d.ts.map +1 -0
- package/dist/telemetry/track.js +142 -0
- package/dist/telemetry/track.js.map +1 -0
- package/dist/upkeep-run.d.ts +15 -0
- package/dist/upkeep-run.d.ts.map +1 -0
- package/dist/upkeep-run.js +71 -0
- package/dist/upkeep-run.js.map +1 -0
- package/dist/upkeep.d.ts +125 -0
- package/dist/upkeep.d.ts.map +1 -0
- package/dist/upkeep.js +255 -0
- package/dist/upkeep.js.map +1 -0
- package/dist/util/browser.d.ts +3 -0
- package/dist/util/browser.d.ts.map +1 -0
- package/dist/util/browser.js +14 -0
- package/dist/util/browser.js.map +1 -0
- package/dist/util/front-matter.d.ts +19 -0
- package/dist/util/front-matter.d.ts.map +1 -0
- package/dist/util/front-matter.js +21 -0
- package/dist/util/front-matter.js.map +1 -0
- package/dist/util/id.d.ts +7 -0
- package/dist/util/id.d.ts.map +1 -0
- package/dist/util/id.js +14 -0
- package/dist/util/id.js.map +1 -0
- package/dist/util/paths.d.ts +29 -0
- package/dist/util/paths.d.ts.map +1 -0
- package/dist/util/paths.js +71 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/source.d.ts +4 -0
- package/dist/util/source.d.ts.map +1 -0
- package/dist/util/source.js +12 -0
- package/dist/util/source.js.map +1 -0
- package/dist/util/spinner.d.ts +15 -0
- package/dist/util/spinner.d.ts.map +1 -0
- package/dist/util/spinner.js +52 -0
- package/dist/util/spinner.js.map +1 -0
- package/dist/util/state.d.ts +100 -0
- package/dist/util/state.d.ts.map +1 -0
- package/dist/util/state.js +186 -0
- package/dist/util/state.js.map +1 -0
- package/dist/viewer/app.js +2 -0
- package/dist/viewer/index.html +49 -0
- package/dist/viewer/style.css +154 -0
- package/dist/viz/assemble.d.ts +83 -0
- package/dist/viz/assemble.d.ts.map +1 -0
- package/dist/viz/assemble.js +101 -0
- package/dist/viz/assemble.js.map +1 -0
- package/dist/viz/export.d.ts +39 -0
- package/dist/viz/export.d.ts.map +1 -0
- package/dist/viz/export.js +98 -0
- package/dist/viz/export.js.map +1 -0
- package/dist/viz/serve.d.ts +12 -0
- package/dist/viz/serve.d.ts.map +1 -0
- package/dist/viz/serve.js +129 -0
- package/dist/viz/serve.js.map +1 -0
- package/docs/assets/context-benchmark.svg +31 -0
- package/docs/assets/julius-hero.png +0 -0
- package/docs/upstream-changelog.md +785 -0
- package/package.json +138 -4
package/dist/cli.js
ADDED
|
@@ -0,0 +1,2213 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** Julius CLI: local graph navigation and shared repository learnings. */
|
|
3
|
+
import { installGlobal, uninstallGlobal } from "./hosts/install.js";
|
|
4
|
+
import { registerEconomyCommands } from "./economy/cli.js";
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import "dotenv/config";
|
|
7
|
+
import { Command } from "commander";
|
|
8
|
+
import { statSync } from "node:fs";
|
|
9
|
+
import { basename, dirname, join, relative, resolve } from "node:path";
|
|
10
|
+
import { fileURLToPath } from "node:url";
|
|
11
|
+
import { Julius } from "./engine.js";
|
|
12
|
+
import { resolveConfig } from "./ai/providers.js";
|
|
13
|
+
import { formatCheckReport } from "./context/check.js";
|
|
14
|
+
import { formatGraphCheckReport } from "./graph/check.js";
|
|
15
|
+
import { buildGraphIfMissing, runInit } from "./claude/init.js";
|
|
16
|
+
import { statuslineWanted } from "./claude/settings-merge.js";
|
|
17
|
+
import { runHostsInit } from "./hosts/init.js";
|
|
18
|
+
import { hostIds } from "./hosts/registry.js";
|
|
19
|
+
import { ensureRepoHome, keepsNotes, rememberRepo, repoName, repoPlace, shownPath } from "./notes/home.js";
|
|
20
|
+
import { brand, cmd, tag } from "./brand.js";
|
|
21
|
+
import { branchDiff } from "./cloud/diff.js";
|
|
22
|
+
import { openBrowser } from "./util/browser.js";
|
|
23
|
+
import { learningsAtBase, teammateEdits, withBaseLearnings } from "./check/learning-edits.js";
|
|
24
|
+
import { contextDirFor } from "./context/node-file.js";
|
|
25
|
+
import { loadGraphCached } from "./graph/load.js";
|
|
26
|
+
import { ensureFreshChildren, ensureFreshGraph, refreshNote } from "./graph/refresh.js";
|
|
27
|
+
import { isWorkspaceBuildRoot, readWorkspace } from "./graph/workspace.js";
|
|
28
|
+
import { NOT_GIT_LINE, homeFolderRefusal, isGitWorkTree } from "./init-guard.js";
|
|
29
|
+
import { hasJuliusIndex, nearestJuliusRoot } from "./graph/root.js";
|
|
30
|
+
import { unsupportedExtensions, supportedExtensions } from "./graph/source-files.js";
|
|
31
|
+
import { discoverWorkspaceChildren } from "./graph/scopes.js";
|
|
32
|
+
import { runWorkspaceAsk, runWorkspaceBuild, runWorkspaceCallers, runWorkspaceCheck, runWorkspaceGrep, runWorkspaceMap, } from "./graph/workspace-cli.js";
|
|
33
|
+
import { formatInitEpilogue } from "./cli-epilogue.js";
|
|
34
|
+
import { planInit, selectedWrites } from "./hosts/plan.js";
|
|
35
|
+
import { planRetract, runRetract, changed } from "./hosts/retract.js";
|
|
36
|
+
import { compactWrites, formatNonInteractiveHelp, formatPlan, pickLearnings, runPicker } from "./cli-picker.js";
|
|
37
|
+
import { buildGraphWithProgress } from "./claude/build-progress.js";
|
|
38
|
+
import { homedir } from "node:os";
|
|
39
|
+
import { formatUpgradeReport, formatVersionReport, getNpmViewVersion, readCurrentVersion, readPackageName, runUpgrade } from "./cli-meta.js";
|
|
40
|
+
import { nativeFallbackNotice } from "./graph/native.js";
|
|
41
|
+
import { patchBuildConfig } from "./util/state.js";
|
|
42
|
+
import { normalizePathPrefix } from "./util/paths.js";
|
|
43
|
+
import { latestSession, formatSessionStats, sessionInputRate } from "./claude/session-metrics.js";
|
|
44
|
+
import { listSessionIds, readSession, sessionDir } from "./claude/state.js";
|
|
45
|
+
import { costLabel, listNotes, noteName, notePlace, noteTargets, readingTokens, savedByNote, commitLines, PERSONAL_SAVED_LINE, PR_SPEEDUP, SECTIONS, tokensWorthSaying, sectionLead, shortDate, tokensLabel, writeNote, mentionedFiles } from "./notes/notes.js";
|
|
46
|
+
import { asLearningId, findLearning, liveLearnings } from "./notes/learning-fields.js";
|
|
47
|
+
import { gateNote, namesRepoSymbol, symbolCandidates, trackedFiles } from "./notes/note-gate.js";
|
|
48
|
+
import { aboutTerms, currentSessionCost } from "./notes/session-cost.js";
|
|
49
|
+
import { beginPastRead, finishPastRead } from "./notes/cold-start.js";
|
|
50
|
+
import { beginReviewRead, finishReviewRead } from "./notes/pr-reviews.js";
|
|
51
|
+
import { currentBranch, noteAuthor, teammatesOn } from "./notes/git-facts.js";
|
|
52
|
+
import { confirm, fold, getSkill, learn, listSkills, publish, skillForAgent, skillName, skillStatus } from "./skills/skills.js";
|
|
53
|
+
import { clearPending, cloudLines, loginLink, sessionKey, waitForConnect } from "./cloud/nudge.js";
|
|
54
|
+
import { addRepo, clearCloud, cloudEnabled, fetchMe, fetchTeam, isError, readCloud, writeCloud } from "./cloud/workspace.js";
|
|
55
|
+
import { inWorkspace, maybeSyncInBackground, recordActivity, runSyncChild, syncRepo } from "./cloud/workspace-sync.js";
|
|
56
|
+
import { checkLocally } from "./check/local-check.js";
|
|
57
|
+
import { formatOverlap, maybeRefreshBranches, overlapsWith, pushedWhen, readBranchCache, refreshBranches } from "./notes/branches.js";
|
|
58
|
+
import { ensureRepoJulius, LEARNINGS_DIR } from "./notes/repo-julius.js";
|
|
59
|
+
import { setInputRate } from "./context/savings.js";
|
|
60
|
+
import { formatUpdateNudge, maybeRefreshInBackground, readUpdateCache, refreshUpdateCache, writeStamp } from "./upkeep.js";
|
|
61
|
+
import { countBucket, savedTokensBucket, errorCode, filesBucket, durationBucket, formatDebug, formatStatus, firstRunNotice, isTrackedCommand, langsValue, offReason, maybeFlushInBackground, patchState, runFlush, track, trackFirstRunIfNew, } from "./telemetry/index.js";
|
|
62
|
+
const program = new Command();
|
|
63
|
+
const currentVersion = readCurrentVersion(import.meta.url);
|
|
64
|
+
/** Help-screen groups under julius; julius keeps its one flat list. */
|
|
65
|
+
const GROUP = {
|
|
66
|
+
find: "Find code · your agent runs these:",
|
|
67
|
+
memory: "Team memory:",
|
|
68
|
+
setup: "Setup:",
|
|
69
|
+
cloud: "Workspace · your team's view, across repos:",
|
|
70
|
+
ci: "CI:",
|
|
71
|
+
};
|
|
72
|
+
/** Put a command in a help group, under julius only. */
|
|
73
|
+
function grouped(c, heading) {
|
|
74
|
+
c.helpGroup(heading);
|
|
75
|
+
return c;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* What the `query` telemetry event will say, filled in by the command as it runs
|
|
79
|
+
* and emitted once from the `postAction` hook below.
|
|
80
|
+
*
|
|
81
|
+
* A module-level slot rather than a threaded parameter because the repo root is
|
|
82
|
+
* resolved deep inside each action (`queryRoot`) while the event is emitted
|
|
83
|
+
* centrally — and because a command that calls `process.exit` should simply
|
|
84
|
+
* report nothing, which falls out of never emitting until postAction.
|
|
85
|
+
*/
|
|
86
|
+
let queryNote = {};
|
|
87
|
+
/** Record the repo a query ran against, and pass it straight through so call
|
|
88
|
+
* sites stay one line. */
|
|
89
|
+
function noteQuery(dir) {
|
|
90
|
+
queryNote.repo = dir;
|
|
91
|
+
// Every retrieval command funnels through here, which makes it the one place
|
|
92
|
+
// that can price this session's tokens before a formatter needs the number.
|
|
93
|
+
setInputRate(sessionInputRate(dir));
|
|
94
|
+
return dir;
|
|
95
|
+
}
|
|
96
|
+
/** Whether a query found anything. Only the commands that have a result count in
|
|
97
|
+
* hand call this; the property is simply absent for the others. */
|
|
98
|
+
function noteHit(found) {
|
|
99
|
+
queryNote.hit = found ? "yes" : "no";
|
|
100
|
+
}
|
|
101
|
+
program
|
|
102
|
+
.name(brand())
|
|
103
|
+
.description("Memory for your coding agents: a code map, and the learnings each session\n" +
|
|
104
|
+
"leaves in your repo's .julius/, so your whole team's Claude starts from them.")
|
|
105
|
+
.version(currentVersion, "-v, --version")
|
|
106
|
+
.option("--dir <path>", "context graph directory (default: <repo>/.julius/cache)")
|
|
107
|
+
.option("--provider <name>", "LLM wire format: openai | anthropic | litellm | orcarouter (env JULIUS_PROVIDER)")
|
|
108
|
+
.option("--model <id>", "model id for the LLM pass (env JULIUS_MODEL)")
|
|
109
|
+
.option("--api-key <key>", "provider API key (env JULIUS_API_KEY)")
|
|
110
|
+
.option("--base-url <url>", "OpenAI-compatible endpoint URL (env JULIUS_BASE_URL)");
|
|
111
|
+
/** Config drawn from the global CLI flags (env + defaults fill the rest). */
|
|
112
|
+
function cliConfig() {
|
|
113
|
+
const o = program.opts();
|
|
114
|
+
return {
|
|
115
|
+
contextDir: o.dir,
|
|
116
|
+
provider: o.provider,
|
|
117
|
+
model: o.model,
|
|
118
|
+
apiKey: o.apiKey,
|
|
119
|
+
baseUrl: o.baseUrl,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
const engineFrom = () => new Julius(cliConfig());
|
|
123
|
+
/**
|
|
124
|
+
* Warn (never fail) when a user's `-e` extension has no parser, so it is never a silent
|
|
125
|
+
* no-op — `julius build -e ".vue"` used to accept it, index nothing, and exit 0. The
|
|
126
|
+
* supported set is listed so `-e` also answers "what is actually supported".
|
|
127
|
+
*/
|
|
128
|
+
function warnUnsupportedExtensions(exts) {
|
|
129
|
+
if (!exts?.length)
|
|
130
|
+
return;
|
|
131
|
+
const bad = unsupportedExtensions(exts);
|
|
132
|
+
if (bad.length === 0)
|
|
133
|
+
return;
|
|
134
|
+
for (const e of bad) {
|
|
135
|
+
const shown = e.trim().startsWith(".") ? e.trim() : `.${e.trim()}`;
|
|
136
|
+
console.error(`⚠ -e "${shown}": no parser registered for this extension — ignoring it.`);
|
|
137
|
+
}
|
|
138
|
+
console.error(` supported: ${supportedExtensions().join(" ")}`);
|
|
139
|
+
}
|
|
140
|
+
/** Text for the omitted-`[dir]` case, shared by every query command's help. */
|
|
141
|
+
const DIR_ARG = ["[dir]", "repository root (default: nearest ancestor with a julius/ index)"];
|
|
142
|
+
/**
|
|
143
|
+
* The root a query runs against: the dir the user named, else the nearest
|
|
144
|
+
* ancestor holding a julius index (`graph/root.ts`) so a shell or agent session
|
|
145
|
+
* in a subdirectory still finds the graph. The walk is announced on stderr —
|
|
146
|
+
* answering from an ancestor's graph must never be silent.
|
|
147
|
+
*/
|
|
148
|
+
function queryRoot(dir) {
|
|
149
|
+
if (dir !== undefined)
|
|
150
|
+
return resolve(dir);
|
|
151
|
+
const { root, levels } = nearestJuliusRoot(process.cwd(), program.opts().dir);
|
|
152
|
+
if (levels > 0)
|
|
153
|
+
console.error(`${tag()} no code map here — answering from ${contextDirFor(root, program.opts().dir)}`);
|
|
154
|
+
return root;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Bring the graph up to date with the working tree before a query answers from it
|
|
158
|
+
* — the same gate the MCP tools run (see `graph/refresh.ts`). Cheap when nothing
|
|
159
|
+
* moved; a structural, $0 rebuild when it did. The note goes to stderr so `--json`
|
|
160
|
+
* stdout stays machine-readable.
|
|
161
|
+
*/
|
|
162
|
+
async function refreshBefore(dir, opts) {
|
|
163
|
+
const globalDir = program.opts().dir;
|
|
164
|
+
const root = resolve(dir);
|
|
165
|
+
const disabled = opts.refresh === false;
|
|
166
|
+
const ws = readWorkspace(root, globalDir);
|
|
167
|
+
const r = ws
|
|
168
|
+
? await ensureFreshChildren(root, ws.children, { contextDir: globalDir, disabled })
|
|
169
|
+
: await ensureFreshGraph(root, { contextDir: globalDir, disabled });
|
|
170
|
+
const note = refreshNote(r);
|
|
171
|
+
if (note)
|
|
172
|
+
console.error(note);
|
|
173
|
+
}
|
|
174
|
+
/** Attached to every query command: `--no-refresh` answers from the graph exactly
|
|
175
|
+
* as it is on disk, no rebuild. */
|
|
176
|
+
const NO_REFRESH_FLAG = ["--no-refresh", "skip the freshness check — answer from the graph as-is"];
|
|
177
|
+
const VIZ_TABS = ["context", "code", "outline"];
|
|
178
|
+
/**
|
|
179
|
+
* `--tabs context,code` → the tabs to write into an exported page.
|
|
180
|
+
*
|
|
181
|
+
* An unknown name is a caller mistake worth failing on rather than silently
|
|
182
|
+
* dropping: a page exported with a typo'd tab list would be missing a tab and
|
|
183
|
+
* nothing would say why. Undefined means "all of them", which is the default the
|
|
184
|
+
* exporter already applies.
|
|
185
|
+
*/
|
|
186
|
+
function parseTabs(raw) {
|
|
187
|
+
if (raw === undefined)
|
|
188
|
+
return undefined;
|
|
189
|
+
const want = raw.split(",").map((t) => t.trim()).filter(Boolean);
|
|
190
|
+
const bad = want.filter((t) => !VIZ_TABS.includes(t));
|
|
191
|
+
if (bad.length > 0 || want.length === 0) {
|
|
192
|
+
console.error(`✗ --tabs takes a comma-separated subset of ${VIZ_TABS.join(", ")}${bad.length ? ` — got "${bad.join('", "')}"` : ""}`);
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
return want;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Commands that own the upgrade story themselves (`version`, `upgrade`) or must
|
|
199
|
+
* not editorialize on stderr at startup (`mcp` runs its own upkeep at boot, and
|
|
200
|
+
* `_update-check` IS the fetch).
|
|
201
|
+
*/
|
|
202
|
+
const UPKEEP_SKIP = new Set(["version", "upgrade", "_update-check", "_julius-past-read", "mcp"]);
|
|
203
|
+
/**
|
|
204
|
+
* Every other command: top up the cached registry answer in the background and,
|
|
205
|
+
* if a newer julius is out, say so once on stderr. This is what makes the CLI the
|
|
206
|
+
* cache filler for the hooks, which are not allowed to touch the network.
|
|
207
|
+
*/
|
|
208
|
+
program.hook("preAction", (_parent, action) => {
|
|
209
|
+
if (["capture", "read", "run", "stats", "clear"].includes(action.name()) || UPKEEP_SKIP.has(action.name()))
|
|
210
|
+
return;
|
|
211
|
+
maybeRefreshInBackground();
|
|
212
|
+
const nudge = formatUpdateNudge(currentVersion, readUpdateCache()?.latest);
|
|
213
|
+
if (nudge)
|
|
214
|
+
console.error(nudge);
|
|
215
|
+
// Telemetry, in the order a user should experience it: disclose first, then
|
|
216
|
+
// record, then (at most once a day, detached) send. Every step is a no-op in a
|
|
217
|
+
// fork, in CI, under DO_NOT_TRACK, or after `julius telemetry disable`.
|
|
218
|
+
const notice = firstRunNotice();
|
|
219
|
+
if (notice)
|
|
220
|
+
console.error(notice);
|
|
221
|
+
trackFirstRunIfNew();
|
|
222
|
+
maybeFlushInBackground();
|
|
223
|
+
});
|
|
224
|
+
/**
|
|
225
|
+
* The `query` event, emitted after the command rather than before it, so it can
|
|
226
|
+
* carry what the query actually did. A command that exits early via
|
|
227
|
+
* `process.exit` never reaches here and is simply not counted — under-reporting
|
|
228
|
+
* is the right failure mode for a metric.
|
|
229
|
+
*/
|
|
230
|
+
program.hook("postAction", (_parent, action) => {
|
|
231
|
+
// `julius build --check` is julius's `check`, and counts as it always has.
|
|
232
|
+
const name = queryNote.command ?? action.name();
|
|
233
|
+
if (!isTrackedCommand(name))
|
|
234
|
+
return;
|
|
235
|
+
track("query", { command: name, surface: "cli", hit: queryNote.hit, notes: queryNote.notes }, { repo: queryNote.repo });
|
|
236
|
+
});
|
|
237
|
+
/** `julius ask`, `julius build`: a command as julius spells it, whatever ran it. */
|
|
238
|
+
function spelling(action) {
|
|
239
|
+
const words = [];
|
|
240
|
+
for (let c = action; c && c.parent; c = c.parent)
|
|
241
|
+
words.unshift(c.name());
|
|
242
|
+
return ["julius", ...words].join(" ");
|
|
243
|
+
}
|
|
244
|
+
// Hidden: spawned detached by maybeSyncInBackground when a workspace repo's
|
|
245
|
+
// learnings changed, or uses are waiting to go. Running it by hand syncs now.
|
|
246
|
+
// A repo that moved from julius to julius at session start reads its past
|
|
247
|
+
// sessions and PR reviews here, detached, so the session doesn't wait on it.
|
|
248
|
+
program
|
|
249
|
+
.command("_julius-past-read", { hidden: true })
|
|
250
|
+
.argument("<dir>")
|
|
251
|
+
.action(async (dir) => {
|
|
252
|
+
const repo = resolve(dir);
|
|
253
|
+
const read = beginPastRead(repo);
|
|
254
|
+
const reviews = beginReviewRead(repo);
|
|
255
|
+
if (read)
|
|
256
|
+
await finishPastRead(repo, read);
|
|
257
|
+
if (reviews)
|
|
258
|
+
await finishReviewRead(repo, reviews);
|
|
259
|
+
});
|
|
260
|
+
program
|
|
261
|
+
.command("_julius-sync", { hidden: true })
|
|
262
|
+
.description("internal: send this repo's learnings and the waiting uses to the Julius workspace")
|
|
263
|
+
.argument("[dir]", "target repo directory", ".")
|
|
264
|
+
.action(async (dir) => {
|
|
265
|
+
await runSyncChild(resolve(dir));
|
|
266
|
+
});
|
|
267
|
+
// Hidden: spawned detached by maybeRefreshBranches.
|
|
268
|
+
program
|
|
269
|
+
.command("_julius-branches", { hidden: true })
|
|
270
|
+
.description("internal: fetch, then note which files teammates' open branches change and the learnings they carry")
|
|
271
|
+
.argument("[dir]", "target repo directory", ".")
|
|
272
|
+
.action((dir) => {
|
|
273
|
+
refreshBranches(resolve(dir), { prs: true });
|
|
274
|
+
});
|
|
275
|
+
program
|
|
276
|
+
.command("_julius-claim", { hidden: true })
|
|
277
|
+
.description("internal: wait for a sign-in through the link julius handed the agent, then connect the workspace")
|
|
278
|
+
.action(async () => {
|
|
279
|
+
await waitForConnect();
|
|
280
|
+
});
|
|
281
|
+
program
|
|
282
|
+
.command("_update-check", { hidden: true })
|
|
283
|
+
.description("internal: refresh the cached latest-version answer")
|
|
284
|
+
.action(() => {
|
|
285
|
+
refreshUpdateCache();
|
|
286
|
+
});
|
|
287
|
+
// Hidden for the same reason as _update-check: only ever spawned detached, by
|
|
288
|
+
// maybeFlushInBackground. Running it by hand is harmless — it drains the queue.
|
|
289
|
+
program
|
|
290
|
+
.command("_telemetry-flush", { hidden: true })
|
|
291
|
+
.description("internal: POST the queued anonymous usage events")
|
|
292
|
+
.action(async () => {
|
|
293
|
+
await runFlush();
|
|
294
|
+
});
|
|
295
|
+
grouped(program.command("telemetry"), GROUP.setup)
|
|
296
|
+
.description("Show, inspect, or turn off the anonymous usage stats (see TELEMETRY.md)")
|
|
297
|
+
.argument("[action]", "status (default) | enable | disable | debug", "status")
|
|
298
|
+
.action((action) => {
|
|
299
|
+
switch (action) {
|
|
300
|
+
case "status":
|
|
301
|
+
console.log(formatStatus());
|
|
302
|
+
return;
|
|
303
|
+
case "enable":
|
|
304
|
+
patchState({ enabled: true });
|
|
305
|
+
console.log(`telemetry: on — anonymous, aggregate-only. \`${cmd("julius telemetry status")}\` for details.`);
|
|
306
|
+
return;
|
|
307
|
+
case "disable":
|
|
308
|
+
// Also stamp the notice as shown: someone who has just opted out should
|
|
309
|
+
// not be told about telemetry again the next time they run a command.
|
|
310
|
+
patchState({ enabled: false, noticeShownAt: new Date().toISOString() });
|
|
311
|
+
console.log("telemetry: off. Nothing further will be recorded or sent.");
|
|
312
|
+
return;
|
|
313
|
+
case "debug":
|
|
314
|
+
console.log(formatDebug());
|
|
315
|
+
return;
|
|
316
|
+
default:
|
|
317
|
+
console.error(`✗ unknown action "${action}" — expected status, enable, disable, or debug`);
|
|
318
|
+
process.exit(1);
|
|
319
|
+
}
|
|
320
|
+
});
|
|
321
|
+
// Hidden under julius, where -v says the same; listed under julius as it was.
|
|
322
|
+
program
|
|
323
|
+
.command("version", { hidden: true })
|
|
324
|
+
.description("Print the installed version and the latest published on npm")
|
|
325
|
+
.action(() => {
|
|
326
|
+
const latest = getNpmViewVersion();
|
|
327
|
+
console.log(formatVersionReport(currentVersion, latest));
|
|
328
|
+
});
|
|
329
|
+
grouped(program.command("upgrade"), GROUP.setup)
|
|
330
|
+
.description(`Upgrade the globally installed ${brand()} to the latest version on npm`)
|
|
331
|
+
.action(() => {
|
|
332
|
+
const result = runUpgrade(import.meta.url);
|
|
333
|
+
console.log(formatUpgradeReport(result));
|
|
334
|
+
if (result.ran && !result.ok)
|
|
335
|
+
process.exit(1);
|
|
336
|
+
});
|
|
337
|
+
grouped(program.command("build"), GROUP.setup)
|
|
338
|
+
.description("Rebuild the code map in .julius/cache/ ($0, no key). --check fails if it's stale; --deep adds LLM summaries.")
|
|
339
|
+
.argument("[dir]", "repository root", ".")
|
|
340
|
+
.option("--check", "build nothing: fail if julius/ is stale relative to the code (for CI)")
|
|
341
|
+
.option("--json", "with --check: output the drift as JSON")
|
|
342
|
+
.option("--deep", "run the LLM pass: concept nodes (julius/*.md) + per-symbol summary/crux")
|
|
343
|
+
.option("-e, --extensions <exts...>", 'code extensions to include (e.g. ".ts" ".py"); an extension with no parser is ignored with a warning that lists the supported set')
|
|
344
|
+
.option("-j, --concurrency <n>", "files summarized in parallel during --deep (default 5)")
|
|
345
|
+
.option("--no-reuse", "re-parse every file instead of replaying unchanged ones from the extraction cache")
|
|
346
|
+
.option("--lsp", "add compiler-grade call edges via a language server if one is installed (opt-in, slower; e.g. rust-analyzer, clangd)")
|
|
347
|
+
.option("--allow-partial", "with --deep: exit 0 even when some files' summaries failed (default: a degraded meaning tier exits 1)")
|
|
348
|
+
.option("--follow-submodules", "include initialized Git submodules recursively; persisted for later builds and automatic refreshes")
|
|
349
|
+
.option("--no-follow-submodules", "exclude Git submodules; persisted for later builds and automatic refreshes (default)")
|
|
350
|
+
.option("--follow-nested-repos", "include nested Git clones the index does not track (a multi-repo manifest checkout, or any repo cloned into the tree) " +
|
|
351
|
+
"as ONE graph, so imports across them resolve; persisted for later builds and automatic refreshes")
|
|
352
|
+
.option("--no-follow-nested-repos", "exclude untracked nested Git clones; persisted for later builds and automatic refreshes (default)")
|
|
353
|
+
.option("--include-dir <name>", "override SKIP_DIRS for this repo's walks — repeatable (e.g. --include-dir build --include-dir tools); " +
|
|
354
|
+
"persisted, so a later build (and the hooks/refresh path) include it without the flag; dot-dirs are never overridable", (val, prev) => [...prev, val], [])
|
|
355
|
+
.option("--only-dir <path>", "only index files under this repo-relative path — repeatable; the wiring walk and the --deep " +
|
|
356
|
+
"concept pass both honor it. Recorded in the graph fingerprint so a later build " +
|
|
357
|
+
"(and the hooks/refresh path) walks the same set; everything outside the list is skipped", (val, prev) => [...prev, val], [])
|
|
358
|
+
.option("--no-gitignore", "skip writing julius/ into .gitignore (same as JULIUS_NO_GITIGNORE=1)")
|
|
359
|
+
.option("--no-ignore", "skip writing .ignore for ripgrep re-admit (same as JULIUS_NO_IGNORE=1)")
|
|
360
|
+
.action(async (dir, opts, command) => {
|
|
361
|
+
if (opts.check) {
|
|
362
|
+
// The freshness check, which was `julius check`. Counted as `check` so the
|
|
363
|
+
// metric carries on across the rename; the dir defaults like a query's.
|
|
364
|
+
queryNote.command = "check";
|
|
365
|
+
await runCheckCommand(command.args[0], { extensions: opts.extensions, json: opts.json }, cmd("julius build --check"));
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const buildStartedAt = Date.now();
|
|
369
|
+
if (opts.gitignore === false)
|
|
370
|
+
process.env.JULIUS_NO_GITIGNORE = "1";
|
|
371
|
+
if (opts.ignore === false)
|
|
372
|
+
process.env.JULIUS_NO_IGNORE = "1";
|
|
373
|
+
const concurrency = opts.concurrency ? Math.max(1, Number(opts.concurrency)) : undefined;
|
|
374
|
+
if (opts.concurrency && !Number.isFinite(concurrency)) {
|
|
375
|
+
console.error(`✗ --concurrency must be a number, got "${opts.concurrency}"`);
|
|
376
|
+
process.exit(1);
|
|
377
|
+
}
|
|
378
|
+
warnUnsupportedExtensions(opts.extensions);
|
|
379
|
+
// Persisted BEFORE the build itself runs, so this invocation's walks (and
|
|
380
|
+
// every later no-flag build / hooks refresh) see it identically — the
|
|
381
|
+
// walkDir call sites read it from state, not from a threaded option.
|
|
382
|
+
const buildConfigPatch = {};
|
|
383
|
+
if (opts.includeDir && opts.includeDir.length > 0) {
|
|
384
|
+
// --include-dir takes bare SKIP_DIRS-style directory NAMES (shouldSkipDir
|
|
385
|
+
// compares a single path segment), never paths, and dot-dirs are never
|
|
386
|
+
// overridable at all (see the option's own help text) — reject anything
|
|
387
|
+
// else up front instead of silently persisting a value that can never
|
|
388
|
+
// match a real directory name.
|
|
389
|
+
for (const name of opts.includeDir) {
|
|
390
|
+
if (name.startsWith(".")) {
|
|
391
|
+
console.error(`✗ --include-dir "${name}": dot-directories are never overridable`);
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
if (name.includes("/") || name.includes("\\")) {
|
|
395
|
+
console.error(`✗ --include-dir "${name}": expected a bare directory name, not a path`);
|
|
396
|
+
process.exit(1);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
buildConfigPatch.includeDirs = opts.includeDir;
|
|
400
|
+
}
|
|
401
|
+
// The whitelist is NOT persisted to `.julius/config.json`: it belongs with the
|
|
402
|
+
// graph (the fingerprint records it at build time), never in the source repo,
|
|
403
|
+
// so a `--only-dir` build leaves no trace under the repo being indexed.
|
|
404
|
+
let onlyDirs;
|
|
405
|
+
if (opts.onlyDir && opts.onlyDir.length > 0) {
|
|
406
|
+
// --only-dir takes a repo-relative path prefix, normalized to the same
|
|
407
|
+
// posix, no-`./`, no-trailing-slash form `--in` uses, so the prefix match
|
|
408
|
+
// is exact. A prefix that normalizes to "" (a bare "/" or ".") is rejected:
|
|
409
|
+
// it would mean "match nothing" or "match everything", neither of which is
|
|
410
|
+
// a deliberate whitelist.
|
|
411
|
+
const normalized = opts.onlyDir.map((p) => normalizePathPrefix(p)).filter((p) => p !== "");
|
|
412
|
+
if (normalized.length === 0) {
|
|
413
|
+
console.error("✗ --only-dir: expected a non-empty repo-relative path");
|
|
414
|
+
process.exit(1);
|
|
415
|
+
}
|
|
416
|
+
onlyDirs = normalized;
|
|
417
|
+
}
|
|
418
|
+
const followSubmodulesWasExplicit = command.getOptionValueSource("followSubmodules") === "cli";
|
|
419
|
+
if (followSubmodulesWasExplicit && typeof opts.followSubmodules === "boolean") {
|
|
420
|
+
buildConfigPatch.followSubmodules = opts.followSubmodules;
|
|
421
|
+
}
|
|
422
|
+
const followNestedReposWasExplicit = command.getOptionValueSource("followNestedRepos") === "cli";
|
|
423
|
+
if (followNestedReposWasExplicit && typeof opts.followNestedRepos === "boolean") {
|
|
424
|
+
buildConfigPatch.followNestedRepos = opts.followNestedRepos;
|
|
425
|
+
}
|
|
426
|
+
if (Object.keys(buildConfigPatch).length > 0) {
|
|
427
|
+
patchBuildConfig(resolve(dir), buildConfigPatch);
|
|
428
|
+
}
|
|
429
|
+
const engine = engineFrom();
|
|
430
|
+
const fmt = (o) => Object.entries(o)
|
|
431
|
+
.sort((a, b) => b[1] - a[1])
|
|
432
|
+
.map(([k, n]) => `${n} ${k}`)
|
|
433
|
+
.join(", ");
|
|
434
|
+
// --deep needs a key; without one, degrade to the $0 structural build.
|
|
435
|
+
let deep = opts.deep;
|
|
436
|
+
const resolved = resolveConfig(cliConfig());
|
|
437
|
+
if (deep && !resolved.apiKey) {
|
|
438
|
+
deep = false;
|
|
439
|
+
console.error("⚠ no API key set — falling back to the structural build (no LLM summaries).\n" +
|
|
440
|
+
" Set JULIUS_API_KEY (and JULIUS_PROVIDER / JULIUS_BASE_URL / JULIUS_MODEL for your\n" +
|
|
441
|
+
` provider) and re-run \`${cmd("julius build --deep")}\` to add concept nodes and summaries.`);
|
|
442
|
+
}
|
|
443
|
+
if (deep && resolved.usedLegacyEnv) {
|
|
444
|
+
console.error("⚠ using OPENROUTER_API_KEY (deprecated) — prefer JULIUS_API_KEY + JULIUS_BASE_URL.");
|
|
445
|
+
}
|
|
446
|
+
// Workspace parent: build each child into its OWN julius/ + a workspace index.
|
|
447
|
+
const buildRoot = resolve(dir);
|
|
448
|
+
const buildGlobalDir = program.opts().dir;
|
|
449
|
+
if (isWorkspaceBuildRoot(buildRoot, buildGlobalDir)) {
|
|
450
|
+
await runWorkspaceBuild(buildRoot, {
|
|
451
|
+
deep: !!deep,
|
|
452
|
+
extensions: opts.extensions,
|
|
453
|
+
concurrency,
|
|
454
|
+
childConfig: cliConfig(),
|
|
455
|
+
override: buildGlobalDir,
|
|
456
|
+
includeDirs: opts.includeDir,
|
|
457
|
+
followSubmodules: followSubmodulesWasExplicit ? opts.followSubmodules : undefined,
|
|
458
|
+
followNestedRepos: followNestedReposWasExplicit ? opts.followNestedRepos : undefined,
|
|
459
|
+
packageName: readPackageName(import.meta.url),
|
|
460
|
+
});
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
// --deep: concept nodes first, then the wiring graph links cards up to them.
|
|
464
|
+
let conceptErrors = [];
|
|
465
|
+
let conceptFatal;
|
|
466
|
+
if (deep) {
|
|
467
|
+
const c = await engine.init(dir, {
|
|
468
|
+
extensions: opts.extensions,
|
|
469
|
+
onlyDirs,
|
|
470
|
+
onProgress: ({ phase, index, total, file }) => process.stderr.write(`\r${phase === "summarize" ? "reading" : "writing"} concepts ${index + 1}/${total}: ${file.slice(0, 40).padEnd(40)}`),
|
|
471
|
+
}).catch((err) => {
|
|
472
|
+
// Only the stage and a code enum; the message stays on this machine.
|
|
473
|
+
track("build_failed", { stage: "summarize", code: errorCode(err) }, { repo: buildRoot });
|
|
474
|
+
throw err;
|
|
475
|
+
});
|
|
476
|
+
process.stderr.write("\n");
|
|
477
|
+
console.log(`✓ concepts: ${c.nodes} nodes, ${c.links} links from ${c.files} files (${c.summarized} read, ${c.cached} cached)`);
|
|
478
|
+
for (const e of c.errors)
|
|
479
|
+
console.error(`✗ ${e}`);
|
|
480
|
+
conceptErrors = c.errors;
|
|
481
|
+
conceptFatal = c.fatal;
|
|
482
|
+
}
|
|
483
|
+
// Wiring graph — always; LLM meaning only with --deep.
|
|
484
|
+
const g = await engine.graph(dir, {
|
|
485
|
+
llm: deep,
|
|
486
|
+
concurrency,
|
|
487
|
+
reuse: opts.reuse,
|
|
488
|
+
lsp: opts.lsp,
|
|
489
|
+
onlyDirs,
|
|
490
|
+
onProgress: ({ phase, index, total, file }) => process.stderr.write(`\r${phase === "enrich" ? "summarizing" : "parsing"} ${index + 1}/${total}: ${file.slice(0, 50).padEnd(50)}`),
|
|
491
|
+
}).catch((err) => {
|
|
492
|
+
track("build_failed", { stage: "graph", code: errorCode(err) }, { repo: buildRoot });
|
|
493
|
+
throw err;
|
|
494
|
+
});
|
|
495
|
+
process.stderr.write("\n");
|
|
496
|
+
console.log(`✓ wiring: ${g.nodes} nodes (${fmt(g.byKind)}), ${g.edges} edges, ${g.cards} cards [${g.languages.join(", ")}]`);
|
|
497
|
+
console.log(` parsed: ${g.parsed} of ${g.files} files (${g.reused} replayed from cache)`);
|
|
498
|
+
// Worth one line: this build started from a graph the user never built *here*.
|
|
499
|
+
if (g.seededFrom)
|
|
500
|
+
console.log(` seeded: copied a starting graph from ${g.seededFrom} (git worktree)`);
|
|
501
|
+
if (deep) {
|
|
502
|
+
const m = g.meaning;
|
|
503
|
+
console.log(` meaning: ${m.computed} computed, ${m.cached} cached, ${m.stale} stale, ${m.pending} pending`);
|
|
504
|
+
}
|
|
505
|
+
console.log(` → ${g.contextDir}`);
|
|
506
|
+
// The activation event. Everything here is a bucket or a fixed label: repo
|
|
507
|
+
// scale rather than a file count, a language set rather than file names.
|
|
508
|
+
track("build_completed", {
|
|
509
|
+
files_bucket: filesBucket(g.files),
|
|
510
|
+
langs: langsValue(g.languages),
|
|
511
|
+
mode: deep ? "deep" : "fast",
|
|
512
|
+
duration_bucket: durationBucket(Date.now() - buildStartedAt),
|
|
513
|
+
incremental: String(g.reused > 0),
|
|
514
|
+
}, { repo: buildRoot });
|
|
515
|
+
for (const e of g.errors)
|
|
516
|
+
console.error(`✗ ${e}`);
|
|
517
|
+
// A language whose native grammar didn't load was parsed by its WASM stand-in:
|
|
518
|
+
// say which, and the install that fixes it. Nothing when everything loaded.
|
|
519
|
+
const fallbackNotice = nativeFallbackNotice(g.nativeFallback, readPackageName(import.meta.url));
|
|
520
|
+
if (fallbackNotice)
|
|
521
|
+
console.error(fallbackNotice);
|
|
522
|
+
const rel = relative(process.cwd(), g.contextDir) || "julius";
|
|
523
|
+
if (process.env.JULIUS_NO_GITIGNORE) {
|
|
524
|
+
console.log(` ${rel}/ is a local cache — add it to your gitignore if you want it untracked.`);
|
|
525
|
+
}
|
|
526
|
+
else {
|
|
527
|
+
console.log(` ${rel}/ is git-ignored (added automatically) — a local cache; teammates run \`${cmd("julius build")}\` to get their own.`);
|
|
528
|
+
}
|
|
529
|
+
// #127: a --deep run whose LLM calls failed used to print the same success
|
|
530
|
+
// footer and exit 0, so a quota-exhausted build looked identical to a clean
|
|
531
|
+
// one and `julius check` still said "in sync" (it only ever checked Tier-1).
|
|
532
|
+
// The structural graph IS still written and every successful summary is
|
|
533
|
+
// cached, so this is a loud warning about a degraded tier, not a rollback.
|
|
534
|
+
if (deep) {
|
|
535
|
+
const m = g.meaning;
|
|
536
|
+
const failed = m.failedFiles > 0 || m.fatal !== undefined || conceptErrors.length > 0 || conceptFatal !== undefined;
|
|
537
|
+
if (failed) {
|
|
538
|
+
const ready = m.computed + m.cached;
|
|
539
|
+
const total = ready + m.stale + m.pending;
|
|
540
|
+
const pct = total > 0 ? Math.round((ready / total) * 100) : 0;
|
|
541
|
+
console.error("");
|
|
542
|
+
console.error(`✗ the deep pass did not complete — the meaning tier is incomplete.`);
|
|
543
|
+
if (conceptFatal)
|
|
544
|
+
console.error(` concepts: ${conceptFatal}`);
|
|
545
|
+
if (m.fatal)
|
|
546
|
+
console.error(` summaries: ${m.fatal}`);
|
|
547
|
+
if (m.failedFiles > 0) {
|
|
548
|
+
const skipped = m.skippedFiles > 0 ? `, ${m.skippedFiles} never attempted` : "";
|
|
549
|
+
console.error(` ${m.failedFiles} file(s) failed to summarize${skipped}.`);
|
|
550
|
+
}
|
|
551
|
+
if (conceptErrors.length > 0)
|
|
552
|
+
console.error(` ${conceptErrors.length} concept-pass error(s).`);
|
|
553
|
+
console.error(` meaning coverage: ${ready}/${total} symbols (${pct}%).`);
|
|
554
|
+
console.error(` Nothing computed was lost: re-run \`${cmd("julius build --deep")}\` to resume from what is cached.\n` +
|
|
555
|
+
" Pass --allow-partial to accept a degraded meaning tier and exit 0.");
|
|
556
|
+
if (!opts.allowPartial)
|
|
557
|
+
process.exitCode = 1;
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
/** The file part of a hit's `file:Lx-Ly` pointer. */
|
|
562
|
+
function pointerFile(pointer) {
|
|
563
|
+
return pointer.replace(/:L\d+(-L?\d+)?$/, "");
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* After `ask`, under julius: which shown learnings are a teammate's, and the
|
|
567
|
+
* shown learnings recorded as a use, which is what the team page counts as
|
|
568
|
+
* reuse. Then the background upkeep that keeps branches and the workspace
|
|
569
|
+
* current. Spawns no git itself. Teammates' branches come up after an edit
|
|
570
|
+
* instead, once there's a function to compare (notes/edit-overlap.ts).
|
|
571
|
+
*/
|
|
572
|
+
function afterAsk(r, repo) {
|
|
573
|
+
if (!r.notesChecked)
|
|
574
|
+
return;
|
|
575
|
+
rememberRepo(repo);
|
|
576
|
+
maybeRefreshBranches(repo);
|
|
577
|
+
const me = noteAuthor(repo);
|
|
578
|
+
const files = [...new Set(r.hits.map((h) => pointerFile(h.pointer)))];
|
|
579
|
+
const shown = r.notes ?? [];
|
|
580
|
+
if (shown.length) {
|
|
581
|
+
for (const h of shown)
|
|
582
|
+
h.note.teammate = !!h.note.author && !!me && h.note.author !== me;
|
|
583
|
+
recordActivity({
|
|
584
|
+
repo: repoPlace(repo).key,
|
|
585
|
+
kind: "search",
|
|
586
|
+
asker: me,
|
|
587
|
+
session: sessionKey(repo) ?? `${me}-${new Date().toISOString().slice(0, 10)}`,
|
|
588
|
+
query: r.query,
|
|
589
|
+
files,
|
|
590
|
+
shown_paths: shown.map((h) => noteName(h.note)),
|
|
591
|
+
shown_authors: shown.map((h) => h.note.author),
|
|
592
|
+
at: new Date().toISOString(),
|
|
593
|
+
});
|
|
594
|
+
const saved = shown.reduce((sum, h) => sum + savedByNote(h.note), 0);
|
|
595
|
+
track("learning_reused", { teammate: String(shown.some((h) => h.note.teammate)), saved_tokens_bucket: savedTokensBucket(saved) }, { repo });
|
|
596
|
+
}
|
|
597
|
+
maybeSyncInBackground(repo);
|
|
598
|
+
}
|
|
599
|
+
grouped(program.command("ask"), GROUP.find)
|
|
600
|
+
.description("Query the julius/ graph — returns ranked nodes + exact file:line, routed to prose or wiring ($0, no key)")
|
|
601
|
+
.argument("<query>", "what you want to understand, in plain words")
|
|
602
|
+
.argument(...DIR_ARG)
|
|
603
|
+
.option("-n, --limit <n>", "max results", "8")
|
|
604
|
+
.option("--source", "inline the source at each file:line hit (retriever mode — the pack IS the answer, no need to re-open files)")
|
|
605
|
+
.option("--full", "with --source: inline whole definition spans instead of the default ≤8-line crux excerpts")
|
|
606
|
+
.option("--in <path>", "narrow to nodes under this path prefix, filtered before scoring (segment-aware, like scopeOf)")
|
|
607
|
+
.option("--json", "output the result as JSON")
|
|
608
|
+
.option("--no-graph-rank", "rank by lexical relevance only, without the graph-connectivity re-rank (ablation/eval)")
|
|
609
|
+
.option(...NO_REFRESH_FLAG)
|
|
610
|
+
.action(async (query, dirArg, opts) => {
|
|
611
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
612
|
+
await refreshBefore(dir, opts);
|
|
613
|
+
const askGlobalDir = program.opts().dir;
|
|
614
|
+
if (readWorkspace(dir, askGlobalDir)) {
|
|
615
|
+
runWorkspaceAsk(dir, askGlobalDir, query, {
|
|
616
|
+
limit: Number(opts.limit), source: opts.source, full: opts.full, in: opts.in, json: opts.json,
|
|
617
|
+
});
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const engine = engineFrom();
|
|
621
|
+
let r;
|
|
622
|
+
try {
|
|
623
|
+
r = engine.ask(dir, query, { limit: Number(opts.limit), source: opts.source, full: opts.full, in: opts.in, graphRank: opts.graphRank });
|
|
624
|
+
}
|
|
625
|
+
catch (err) {
|
|
626
|
+
console.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
|
|
627
|
+
process.exit(1);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
noteHit(r.hits.length > 0);
|
|
631
|
+
// Teammates' branches on the same files, and the learnings shown, counted as a use.
|
|
632
|
+
afterAsk(r, dir);
|
|
633
|
+
// How many notes reached the agent: the demand side of `julius note`.
|
|
634
|
+
if (r.notesChecked)
|
|
635
|
+
queryNote.notes = String(Math.min(r.notes?.length ?? 0, 2));
|
|
636
|
+
if (opts.json) {
|
|
637
|
+
console.log(JSON.stringify(r, null, 2));
|
|
638
|
+
}
|
|
639
|
+
else {
|
|
640
|
+
const { formatAsk } = await import("./ask/ask.js");
|
|
641
|
+
process.stdout.write(formatAsk(r));
|
|
642
|
+
printLines(cloudLines(dir, { command: "ask" }));
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
grouped(program.command("skeleton"), GROUP.find)
|
|
646
|
+
.description("Signatures-only view of one file from the wiring graph — the cheapest way to see a file's API surface")
|
|
647
|
+
.argument("<file>", "repo-relative path (or unique basename) of the file")
|
|
648
|
+
.argument(...DIR_ARG)
|
|
649
|
+
.option("--json", "output the result as JSON")
|
|
650
|
+
.option(...NO_REFRESH_FLAG)
|
|
651
|
+
.action(async (file, dirArg, opts) => {
|
|
652
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
653
|
+
await refreshBefore(dir, opts);
|
|
654
|
+
const { skeleton, formatSkeleton } = await import("./ask/ask.js");
|
|
655
|
+
const globalOpts = program.opts();
|
|
656
|
+
const r = skeleton(dir, file, { contextDir: globalOpts.dir });
|
|
657
|
+
if (opts.json)
|
|
658
|
+
console.log(JSON.stringify(r, null, 2));
|
|
659
|
+
else
|
|
660
|
+
process.stdout.write(formatSkeleton(r));
|
|
661
|
+
});
|
|
662
|
+
;
|
|
663
|
+
// Under julius, `check` is the team check (teamCheckCommand, with the cloud
|
|
664
|
+
// commands below); the freshness check is `julius build --check`.
|
|
665
|
+
/**
|
|
666
|
+
* The freshness check: `julius check`, and `julius build --check`. `label` is how
|
|
667
|
+
* the report names the command, so each name prints its own spelling.
|
|
668
|
+
*/
|
|
669
|
+
async function runCheckCommand(dirArg, opts, label) {
|
|
670
|
+
warnUnsupportedExtensions(opts.extensions);
|
|
671
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
672
|
+
const checkGlobalDir = program.opts().dir;
|
|
673
|
+
if (readWorkspace(dir, checkGlobalDir)) {
|
|
674
|
+
await runWorkspaceCheck(dir, checkGlobalDir);
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
const engine = engineFrom();
|
|
678
|
+
const r = engine.check(dir, { extensions: opts.extensions });
|
|
679
|
+
const g = await engine.checkGraph(dir); // graph.json is only judged when it exists
|
|
680
|
+
// A layer that IS present must be in sync; a never-built layer (keyless
|
|
681
|
+
// build skips the markdown layer) is informational, not a failure.
|
|
682
|
+
const bothMissing = r.missing && g.missing;
|
|
683
|
+
const markdownFail = !r.missing && !r.ok;
|
|
684
|
+
const wiringFail = !g.missing && !g.ok;
|
|
685
|
+
if (opts.json) {
|
|
686
|
+
console.log(JSON.stringify({ context: r, graph: g.missing ? null : g }, null, 2));
|
|
687
|
+
}
|
|
688
|
+
else if (bothMissing) {
|
|
689
|
+
console.log(`${label}: NO GRAPH\n\nNo code map found. Run \`${cmd("julius build")}\` first.`);
|
|
690
|
+
}
|
|
691
|
+
else {
|
|
692
|
+
if (r.missing) {
|
|
693
|
+
console.log(`deep layer: not built (run \`${cmd("julius build --deep")}\` for concept nodes) — wiring graph is the source of truth`);
|
|
694
|
+
}
|
|
695
|
+
else {
|
|
696
|
+
console.log(formatCheckReport(r, label));
|
|
697
|
+
}
|
|
698
|
+
if (!g.missing)
|
|
699
|
+
console.log("\n" + formatGraphCheckReport(g));
|
|
700
|
+
}
|
|
701
|
+
if (bothMissing || markdownFail || wiringFail)
|
|
702
|
+
process.exit(1);
|
|
703
|
+
}
|
|
704
|
+
// Under julius this is part of `status`; the old name still runs, unlisted.
|
|
705
|
+
program
|
|
706
|
+
.command("stats", { hidden: true })
|
|
707
|
+
.description(`Show this agent session's ${brand()}-vs-source usage mix and tokens saved`)
|
|
708
|
+
.argument(...DIR_ARG)
|
|
709
|
+
.option("--json", "output the session stats as JSON")
|
|
710
|
+
.action((dirArg, opts) => {
|
|
711
|
+
// Reads local session JSON only — no graph, no network. This is how a Cursor
|
|
712
|
+
// user (no statusline) sees the numbers the Claude Code bar would show, and it
|
|
713
|
+
// works under DO_NOT_TRACK because it never touches telemetry.
|
|
714
|
+
const dir = queryRoot(dirArg);
|
|
715
|
+
const s = latestSession(dir);
|
|
716
|
+
if (opts.json) {
|
|
717
|
+
console.log(JSON.stringify(s, null, 2));
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
console.log(formatSessionStats(s));
|
|
721
|
+
});
|
|
722
|
+
program
|
|
723
|
+
.command("viz", { hidden: true })
|
|
724
|
+
.description("Serve an interactive visualization of the context graph (and graph.json when present)")
|
|
725
|
+
.argument(...DIR_ARG)
|
|
726
|
+
.option("-p, --port <port>", "port to serve on", "4400")
|
|
727
|
+
.option("--no-open", "don't open the browser")
|
|
728
|
+
.option("--export <dir>", "write one self-contained index.html instead of serving (for CI, GitHub Pages, or a build artifact)")
|
|
729
|
+
.option("--title <text>", "subtitle shown beside the repo name in an exported page (e.g. \"PR #151\")")
|
|
730
|
+
.option("--tabs <list>", "tabs the exported page offers, comma separated: context,code,outline (default: all three)")
|
|
731
|
+
.action(async (dirArg, opts) => {
|
|
732
|
+
// Flags are checked before the repository is: a typo'd `--tabs` is a mistake
|
|
733
|
+
// in the command the caller just typed, and telling them to go build an index
|
|
734
|
+
// first sends them off to fix the wrong thing.
|
|
735
|
+
const tabs = parseTabs(opts.tabs);
|
|
736
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
737
|
+
const { existsSync } = await import("node:fs");
|
|
738
|
+
const { resolve, basename } = await import("node:path");
|
|
739
|
+
const { spawn } = await import("node:child_process");
|
|
740
|
+
const { fileURLToPath } = await import("node:url");
|
|
741
|
+
const { contextDirFor } = await import("./context/node-file.js");
|
|
742
|
+
const { startVizServer } = await import("./viz/serve.js");
|
|
743
|
+
const root = resolve(dir);
|
|
744
|
+
const globalOpts = program.opts();
|
|
745
|
+
const contextDir = contextDirFor(root, globalOpts.dir);
|
|
746
|
+
if (!existsSync(contextDir)) {
|
|
747
|
+
console.error(`✗ no context graph at ${contextDir} — run \`${cmd("julius build --deep")}\` first`);
|
|
748
|
+
process.exit(1);
|
|
749
|
+
}
|
|
750
|
+
const viewerDir = fileURLToPath(new URL("./viewer/", import.meta.url)); // prebuilt
|
|
751
|
+
if (opts.export) {
|
|
752
|
+
const { exportViz } = await import("./viz/export.js");
|
|
753
|
+
const out = exportViz({
|
|
754
|
+
contextDir,
|
|
755
|
+
viewerDir,
|
|
756
|
+
outDir: resolve(opts.export),
|
|
757
|
+
repoName: basename(root),
|
|
758
|
+
subtitle: opts.title,
|
|
759
|
+
tabs,
|
|
760
|
+
});
|
|
761
|
+
const kb = Math.round(out.bytes / 1024);
|
|
762
|
+
console.log(`${cmd("julius viz")} → ${out.file} (${kb} kB, ${out.contextNodes} concept nodes, ${out.codeNodes} code nodes)`);
|
|
763
|
+
return;
|
|
764
|
+
}
|
|
765
|
+
const srv = await startVizServer({
|
|
766
|
+
contextDir,
|
|
767
|
+
viewerDir,
|
|
768
|
+
port: Number(opts.port),
|
|
769
|
+
repoName: basename(root),
|
|
770
|
+
});
|
|
771
|
+
console.log(`${cmd("julius viz")} → ${srv.url} (ctrl-c to stop)`);
|
|
772
|
+
if (opts.open) {
|
|
773
|
+
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
774
|
+
spawn(opener, [srv.url], { stdio: "ignore", detached: true, shell: process.platform === "win32" }).unref();
|
|
775
|
+
}
|
|
776
|
+
});
|
|
777
|
+
program
|
|
778
|
+
.command("mcp", { hidden: true })
|
|
779
|
+
.description("Serve compact local graph/context tools over MCP stdio")
|
|
780
|
+
.option("--full-tools", "expose the six inherited graph tools for compatibility")
|
|
781
|
+
.argument(...DIR_ARG)
|
|
782
|
+
.action(async (dirArg, opts) => {
|
|
783
|
+
const dir = queryRoot(dirArg);
|
|
784
|
+
const { startMcpServer } = await import("./mcp/server.js");
|
|
785
|
+
const globalOpts = program.opts();
|
|
786
|
+
startMcpServer(dir, globalOpts.dir, currentVersion, opts.fullTools);
|
|
787
|
+
});
|
|
788
|
+
grouped(program.command("callers"), GROUP.find)
|
|
789
|
+
.description("Who calls/references a symbol ($0, no LLM). --direction out gives callees (what it calls); --depth N (or all) walks transitively for full blast radius")
|
|
790
|
+
.argument("<symbol>", "bare name, qualified (Class.method), or package-qualified (pkg.Fn)")
|
|
791
|
+
.argument(...DIR_ARG)
|
|
792
|
+
.option("--direction <in|out>", 'edge direction: "in" = callers (default), "out" = callees')
|
|
793
|
+
.option("-d, --depth <n>", 'walk transitively up to N hops for blast radius, or "all" for the full connected closure (default 1)')
|
|
794
|
+
.option("--in <path>", "narrow matches to nodes at or under this path prefix")
|
|
795
|
+
.option("--json", "output as JSON")
|
|
796
|
+
.option(...NO_REFRESH_FLAG)
|
|
797
|
+
.action(async (symbol, dirArg, opts) => {
|
|
798
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
799
|
+
await refreshBefore(dir, opts);
|
|
800
|
+
const globalOpts = program.opts();
|
|
801
|
+
if (!opts.json && readWorkspace(dir, globalOpts.dir)) {
|
|
802
|
+
runWorkspaceCallers(dir, globalOpts.dir, symbol, {
|
|
803
|
+
direction: opts.direction === "out" ? "out" : "in",
|
|
804
|
+
depth: opts.depth
|
|
805
|
+
? (/^(all|full|max)$/i.test(opts.depth) ? Number.POSITIVE_INFINITY : Number(opts.depth))
|
|
806
|
+
: undefined,
|
|
807
|
+
in: opts.in,
|
|
808
|
+
});
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
const { runCallersCommand } = await import("./graph/traverse-cli.js");
|
|
812
|
+
runCallersCommand(symbol, dir, {
|
|
813
|
+
direction: opts.direction,
|
|
814
|
+
depth: opts.depth,
|
|
815
|
+
in: opts.in,
|
|
816
|
+
json: opts.json,
|
|
817
|
+
globalDir: globalOpts.dir,
|
|
818
|
+
});
|
|
819
|
+
});
|
|
820
|
+
grouped(program.command("blast"), GROUP.ci)
|
|
821
|
+
.description("Blast radius of a diff: what depends on the lines this change touched ($0, no LLM). " +
|
|
822
|
+
"Built for CI — `--format markdown` is a PR comment with a Mermaid diagram.")
|
|
823
|
+
.argument(...DIR_ARG)
|
|
824
|
+
.option("--base <ref>", "diff against this ref's merge base with HEAD (e.g. origin/main); default: the working tree vs HEAD")
|
|
825
|
+
.option("-d, --depth <n>", 'hops to walk over incoming edges, or "all" for the full closure (default 2)')
|
|
826
|
+
.option("--format <fmt>", "text (default) | markdown | mermaid | json")
|
|
827
|
+
.option("--name", "name the affected areas with one cached LLM call (needs JULIUS_API_KEY); without it, areas are named after their hub symbol")
|
|
828
|
+
.option("--export-viz <dir>", "also write the interactive page for this radius (one self-contained index.html — for CI, GitHub Pages, or an artifact)")
|
|
829
|
+
.option("--title <text>", "subtitle beside the repo name on the exported page (e.g. \"PR #171\")")
|
|
830
|
+
.option("--no-owners", "do not suggest who to tag (by default, git history names the people behind each affected area)")
|
|
831
|
+
.option("--pr-author <who...>", "GitHub login, git name or email of the PR author, so they are left out of their own suggestions")
|
|
832
|
+
.option(...NO_REFRESH_FLAG)
|
|
833
|
+
.action(async (dirArg, opts) => {
|
|
834
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
835
|
+
await refreshBefore(dir, opts);
|
|
836
|
+
const { runBlastCommand } = await import("./blast/blast-cli.js");
|
|
837
|
+
await runBlastCommand(dir, {
|
|
838
|
+
base: opts.base,
|
|
839
|
+
depth: opts.depth,
|
|
840
|
+
format: opts.format,
|
|
841
|
+
name: opts.name,
|
|
842
|
+
exportViz: opts.exportViz,
|
|
843
|
+
title: opts.title,
|
|
844
|
+
owners: opts.owners,
|
|
845
|
+
prAuthor: opts.prAuthor,
|
|
846
|
+
globalDir: program.opts().dir,
|
|
847
|
+
});
|
|
848
|
+
});
|
|
849
|
+
grouped(program.command("grep"), GROUP.find)
|
|
850
|
+
.description("Regex search over indexed files, hits grouped by enclosing symbol and ranked by coupling ($0, no LLM)")
|
|
851
|
+
.argument("<pattern>", "regex pattern (or literal string with --fixed)")
|
|
852
|
+
.argument(...DIR_ARG)
|
|
853
|
+
.option("-i, --ignore-case", "case-insensitive match")
|
|
854
|
+
.option("--fixed", "treat pattern as a literal string, not a regex")
|
|
855
|
+
.option("--in <path>", "narrow to files at or under this path prefix")
|
|
856
|
+
.option("--json", "output as JSON")
|
|
857
|
+
.option(...NO_REFRESH_FLAG)
|
|
858
|
+
.action(async (pattern, dirArg, opts) => {
|
|
859
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
860
|
+
await refreshBefore(dir, opts);
|
|
861
|
+
const globalOpts = program.opts();
|
|
862
|
+
if (readWorkspace(dir, globalOpts.dir)) {
|
|
863
|
+
runWorkspaceGrep(dir, globalOpts.dir, pattern, {
|
|
864
|
+
ignoreCase: opts.ignoreCase, fixed: opts.fixed, json: opts.json,
|
|
865
|
+
});
|
|
866
|
+
return;
|
|
867
|
+
}
|
|
868
|
+
const { runGrepCommand } = await import("./search/grep-cli.js");
|
|
869
|
+
runGrepCommand(pattern, dir, {
|
|
870
|
+
ignoreCase: opts.ignoreCase,
|
|
871
|
+
fixed: opts.fixed,
|
|
872
|
+
in: opts.in,
|
|
873
|
+
json: opts.json,
|
|
874
|
+
globalDir: globalOpts.dir,
|
|
875
|
+
});
|
|
876
|
+
});
|
|
877
|
+
grouped(program.command("map"), GROUP.find)
|
|
878
|
+
.description("Token-budgeted repo orientation — directory clusters, per-directory hubs, and global hotspots from the wiring graph ($0, no LLM)")
|
|
879
|
+
.argument(...DIR_ARG)
|
|
880
|
+
.option("--max-dirs <n>", "max directory entries shown, rest counted into dropped (default 16)")
|
|
881
|
+
.option("--json", "output as JSON")
|
|
882
|
+
.option(...NO_REFRESH_FLAG)
|
|
883
|
+
.action(async (dirArg, opts) => {
|
|
884
|
+
const dir = noteQuery(queryRoot(dirArg));
|
|
885
|
+
const root = resolve(dir);
|
|
886
|
+
const globalOpts = program.opts();
|
|
887
|
+
let maxDirsW;
|
|
888
|
+
if (opts.maxDirs !== undefined) {
|
|
889
|
+
const n = parseInt(opts.maxDirs, 10);
|
|
890
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
891
|
+
console.error(`✗ --max-dirs must be a positive integer, got "${opts.maxDirs}"`);
|
|
892
|
+
process.exit(1);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
maxDirsW = n;
|
|
896
|
+
}
|
|
897
|
+
await refreshBefore(dir, opts); // after arg validation: a bad flag shouldn't cost a rebuild
|
|
898
|
+
if (!opts.json && readWorkspace(root, globalOpts.dir)) {
|
|
899
|
+
runWorkspaceMap(root, globalOpts.dir, { maxDirs: maxDirsW });
|
|
900
|
+
return;
|
|
901
|
+
}
|
|
902
|
+
const { buildRepoMap, formatRepoMap } = await import("./graph/map.js");
|
|
903
|
+
const contextDir = contextDirFor(root, globalOpts.dir);
|
|
904
|
+
const graph = loadGraphCached(contextDir);
|
|
905
|
+
if (!graph) {
|
|
906
|
+
console.error(`✗ no graph — run ${cmd("julius build")} first`);
|
|
907
|
+
process.exit(1);
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
const map = buildRepoMap(graph, { maxDirs: maxDirsW });
|
|
911
|
+
if (opts.json) {
|
|
912
|
+
console.log(JSON.stringify(map, null, 2));
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
process.stdout.write(formatRepoMap(map));
|
|
916
|
+
});
|
|
917
|
+
// `julius note`: what a session worked out, saved for the next person. Listed
|
|
918
|
+
// under julius; under julius it still runs, unlisted, for a teammate on julius in
|
|
919
|
+
// a repo where someone else set up julius.
|
|
920
|
+
grouped(program.command("note", { hidden: false }), GROUP.memory)
|
|
921
|
+
.description("Save what this session decided, tried and ruled out, as a learning in the repo's .julius/learnings/ (the text on stdin)")
|
|
922
|
+
.requiredOption("--title <text>", "what the session was about, in a few words")
|
|
923
|
+
.option("-m, --body <text>", "the learning itself, instead of stdin")
|
|
924
|
+
.option("--personal", "about your own setup or habits, not the code: keep it in ~/.julius, out of the repo")
|
|
925
|
+
.option("--touches <list>", "comma-separated files or file#Symbol it's about (default: the files this session changed, in every repo it changed)")
|
|
926
|
+
.option("--author <name>", "who wrote it (default: the first word of git config user.name)")
|
|
927
|
+
.option("--minutes <n>", "what it took to work out, when the agent's transcript can't say")
|
|
928
|
+
.option("--tokens <n>", "the same, in tokens")
|
|
929
|
+
.option("--replaces <ref>", "the learning this one replaces, by id or file name")
|
|
930
|
+
.option("--anyway", "save even when the note checks fail")
|
|
931
|
+
.option("--json", "print the saved learning as JSON")
|
|
932
|
+
.argument("[dir]", "repository root", ".")
|
|
933
|
+
.action(async (dir, opts) => {
|
|
934
|
+
await runNoteCommand(resolve(dir), opts);
|
|
935
|
+
});
|
|
936
|
+
// `julius learn` and `julius skills`: corrections become takeaways on a skill,
|
|
937
|
+
// kept on this machine, and takeaways fold into its SKILL.md. Unlisted under
|
|
938
|
+
// julius, like `note`, but they run.
|
|
939
|
+
// Still runs; unlisted while learnings are the one thing julius keeps.
|
|
940
|
+
grouped(program.command("learn", { hidden: true }), GROUP.memory)
|
|
941
|
+
.description("Turn a correction into a takeaway on a skill, kept in ~/.julius (the takeaway on stdin)")
|
|
942
|
+
.argument("<skill>", "the skill it belongs to, e.g. pdf-coords; a new name makes a new skill")
|
|
943
|
+
.argument("[dir]", "repository root", ".")
|
|
944
|
+
.option("-m, --text <text>", "the takeaway itself, instead of stdin")
|
|
945
|
+
.option("--description <text>", "for a new skill: what it covers")
|
|
946
|
+
.option("--section <heading>", "the SKILL.md heading it belongs under when folded")
|
|
947
|
+
.option("--author <name>", "who taught it (default: the first word of git config user.name)")
|
|
948
|
+
.action(async (skill, dir, opts) => {
|
|
949
|
+
const repo = resolve(dir);
|
|
950
|
+
const text = (opts.text ?? (await readStdin())).trim();
|
|
951
|
+
if (!text) {
|
|
952
|
+
console.error(`✗ a takeaway needs its text, on stdin or with -m:`);
|
|
953
|
+
console.error(` ${cmd("julius learn")} ${skill} <<'EOF'\n Read rotation with page.Rotation(), never pdfcpu: it drops /Rotate on linearized files.\n EOF`);
|
|
954
|
+
process.exitCode = 1;
|
|
955
|
+
return;
|
|
956
|
+
}
|
|
957
|
+
const author = opts.author?.trim() || noteAuthor(repo);
|
|
958
|
+
let r;
|
|
959
|
+
try {
|
|
960
|
+
r = learn(repo, { skill, text, author, date: new Date().toISOString().slice(0, 10), description: opts.description, section: opts.section });
|
|
961
|
+
}
|
|
962
|
+
catch (err) {
|
|
963
|
+
console.error(`✗ ${err instanceof Error ? err.message : String(err)}`);
|
|
964
|
+
process.exitCode = 1;
|
|
965
|
+
return;
|
|
966
|
+
}
|
|
967
|
+
track("takeaway_saved", { new_skill: String(r.created) }, { repo });
|
|
968
|
+
const kind = r.created ? "new skill" : r.skill.where === "repo" ? "the repo's skill" : "skill";
|
|
969
|
+
console.log(`✓ takeaway saved to ${kind} ${r.skill.name}${author ? ` · taught by ${author}` : ""}`);
|
|
970
|
+
console.log(`· your agent follows it from now on · kept on this machine, in ${shownPath(dirname(dirname(r.takeaway.path)))}`);
|
|
971
|
+
console.log(`· ${cmd("julius skills")} fold ${r.skill.name} writes it into SKILL.md`);
|
|
972
|
+
});
|
|
973
|
+
const skillsCmd = grouped(program.command("skills", { hidden: true }), GROUP.memory)
|
|
974
|
+
.description("List this repo's skills, and the takeaways waiting to fold into each")
|
|
975
|
+
.argument("[dir]", "repository root", ".")
|
|
976
|
+
.option("--json", "output as JSON")
|
|
977
|
+
.action((dir, opts) => {
|
|
978
|
+
const repo = resolve(dir);
|
|
979
|
+
const all = listSkills(repo);
|
|
980
|
+
if (opts.json) {
|
|
981
|
+
console.log(JSON.stringify(all, null, 2));
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
if (all.length === 0) {
|
|
985
|
+
console.log(`no skills yet · ${cmd("julius learn")} <skill> saves the first takeaway and makes the skill`);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
const width = Math.max(...all.map((s) => s.name.length)) + 2;
|
|
989
|
+
for (const s of all)
|
|
990
|
+
console.log(`${s.name.padEnd(width)}${skillStatus(s)}`);
|
|
991
|
+
});
|
|
992
|
+
/** `✗ no skill called x` and the exit code, for a name that isn't one. */
|
|
993
|
+
function noSuchSkill(name) {
|
|
994
|
+
console.error(`✗ no skill called ${skillName(name)} · ${cmd("julius skills")} lists them`);
|
|
995
|
+
process.exitCode = 1;
|
|
996
|
+
}
|
|
997
|
+
skillsCmd
|
|
998
|
+
.command("show")
|
|
999
|
+
.description("Print a skill with every takeaway not yet folded in: what an agent reads before working in its area")
|
|
1000
|
+
.argument("<skill>", "the skill")
|
|
1001
|
+
.option("-C, --dir <path>", "repository root", ".")
|
|
1002
|
+
.action((skill, opts) => {
|
|
1003
|
+
const s = getSkill(resolve(opts.dir), skill);
|
|
1004
|
+
if (!s)
|
|
1005
|
+
return noSuchSkill(skill);
|
|
1006
|
+
process.stdout.write(skillForAgent(s));
|
|
1007
|
+
});
|
|
1008
|
+
skillsCmd
|
|
1009
|
+
.command("fold")
|
|
1010
|
+
.description("Write a skill's waiting takeaways into its SKILL.md and bump its version")
|
|
1011
|
+
.argument("[skill]", "one skill; leave out to fold every skill with takeaways waiting")
|
|
1012
|
+
.option("--confirmed", "only the takeaways someone other than their teacher confirmed")
|
|
1013
|
+
.option("-C, --dir <path>", "repository root", ".")
|
|
1014
|
+
.action((skill, opts) => {
|
|
1015
|
+
const repo = resolve(opts.dir);
|
|
1016
|
+
if (skill && !getSkill(repo, skill))
|
|
1017
|
+
return noSuchSkill(skill);
|
|
1018
|
+
const names = skill ? [skill] : listSkills(repo).map((s) => s.name);
|
|
1019
|
+
let inRepo = false;
|
|
1020
|
+
let any = false;
|
|
1021
|
+
for (const n of names) {
|
|
1022
|
+
const r = fold(repo, n, { confirmed: opts.confirmed });
|
|
1023
|
+
if (!r)
|
|
1024
|
+
continue;
|
|
1025
|
+
if (r.folded.length === 0) {
|
|
1026
|
+
if (skill)
|
|
1027
|
+
console.log(`· ${r.skill} v${r.from} · nothing to fold${r.stillWaiting ? `, ${r.stillWaiting} waiting for a second person` : ""}`);
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
any = true;
|
|
1031
|
+
inRepo ||= r.where === "repo";
|
|
1032
|
+
track("skills_folded", { takeaways_bucket: countBucket(r.folded.length) }, { repo });
|
|
1033
|
+
console.log(`✓ ${r.skill} v${r.from} → v${r.to} · folded ${r.folded.length} takeaway${r.folded.length === 1 ? "" : "s"}${r.stillWaiting ? `, ${r.stillWaiting} still waiting` : ""}`);
|
|
1034
|
+
console.log(` M ${r.where === "repo" ? shown(repo, r.file) : shownPath(r.file)} ${r.sections.map((h) => `+ ${h}`).join(" ")}`);
|
|
1035
|
+
}
|
|
1036
|
+
if (!any) {
|
|
1037
|
+
if (!skill)
|
|
1038
|
+
console.log("· nothing to fold");
|
|
1039
|
+
return;
|
|
1040
|
+
}
|
|
1041
|
+
if (inRepo)
|
|
1042
|
+
console.log("· review with git diff, then commit");
|
|
1043
|
+
else
|
|
1044
|
+
console.log(`· ${cmd("julius skills")} publish <skill> moves a skill into the repo's .claude/skills/, to commit for your team`);
|
|
1045
|
+
});
|
|
1046
|
+
skillsCmd
|
|
1047
|
+
.command("publish")
|
|
1048
|
+
.description("Move a skill kept on this machine into the repo's .claude/skills/, ready to commit")
|
|
1049
|
+
.argument("<skill>", "the skill")
|
|
1050
|
+
.option("-C, --dir <path>", "repository root", ".")
|
|
1051
|
+
.action((skill, opts) => {
|
|
1052
|
+
const repo = resolve(opts.dir);
|
|
1053
|
+
const r = publish(repo, skill);
|
|
1054
|
+
if (!r.ok) {
|
|
1055
|
+
if (r.reason === "unknown")
|
|
1056
|
+
return noSuchSkill(skill);
|
|
1057
|
+
console.log(`· ${skillName(skill)} is already in the repo, in .claude/skills/${skillName(skill)}/`);
|
|
1058
|
+
return;
|
|
1059
|
+
}
|
|
1060
|
+
console.log(`✓ ${skillName(skill)} → ${shown(repo, r.file)}`);
|
|
1061
|
+
console.log("· commit it to share it: Claude Code loads it for everyone who pulls. its takeaways stay on this machine");
|
|
1062
|
+
});
|
|
1063
|
+
skillsCmd
|
|
1064
|
+
.command("confirm")
|
|
1065
|
+
.description("Say a teammate's takeaway is right, so `fold --confirmed` takes it")
|
|
1066
|
+
.argument("<skill>", "the skill")
|
|
1067
|
+
.argument("[takeaway]", "one takeaway file (default: every one waiting that someone else taught)")
|
|
1068
|
+
.option("--author <name>", "who is confirming (default: the first word of git config user.name)")
|
|
1069
|
+
.option("-C, --dir <path>", "repository root", ".")
|
|
1070
|
+
.action((skill, takeaway, opts) => {
|
|
1071
|
+
const repo = resolve(opts.dir);
|
|
1072
|
+
if (!getSkill(repo, skill))
|
|
1073
|
+
return noSuchSkill(skill);
|
|
1074
|
+
const who = opts.author?.trim() || noteAuthor(repo);
|
|
1075
|
+
const done = confirm(repo, skill, who, takeaway);
|
|
1076
|
+
if (done.length === 0) {
|
|
1077
|
+
console.log(`· nothing to confirm on ${skillName(skill)} — a takeaway needs someone other than its teacher`);
|
|
1078
|
+
return;
|
|
1079
|
+
}
|
|
1080
|
+
for (const t of done)
|
|
1081
|
+
console.log(`✓ confirmed ${t.taughtBy || "a"}'s takeaway from ${shortDate(t.date)} · ${shownPath(t.path)}`);
|
|
1082
|
+
console.log(`· ${cmd("julius skills")} fold ${skillName(skill)} writes it into SKILL.md`);
|
|
1083
|
+
});
|
|
1084
|
+
grouped(program.command("init"), GROUP.setup)
|
|
1085
|
+
.description("Wire julius into your agents: instruction files and MCP for each, plus hooks and a statusline for Claude Code")
|
|
1086
|
+
.argument("[dir]", "target repo directory", ".")
|
|
1087
|
+
.option("--no-build", "skip building the graph (wire files only)")
|
|
1088
|
+
.option("--agents <ids...>", `only these agents (${hostIds().join(", ")}, claude)`)
|
|
1089
|
+
.option("--all-agents", "write instruction files for every known agent, detected or not")
|
|
1090
|
+
.option("--no-agents", "Claude Code wiring only; skip other agents")
|
|
1091
|
+
.option("--list-agents", "list known agent ids and exit")
|
|
1092
|
+
.option("--no-mcp", "skip MCP server registration for other agents")
|
|
1093
|
+
.option("--no-hooks", "skip hook installation for other agents")
|
|
1094
|
+
.option("--no-statusline", "skip writing Claude Code statusLine (keep a user-defined one)")
|
|
1095
|
+
.option("--dry-run", "print every file init would touch, then exit without writing")
|
|
1096
|
+
.option("-y, --yes", "skip the picker and wire every detected agent (the pre-0.8 default)")
|
|
1097
|
+
.option("--no-global", "skip writes outside this repo (the ~/.codex/ config + hooks)")
|
|
1098
|
+
.option("--verbose", "print every file written, the graph build's own output and the closing banner")
|
|
1099
|
+
.action(async (dir, opts) => {
|
|
1100
|
+
await runInitCommand(dir, opts);
|
|
1101
|
+
});
|
|
1102
|
+
/** Everything on stdin, or "" when nothing is piped in. */
|
|
1103
|
+
async function readStdin() {
|
|
1104
|
+
if (process.stdin.isTTY)
|
|
1105
|
+
return "";
|
|
1106
|
+
const chunks = [];
|
|
1107
|
+
for await (const c of process.stdin)
|
|
1108
|
+
chunks.push(typeof c === "string" ? Buffer.from(c) : c);
|
|
1109
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
1110
|
+
}
|
|
1111
|
+
async function runNoteCommand(repo, opts) {
|
|
1112
|
+
const body = (opts.body ?? (await readStdin())).trim();
|
|
1113
|
+
if (!opts.title.trim() || !body) {
|
|
1114
|
+
console.error(`✗ a learning needs a --title and a body, on stdin or with -m:`);
|
|
1115
|
+
console.error(` ${cmd("julius note")} --title "What it was about" <<'EOF'`);
|
|
1116
|
+
console.error(" ## Decided\n …\n ## Tried and ruled out\n …\n ## Watch out\n …\n EOF");
|
|
1117
|
+
process.exitCode = 1;
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
const wholeNumber = (raw, flag) => {
|
|
1121
|
+
if (raw === undefined)
|
|
1122
|
+
return undefined;
|
|
1123
|
+
const n = Number(raw);
|
|
1124
|
+
if (!Number.isFinite(n) || n < 0) {
|
|
1125
|
+
console.error(`✗ ${flag} takes a number, got "${raw}"`);
|
|
1126
|
+
process.exit(1);
|
|
1127
|
+
}
|
|
1128
|
+
return Math.round(n);
|
|
1129
|
+
};
|
|
1130
|
+
const minutes = wholeNumber(opts.minutes, "--minutes");
|
|
1131
|
+
const tokens = wholeNumber(opts.tokens, "--tokens");
|
|
1132
|
+
// What the session spent, from the agent's own transcript when there is one,
|
|
1133
|
+
// counted from where the work the note names first came up; the flags win,
|
|
1134
|
+
// since only the agent knows for sure where its task began.
|
|
1135
|
+
const named = [...(opts.touches?.split(",").map((t) => t.trim()).filter(Boolean) ?? []), ...mentionedFiles(repo, body)];
|
|
1136
|
+
const spent = currentSessionCost(repo, undefined, Date.now(), aboutTerms(body, named));
|
|
1137
|
+
const cost = minutes !== undefined || tokens !== undefined || spent
|
|
1138
|
+
? { minutes: minutes ?? spent?.minutes, tokens: tokens ?? spent?.tokens }
|
|
1139
|
+
: undefined;
|
|
1140
|
+
// Which repos it goes to: the one it was saved from, plus any other the
|
|
1141
|
+
// session edited. Explicit --touches means just this repo.
|
|
1142
|
+
const targets = opts.touches
|
|
1143
|
+
? [{ dir: repo, touches: opts.touches.split(",").map((t) => t.trim()).filter(Boolean) }]
|
|
1144
|
+
: noteTargets(repo, spent?.edited ?? [], spent?.startedAt, spent ? { read: spent.read } : undefined).map((t) => ({
|
|
1145
|
+
dir: t.dir,
|
|
1146
|
+
// Then the files the note names, then the ones the session only read.
|
|
1147
|
+
touches: [...new Set([...t.touches, ...mentionedFiles(t.dir, body), ...(t.read ?? [])])].slice(0, 10),
|
|
1148
|
+
}));
|
|
1149
|
+
const author = opts.author?.trim() || noteAuthor(repo);
|
|
1150
|
+
const date = new Date().toISOString().slice(0, 10);
|
|
1151
|
+
const scope = opts.personal ? "personal" : "repo";
|
|
1152
|
+
const existing = listNotes(repo);
|
|
1153
|
+
let replaces = opts.replaces?.trim();
|
|
1154
|
+
if (replaces) {
|
|
1155
|
+
const found = findLearning(existing, replaces);
|
|
1156
|
+
if (found)
|
|
1157
|
+
replaces = found.id;
|
|
1158
|
+
else if (!asLearningId(replaces)) {
|
|
1159
|
+
console.error(`✗ no learning named ${opts.replaces}`);
|
|
1160
|
+
process.exitCode = 1;
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
if (!opts.anyway) {
|
|
1165
|
+
const text = `${opts.title}\n${body}`;
|
|
1166
|
+
const namedFiles = mentionedFiles(repo, text);
|
|
1167
|
+
const gate = gateNote({
|
|
1168
|
+
title: opts.title,
|
|
1169
|
+
body,
|
|
1170
|
+
personal: scope === "personal",
|
|
1171
|
+
files: [...trackedFiles(repo, namedFiles)],
|
|
1172
|
+
namesSymbol: namesRepoSymbol(repo, symbolCandidates(text)),
|
|
1173
|
+
touches: named,
|
|
1174
|
+
replaces,
|
|
1175
|
+
}, existing);
|
|
1176
|
+
for (const warning of gate.warnings)
|
|
1177
|
+
console.error(`! ${warning}`);
|
|
1178
|
+
if (gate.problems.length) {
|
|
1179
|
+
for (const problem of gate.problems)
|
|
1180
|
+
console.error(`✗ ${problem}`);
|
|
1181
|
+
console.error(" save anyway with --anyway");
|
|
1182
|
+
process.exitCode = 1;
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
const earlier = [];
|
|
1187
|
+
const saved = [];
|
|
1188
|
+
for (const t of targets) {
|
|
1189
|
+
earlier.push(...listNotes(t.dir));
|
|
1190
|
+
saved.push(writeNote(t.dir, { title: opts.title, body, author, date, branch: currentBranch(t.dir), cost, touches: t.touches, replaces }, scope));
|
|
1191
|
+
}
|
|
1192
|
+
const touches = targets.flatMap((t) => t.touches);
|
|
1193
|
+
track("note_saved", { has_cost: String(cost?.tokens !== undefined || cost?.minutes !== undefined), touches_bucket: countBucket(touches.length), scope: saved[0]?.scope ?? scope }, { repo });
|
|
1194
|
+
if (opts.json) {
|
|
1195
|
+
console.log(JSON.stringify(saved.length === 1 ? saved[0] : saved, null, 2));
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
for (const n of saved)
|
|
1199
|
+
console.log(`✓ ${n.scope === "personal" ? "saved just for you" : "saved for your team"} · ${notePlace(n)}`);
|
|
1200
|
+
const note = saved[0];
|
|
1201
|
+
// Name a code file if the note touches one; docs are rarely what it's about.
|
|
1202
|
+
const about = touches.find((t) => !/\.(md|mdx|txt)$/i.test(t.split("#")[0])) ?? touches[0];
|
|
1203
|
+
const first = about ? ` that touches ${basename(about.split("#")[0])}` : "";
|
|
1204
|
+
const took = costLabel(note.cost);
|
|
1205
|
+
if (took && tokensWorthSaying(note.cost?.tokens)) {
|
|
1206
|
+
const reading = tokensLabel(readingTokens(note)).replace(" tokens", "");
|
|
1207
|
+
console.log(`· this ${took.replace(" to work out", " to figure out")}. the next session${first} gets it for ${reading}`);
|
|
1208
|
+
}
|
|
1209
|
+
else if (note.scope !== "personal") {
|
|
1210
|
+
console.log(`· the next session${first} starts from this, and gets to a PR ${PR_SPEEDUP}`);
|
|
1211
|
+
}
|
|
1212
|
+
// Learnings about the same files, from someone else: this one builds on theirs.
|
|
1213
|
+
const files = new Set(touches.map((t) => t.split("#")[0]));
|
|
1214
|
+
const prior = earlier.find((n) => n.author !== note.author && n.touches.some((t) => files.has(t.split("#")[0])));
|
|
1215
|
+
if (prior)
|
|
1216
|
+
console.log(`· builds on ${prior.author ? `${prior.author}'s` : "a"} learning from ${shortDate(prior.date)}`);
|
|
1217
|
+
if (!SECTIONS.some((s) => sectionLead(body, s.heading) !== null))
|
|
1218
|
+
console.log("· tip: learnings read best under ## Decided, ## Tried and ruled out and ## Watch out");
|
|
1219
|
+
const repoSaved = saved.filter((n) => n.scope === "repo");
|
|
1220
|
+
if (repoSaved.length) {
|
|
1221
|
+
// Who else works on these files, for the case for committing it.
|
|
1222
|
+
const lines = commitLines(note, teammatesOn(repo, [...files].filter((f) => !!f)));
|
|
1223
|
+
console.log(`${lines.uncommitted} · git add ${repoSaved.map(notePlace).join(" ")}`);
|
|
1224
|
+
if (!process.stdout.isTTY)
|
|
1225
|
+
console.log(`[julius] Close your reply with one line, word for word. If this learning is committed by the end of your turn: ${lines.committed}\n` +
|
|
1226
|
+
` If it isn't: ${lines.uncommitted}`);
|
|
1227
|
+
}
|
|
1228
|
+
else {
|
|
1229
|
+
console.log("· just for you: kept on this machine, out of the repo");
|
|
1230
|
+
if (!process.stdout.isTTY)
|
|
1231
|
+
console.log(`[julius] Close your reply with this line, word for word: ${PERSONAL_SAVED_LINE}`);
|
|
1232
|
+
}
|
|
1233
|
+
for (const t of targets) {
|
|
1234
|
+
rememberRepo(t.dir);
|
|
1235
|
+
maybeSyncInBackground(t.dir);
|
|
1236
|
+
}
|
|
1237
|
+
printLines(cloudLines(repo, { command: "note" }));
|
|
1238
|
+
}
|
|
1239
|
+
/** Lines that close a command's output, with a blank line before them. */
|
|
1240
|
+
function printLines(lines) {
|
|
1241
|
+
if (lines.length)
|
|
1242
|
+
console.log(`\n${lines.join("\n")}`);
|
|
1243
|
+
}
|
|
1244
|
+
/** Repo-relative with forward slashes, for printing. */
|
|
1245
|
+
function shown(repo, path) {
|
|
1246
|
+
return relative(repo, path).split("\\").join("/");
|
|
1247
|
+
}
|
|
1248
|
+
/** `julius init`. */
|
|
1249
|
+
async function runInitCommand(dir, opts) {
|
|
1250
|
+
if (opts.listAgents) {
|
|
1251
|
+
for (const id of [...hostIds(), "claude"])
|
|
1252
|
+
console.log(id);
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
const repo = resolve(dir);
|
|
1256
|
+
const explicit = Array.isArray(opts.agents) ? opts.agents : undefined;
|
|
1257
|
+
// Checked before anything is written: run from the home folder, init wired
|
|
1258
|
+
// it, mapped every code file under it, then said to commit.
|
|
1259
|
+
const refusal = homeFolderRefusal(repo);
|
|
1260
|
+
if (refusal) {
|
|
1261
|
+
console.error(refusal);
|
|
1262
|
+
process.exitCode = 1;
|
|
1263
|
+
return null;
|
|
1264
|
+
}
|
|
1265
|
+
if (explicit) {
|
|
1266
|
+
const validIds = [...hostIds(), "claude"];
|
|
1267
|
+
const unknown = explicit.filter((id) => !validIds.includes(id));
|
|
1268
|
+
if (unknown.length) {
|
|
1269
|
+
console.error(`✗ unknown agent id(s): ${unknown.join(", ")} — valid: ${validIds.join(", ")}`);
|
|
1270
|
+
process.exit(1);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
// Which agents to wire, decided before anything is written. Explicit flags
|
|
1274
|
+
// win; otherwise prompt on a TTY, and on a pipe write nothing rather than
|
|
1275
|
+
// guessing (pre-0.8 this silently wired every agent the machine had ever
|
|
1276
|
+
// installed — see --yes to get that back).
|
|
1277
|
+
const home = homedir();
|
|
1278
|
+
const plan = planInit(repo, { home });
|
|
1279
|
+
const detectedIds = plan.filter((p) => p.detected).map((p) => p.id);
|
|
1280
|
+
const noAgents = opts.agents === false;
|
|
1281
|
+
let ids;
|
|
1282
|
+
// The consent answer from the picker. Undefined everywhere else — a scripted
|
|
1283
|
+
// or flag-driven init never asked, so it must not silently answer.
|
|
1284
|
+
let consent;
|
|
1285
|
+
if (explicit)
|
|
1286
|
+
ids = explicit;
|
|
1287
|
+
else if (opts.allAgents)
|
|
1288
|
+
ids = plan.map((p) => p.id);
|
|
1289
|
+
else if (noAgents)
|
|
1290
|
+
ids = ["claude"];
|
|
1291
|
+
else if (opts.yes || opts.dryRun)
|
|
1292
|
+
ids = detectedIds;
|
|
1293
|
+
else if (process.stdin.isTTY && process.stderr.isTTY) {
|
|
1294
|
+
// Only offer the row when telemetry could actually run. `disabled` still
|
|
1295
|
+
// counts: someone who turned it off should be able to turn it back on here.
|
|
1296
|
+
const reason = offReason();
|
|
1297
|
+
const picked = await runPicker(plan, repo, home, {
|
|
1298
|
+
offerTelemetry: reason === null || reason === "disabled",
|
|
1299
|
+
});
|
|
1300
|
+
if (picked === null) {
|
|
1301
|
+
console.error("· cancelled — nothing written");
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
ids = picked.hosts;
|
|
1305
|
+
consent = picked.telemetry;
|
|
1306
|
+
}
|
|
1307
|
+
else {
|
|
1308
|
+
console.error(formatNonInteractiveHelp(detectedIds));
|
|
1309
|
+
return null;
|
|
1310
|
+
}
|
|
1311
|
+
// The picker's answer, recorded before anything is wired: a user who
|
|
1312
|
+
// unchecked the row must not have this run's init_completed sent.
|
|
1313
|
+
if (consent !== undefined) {
|
|
1314
|
+
patchState({ enabled: consent, noticeShownAt: new Date().toISOString() });
|
|
1315
|
+
}
|
|
1316
|
+
// Workspace parent: every child repo gets its OWN wiring too. A session
|
|
1317
|
+
// opens at a repo root, not at the parent, and reads `.claude/` from there —
|
|
1318
|
+
// wiring only the parent leaves each child with no skill, hooks, or MCP.
|
|
1319
|
+
// The parent's own wiring stays (queries there federate across children).
|
|
1320
|
+
const children = isWorkspaceBuildRoot(repo, program.opts().dir)
|
|
1321
|
+
? discoverWorkspaceChildren(repo)
|
|
1322
|
+
: [];
|
|
1323
|
+
// Parent FIRST: its build is the workspace build, which builds every child's
|
|
1324
|
+
// graph, so each child's own `buildGraphIfMissing` then finds one and no-ops.
|
|
1325
|
+
const targets = [repo, ...children.map((c) => join(repo, c))];
|
|
1326
|
+
if (opts.dryRun) {
|
|
1327
|
+
console.error(formatPlan(plan, ids, repo, home));
|
|
1328
|
+
for (const child of children)
|
|
1329
|
+
console.error(`\n— ${child}/ (workspace child)\n` + formatPlan(planInit(join(repo, child), { home }), ids, join(repo, child), home));
|
|
1330
|
+
return null;
|
|
1331
|
+
}
|
|
1332
|
+
if (ids.length === 0) {
|
|
1333
|
+
console.error("· no agents selected — nothing written");
|
|
1334
|
+
return null;
|
|
1335
|
+
}
|
|
1336
|
+
const wantClaude = ids.includes("claude");
|
|
1337
|
+
const cliPath = fileURLToPath(import.meta.url);
|
|
1338
|
+
// Under julius, each repo gets its `.julius/learnings/`, committed with the
|
|
1339
|
+
// code, and its folder in ~/.julius for personal learnings and corrections.
|
|
1340
|
+
// First, before the reads below send their first event: that makes the
|
|
1341
|
+
// repo one on julius, so the event's repo id lands in `.julius/cache/` and
|
|
1342
|
+
// not in a `julius/` that nothing ignores.
|
|
1343
|
+
const notesHome = new Map();
|
|
1344
|
+
for (const target of targets) {
|
|
1345
|
+
const { place } = ensureRepoHome(target);
|
|
1346
|
+
const created = place.git ? ensureRepoJulius(place.checkout) : false;
|
|
1347
|
+
notesHome.set(target, { created, dir: place.git ? place.checkout : place.dir });
|
|
1348
|
+
if (place.git)
|
|
1349
|
+
maybeRefreshBranches(place.checkout);
|
|
1350
|
+
}
|
|
1351
|
+
// Under julius, with Claude Code picked: what the person kept telling Claude
|
|
1352
|
+
// in this repo's past sessions, and what reviewers kept flagging on its
|
|
1353
|
+
// merged PRs, read while the rest of init runs and saved as learnings at
|
|
1354
|
+
// the end. Once per repo, and never asked about first.
|
|
1355
|
+
const pastRead = wantClaude ? beginPastRead(repo) : null;
|
|
1356
|
+
if (pastRead)
|
|
1357
|
+
console.error(`· reading your ${pastRead.sessions} past Claude sessions here for what you keep telling Claude`);
|
|
1358
|
+
const reviewRead = wantClaude ? beginReviewRead(repo) : null;
|
|
1359
|
+
if (reviewRead)
|
|
1360
|
+
console.error("· reading review comments on this repo's merged PRs for what reviewers keep flagging");
|
|
1361
|
+
if (children.length)
|
|
1362
|
+
console.error(`· workspace: wiring ${repo} and ${children.length} child repo(s) — ${children.join(", ")}`);
|
|
1363
|
+
// Today's output, file by file, behind --verbose. Everything else gets one
|
|
1364
|
+
// line per step: the graph, then one per agent.
|
|
1365
|
+
const verbose = opts.verbose === true;
|
|
1366
|
+
const reports = [];
|
|
1367
|
+
for (const target of targets) {
|
|
1368
|
+
if (verbose && target !== repo)
|
|
1369
|
+
console.error(`\n— ${relative(repo, target)}/`);
|
|
1370
|
+
reports.push(wireTarget(target, ids, { home, cliPath, plan, opts, wantClaude, quiet: !verbose }));
|
|
1371
|
+
}
|
|
1372
|
+
// The graph, built once after the wiring: a workspace parent's build is
|
|
1373
|
+
// the workspace build, so it covers every child.
|
|
1374
|
+
let graphLine = null;
|
|
1375
|
+
if (!verbose) {
|
|
1376
|
+
const res = await buildGraphWithProgress(repo, { build: opts.build, cliPath });
|
|
1377
|
+
for (const m of res.messages)
|
|
1378
|
+
console.error(m);
|
|
1379
|
+
const existing = res.built ? null : loadGraphCached(contextDirFor(repo, children.length ? undefined : program.opts().dir));
|
|
1380
|
+
const fmt = (x) => x.toLocaleString("en-US");
|
|
1381
|
+
if (res.graph) {
|
|
1382
|
+
graphLine = `✓ graph built · ${fmt(res.graph.nodes)} nodes, ${fmt(res.graph.edges)} edges${res.graph.files ? ` from ${fmt(res.graph.files)} file${res.graph.files === 1 ? "" : "s"}` : ""}`;
|
|
1383
|
+
}
|
|
1384
|
+
else if (res.built) {
|
|
1385
|
+
graphLine = "✓ graph built";
|
|
1386
|
+
}
|
|
1387
|
+
else if (res.failed) {
|
|
1388
|
+
graphLine = `⚠ the graph build failed — run ${cmd("julius build")} to see why`;
|
|
1389
|
+
}
|
|
1390
|
+
else if (existing) {
|
|
1391
|
+
graphLine = `✓ graph ready · ${fmt(existing.meta.nodeCount)} nodes, ${fmt(existing.meta.edgeCount)} edges`;
|
|
1392
|
+
}
|
|
1393
|
+
else if (hasJuliusIndex(repo)) {
|
|
1394
|
+
graphLine = "✓ graph ready";
|
|
1395
|
+
}
|
|
1396
|
+
else {
|
|
1397
|
+
graphLine = `· skipped the graph build — run ${cmd("julius build")}`;
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
if (!verbose) {
|
|
1401
|
+
// Warnings and removals in full, whatever else is folded.
|
|
1402
|
+
const removed = [...new Set(reports.flatMap((r) => r.retracted))];
|
|
1403
|
+
for (const id of removed)
|
|
1404
|
+
console.error(`- removed ${id} — agent not selected`);
|
|
1405
|
+
for (const w of reports.flatMap((r) => r.warnings))
|
|
1406
|
+
console.error(w);
|
|
1407
|
+
const writesFor = (id) => (plan.find((p) => p.id === id)?.writes ?? []).filter((w) => opts.global !== false || w.scope !== "global");
|
|
1408
|
+
if (graphLine)
|
|
1409
|
+
console.error(graphLine);
|
|
1410
|
+
const width = Math.max(...ids.map((id) => id.length));
|
|
1411
|
+
for (const id of ids) {
|
|
1412
|
+
const summary = compactWrites(writesFor(id), repo, home);
|
|
1413
|
+
console.error(`✓ ${id.padEnd(width)} ${summary}`.trimEnd());
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
// Under julius: what init learned from past sessions and PR reviews, where
|
|
1417
|
+
// this repo's learnings are, and how many there already are.
|
|
1418
|
+
let learnedNow = false;
|
|
1419
|
+
if ((pastRead || reviewRead)) {
|
|
1420
|
+
if (pastRead && !pastRead.done)
|
|
1421
|
+
console.error("· still reading your past sessions…");
|
|
1422
|
+
const fromSessions = pastRead ? (await pastRead.result).findings : [];
|
|
1423
|
+
if (reviewRead && !reviewRead.done)
|
|
1424
|
+
console.error("· still reading PR reviews…");
|
|
1425
|
+
const fromReviews = reviewRead ? (await reviewRead.result).findings : [];
|
|
1426
|
+
// On a terminal, the person ticks which to keep in one list for both
|
|
1427
|
+
// sources, all ticked to start; a scripted run, or one with --yes, keeps
|
|
1428
|
+
// them all. Cancelling saves none, and the next init asks again.
|
|
1429
|
+
const picked = process.stdin.isTTY && process.stderr.isTTY && !opts.yes && fromSessions.length + fromReviews.length
|
|
1430
|
+
? await pickLearnings([
|
|
1431
|
+
...fromSessions.map((f) => ({ title: f.title, forTeam: f.for === "team", sessions: f.sessions.length })),
|
|
1432
|
+
...fromReviews.map((f) => ({ title: f.title, forTeam: true, prs: f.prs.length })),
|
|
1433
|
+
])
|
|
1434
|
+
: undefined;
|
|
1435
|
+
// The picked rows that are `found`'s, which start at `from` in the list.
|
|
1436
|
+
const keepFrom = (from) => picked === undefined
|
|
1437
|
+
? undefined
|
|
1438
|
+
: async (found) => picked && picked.filter((i) => i >= from && i < from + found.length).map((i) => found[i - from]);
|
|
1439
|
+
const learned = [];
|
|
1440
|
+
if (pastRead) {
|
|
1441
|
+
const { result, saved, kept, cancelled } = await finishPastRead(repo, pastRead, keepFrom(0));
|
|
1442
|
+
const offered = result.findings.length;
|
|
1443
|
+
if (saved.length) {
|
|
1444
|
+
const n = saved.length;
|
|
1445
|
+
const what = n < offered ? `kept ${n} of the ${offered} things` : `learned ${n} thing${n === 1 ? "" : "s"}`;
|
|
1446
|
+
console.error(`✓ ${what} you told Claude more than once, from your last ${result.read} sessions here`);
|
|
1447
|
+
// Each with how many sessions it was said in: saveFindings keeps the findings' order.
|
|
1448
|
+
saved.forEach((note, i) => {
|
|
1449
|
+
const said = kept[i]?.sessions.length ?? 0;
|
|
1450
|
+
const count = said > 1 ? `told Claude in ${said} sessions: ` : "";
|
|
1451
|
+
console.error(` ${note.scope === "personal" ? "just for you " : "for your team"} · ${count}${note.title}`);
|
|
1452
|
+
});
|
|
1453
|
+
}
|
|
1454
|
+
else if (cancelled) {
|
|
1455
|
+
console.error(`· saved none of the ${offered} things you told Claude more than once; ${cmd("julius init")} again asks again`);
|
|
1456
|
+
}
|
|
1457
|
+
else if (offered) {
|
|
1458
|
+
console.error(`· kept none of the ${offered} things you told Claude more than once`);
|
|
1459
|
+
}
|
|
1460
|
+
else if (result.reason === "failed") {
|
|
1461
|
+
console.error(`· couldn't read your past sessions this time; ${cmd("julius init")} again tries again`);
|
|
1462
|
+
}
|
|
1463
|
+
learned.push(...saved);
|
|
1464
|
+
}
|
|
1465
|
+
if (reviewRead) {
|
|
1466
|
+
const { result, saved, kept, cancelled } = await finishReviewRead(repo, reviewRead, keepFrom(fromSessions.length));
|
|
1467
|
+
const offered = result.findings.length;
|
|
1468
|
+
if (saved.length) {
|
|
1469
|
+
const n = saved.length;
|
|
1470
|
+
const what = n < offered ? `kept ${n} of the ${offered} things` : `learned ${n} thing${n === 1 ? "" : "s"}`;
|
|
1471
|
+
console.error(`✓ ${what} reviewers flagged on more than one PR, from the last ${result.prs} merged PRs here`);
|
|
1472
|
+
// saveReviewFindings keeps the findings' order.
|
|
1473
|
+
saved.forEach((note, i) => console.error(` for your team · flagged in review on ${kept[i]?.prs.length ?? 2} PRs: ${note.title}`));
|
|
1474
|
+
}
|
|
1475
|
+
else if (cancelled) {
|
|
1476
|
+
console.error(`· saved none of the ${offered} things reviewers flagged; ${cmd("julius init")} again asks again`);
|
|
1477
|
+
}
|
|
1478
|
+
else if (offered) {
|
|
1479
|
+
console.error(`· kept none of the ${offered} things reviewers flagged`);
|
|
1480
|
+
}
|
|
1481
|
+
else if (result.reason === "failed") {
|
|
1482
|
+
console.error(`· couldn't read PR reviews this time; ${cmd("julius init")} again tries again`);
|
|
1483
|
+
}
|
|
1484
|
+
learned.push(...saved);
|
|
1485
|
+
}
|
|
1486
|
+
learnedNow = learned.length > 0;
|
|
1487
|
+
if (learnedNow) {
|
|
1488
|
+
console.error("· Claude follows them from your next session");
|
|
1489
|
+
if (learned.some((s) => s.scope === "repo"))
|
|
1490
|
+
console.error(commitLines({}, teammatesOn(repo), "repo").uncommitted);
|
|
1491
|
+
}
|
|
1492
|
+
}
|
|
1493
|
+
if (!learnedNow) {
|
|
1494
|
+
const home = notesHome.get(repo);
|
|
1495
|
+
if (home) {
|
|
1496
|
+
const learnings = listNotes(repo, { branches: false }).filter((n) => n.scope === "repo");
|
|
1497
|
+
if (learnings.length === 0)
|
|
1498
|
+
console.error(`✓ learnings ${LEARNINGS_DIR}/ · sessions that take real digging leave one there, for your whole team`);
|
|
1499
|
+
else
|
|
1500
|
+
console.error(`✓ learnings ${learnings.length} in ${LEARNINGS_DIR}/, from ${new Set(learnings.map((n) => n.author || "someone")).size} ${new Set(learnings.map((n) => n.author)).size === 1 ? "person" : "people"}`);
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
if (!verbose) {
|
|
1504
|
+
// What there is to commit: the top-level entries the picked agents wrote.
|
|
1505
|
+
const tops = [];
|
|
1506
|
+
for (const w of selectedWrites(plan, ids)) {
|
|
1507
|
+
if (w.scope !== "repo")
|
|
1508
|
+
continue;
|
|
1509
|
+
const rel = shown(repo, w.path);
|
|
1510
|
+
// julius's Claude Code setup shares one file in .claude/; the rest there is personal.
|
|
1511
|
+
if (rel.startsWith(".claude/") && rel !== ".claude/settings.json")
|
|
1512
|
+
continue;
|
|
1513
|
+
const parts = rel.split("/");
|
|
1514
|
+
const top = rel === ".claude/settings.json" ? rel : parts.length > 1 ? `${parts[0]}/` : parts[0];
|
|
1515
|
+
if (!tops.includes(top))
|
|
1516
|
+
tops.push(top);
|
|
1517
|
+
}
|
|
1518
|
+
console.error(`· restart your agents so a new session picks up ${brand()}`);
|
|
1519
|
+
if (!tops.includes(".julius/"))
|
|
1520
|
+
tops.push(".julius/");
|
|
1521
|
+
// Only what git sees as new or changed: a teammate's init over committed files has nothing to commit.
|
|
1522
|
+
const changedTops = tops.filter((t) => {
|
|
1523
|
+
const r = spawnSync("git", ["status", "--porcelain", "--", t], { cwd: repo, encoding: "utf8" });
|
|
1524
|
+
return r.status !== 0 || r.stdout.trim().length > 0;
|
|
1525
|
+
});
|
|
1526
|
+
tops.splice(0, tops.length, ...changedTops);
|
|
1527
|
+
// Outside git there is nothing to commit to, and `git status` failing above
|
|
1528
|
+
// made every path look changed.
|
|
1529
|
+
if (!children.length && !isGitWorkTree(repo))
|
|
1530
|
+
console.error(NOT_GIT_LINE);
|
|
1531
|
+
else if (tops.length)
|
|
1532
|
+
console.error(`· commit ${tops.slice(0, 5).join(" and ")}${tops.length > 5 ? ` +${tops.length - 5} more` : ""} once — after that, teammates' Claude reads your learnings even before they install julius`);
|
|
1533
|
+
}
|
|
1534
|
+
// One epilogue for the whole run. A workspace parent holds no nodes of its
|
|
1535
|
+
// own, so the totals come from the children — the graph the user actually got.
|
|
1536
|
+
const globalDir = program.opts().dir;
|
|
1537
|
+
const graphs = (children.length ? children.map((c) => join(repo, c)) : [repo])
|
|
1538
|
+
.map((d) => loadGraphCached(contextDirFor(d, children.length ? undefined : globalDir)))
|
|
1539
|
+
.filter((g) => g !== null);
|
|
1540
|
+
if (verbose)
|
|
1541
|
+
console.error("\n" +
|
|
1542
|
+
formatInitEpilogue({
|
|
1543
|
+
graphBuilt: graphs.length > 0,
|
|
1544
|
+
nodes: graphs.reduce((n, g) => n + g.meta.nodeCount, 0),
|
|
1545
|
+
edges: graphs.reduce((n, g) => n + g.meta.edgeCount, 0),
|
|
1546
|
+
}));
|
|
1547
|
+
// Sorted so `claude,cursor` and `cursor,claude` aggregate as one value.
|
|
1548
|
+
track("init_completed", { agents: [...ids].sort().join(","), consent: consent === undefined ? "unasked" : String(consent) }, { repo });
|
|
1549
|
+
return { ids };
|
|
1550
|
+
}
|
|
1551
|
+
/** One repo's worth of `init` writes — the parent, then each workspace child. */
|
|
1552
|
+
function wireTarget(repo, ids, ctx) {
|
|
1553
|
+
const { home, cliPath, plan, wantClaude } = ctx;
|
|
1554
|
+
const quiet = ctx.quiet === true;
|
|
1555
|
+
const opts = quiet ? { ...ctx.opts, build: false } : ctx.opts;
|
|
1556
|
+
const report = { retracted: [], warnings: [] };
|
|
1557
|
+
// Every per-file line goes through here; in quiet mode only ⚠ lines survive.
|
|
1558
|
+
const say = (line) => {
|
|
1559
|
+
if (!quiet)
|
|
1560
|
+
console.error(line);
|
|
1561
|
+
else if (line.startsWith("⚠"))
|
|
1562
|
+
report.warnings.push(line);
|
|
1563
|
+
};
|
|
1564
|
+
const wantStatusline = statuslineWanted({ statusline: opts.statusline });
|
|
1565
|
+
// Converge, don't just add. init writes the selected hosts; without this it
|
|
1566
|
+
// never touches the rest, so a repo wired by an older version (or by the same
|
|
1567
|
+
// version with different --agents) keeps that run's files forever — and
|
|
1568
|
+
// `reconcileWiring` then keeps them *up to date*, which is worse than stale.
|
|
1569
|
+
// Retract every host NOT being written now; `exclude` spares the ones about to
|
|
1570
|
+
// be rewritten, and the graph cache is kept (init is one step from using it).
|
|
1571
|
+
const retracted = changed(runRetract(repo, { home, apply: true, global: opts.global, cache: false, exclude: ids })).filter((r) => r.action !== "skipped-unparseable");
|
|
1572
|
+
for (const r of retracted)
|
|
1573
|
+
say(`- removed ${r.path} (${r.what}) — agent not selected`);
|
|
1574
|
+
report.retracted = [...new Set(retracted.map((r) => r.hostId))];
|
|
1575
|
+
if (wantClaude) {
|
|
1576
|
+
// `global`/`home` are threaded through alongside `statusline`: the claude layer
|
|
1577
|
+
// writes under `~/.claude` now (hosts/claude-global.ts), so --no-global has to
|
|
1578
|
+
// reach it or the flag would silently mean "no out-of-repo writes, except three".
|
|
1579
|
+
const res = runInit(repo, { build: opts.build, cliPath, statusline: wantStatusline, global: opts.global, home, brand: brand() });
|
|
1580
|
+
say(`✓ wrote ${res.settingsPath}`);
|
|
1581
|
+
for (const s of res.shims)
|
|
1582
|
+
say(`✓ wrote ${s}`);
|
|
1583
|
+
if (res.skill)
|
|
1584
|
+
say(`✓ wrote ${res.skill}`);
|
|
1585
|
+
if (!res.mcp) {
|
|
1586
|
+
// julius registers no server for Claude Code: the hooks and the `julius` command cover it.
|
|
1587
|
+
}
|
|
1588
|
+
else if (res.mcp.action === "skipped-unparseable")
|
|
1589
|
+
say(`⚠ .mcp.json: ${res.mcp.path} left unchanged (not valid JSON) — add the julius server manually`);
|
|
1590
|
+
else if (res.mcp.action === "unchanged")
|
|
1591
|
+
say(`· mcp claude: ${res.mcp.path} (already registered)`);
|
|
1592
|
+
else
|
|
1593
|
+
say(`✓ mcp claude: ${res.mcp.path} (${res.mcp.action}) — restart Claude Code to load the julius MCP server`);
|
|
1594
|
+
say(res.built ? `✓ built the graph (${cmd("julius build")})` : "· skipped graph build");
|
|
1595
|
+
if (!wantStatusline)
|
|
1596
|
+
say("· skipped Claude Code statusLine (--no-statusline)");
|
|
1597
|
+
for (const w of res.warnings)
|
|
1598
|
+
say(`⚠ ${w}`);
|
|
1599
|
+
}
|
|
1600
|
+
// `ids` is already resolved, so hosts init is always driven by an explicit
|
|
1601
|
+
// list — never by its own detection fallback.
|
|
1602
|
+
const others = ids.filter((id) => id !== "claude");
|
|
1603
|
+
if (others.length > 0) {
|
|
1604
|
+
const r = runHostsInit(repo, {
|
|
1605
|
+
agents: others,
|
|
1606
|
+
home,
|
|
1607
|
+
mcp: opts.mcp,
|
|
1608
|
+
hooks: opts.hooks,
|
|
1609
|
+
global: opts.global,
|
|
1610
|
+
brand: brand(),
|
|
1611
|
+
});
|
|
1612
|
+
for (const w of r.written)
|
|
1613
|
+
say(`✓ ${w.id}: ${w.path} (${w.action})`);
|
|
1614
|
+
for (const m of r.mcp)
|
|
1615
|
+
say(`✓ mcp ${m.id}: ${m.path} (${m.action})`);
|
|
1616
|
+
for (const h of r.hooks)
|
|
1617
|
+
say(`✓ hook ${h.id}: ${h.path} (${h.action})`);
|
|
1618
|
+
// Only worth saying when there was actually something out-of-repo to skip.
|
|
1619
|
+
if (opts.global === false && selectedWrites(plan, ids).some((w) => w.scope === "global"))
|
|
1620
|
+
say("· skipped out-of-repo writes (--no-global)");
|
|
1621
|
+
}
|
|
1622
|
+
// Record WHICH julius wrote this repo's agent files, and under which flags.
|
|
1623
|
+
// Every entry point compares this against the running binary and re-writes
|
|
1624
|
+
// them on a mismatch, so an `npm i -g` upgrade reaches the hooks/skill/rules
|
|
1625
|
+
// too — not just the binary. The flags ride along so a refresh replays the
|
|
1626
|
+
// user's choices (notably --no-global) instead of overriding them.
|
|
1627
|
+
writeStamp(repo, currentVersion, ids, {
|
|
1628
|
+
global: opts.global !== false,
|
|
1629
|
+
mcp: opts.mcp !== false,
|
|
1630
|
+
hooks: opts.hooks !== false,
|
|
1631
|
+
statusline: wantStatusline,
|
|
1632
|
+
});
|
|
1633
|
+
// Every host's wiring points at julius/, so the graph is built whatever was
|
|
1634
|
+
// selected — not only when Claude Code is in the list (runInit does its own).
|
|
1635
|
+
if (!wantClaude) {
|
|
1636
|
+
if (!quiet)
|
|
1637
|
+
say(buildGraphIfMissing(repo, { build: opts.build, cliPath })
|
|
1638
|
+
? `✓ built the graph (${cmd("julius build")})`
|
|
1639
|
+
: "· skipped graph build");
|
|
1640
|
+
}
|
|
1641
|
+
return report;
|
|
1642
|
+
}
|
|
1643
|
+
/** Group a retraction report by host, so the output reads as "what leaves each agent". */
|
|
1644
|
+
function formatRetractions(rs, apply) {
|
|
1645
|
+
const hit = changed(rs);
|
|
1646
|
+
if (hit.length === 0)
|
|
1647
|
+
return "· nothing to remove — no julius wiring found here";
|
|
1648
|
+
const verb = apply ? "removed" : "would remove";
|
|
1649
|
+
const lines = [];
|
|
1650
|
+
const byHost = new Map();
|
|
1651
|
+
for (const r of hit) {
|
|
1652
|
+
const k = byHost.get(r.hostId) ?? [];
|
|
1653
|
+
k.push(r);
|
|
1654
|
+
byHost.set(r.hostId, k);
|
|
1655
|
+
}
|
|
1656
|
+
for (const [host, items] of byHost) {
|
|
1657
|
+
lines.push(`\n${host}:`);
|
|
1658
|
+
for (const r of items) {
|
|
1659
|
+
const mark = r.action === "skipped-unparseable"
|
|
1660
|
+
? "⚠"
|
|
1661
|
+
: r.action === "deleted"
|
|
1662
|
+
? "-"
|
|
1663
|
+
: "~";
|
|
1664
|
+
const note = r.action === "skipped-unparseable"
|
|
1665
|
+
? " — not valid JSON, left untouched (remove the julius entry by hand)"
|
|
1666
|
+
: r.action === "deleted"
|
|
1667
|
+
? ` (${r.what} — deleted)`
|
|
1668
|
+
: ` (${r.what})`;
|
|
1669
|
+
const scope = r.scope === "global" ? " [machine-wide]" : "";
|
|
1670
|
+
lines.push(` ${mark} ${verb}: ${r.path}${scope}${note}`);
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1673
|
+
return lines.join("\n").replace(/^\n/, "");
|
|
1674
|
+
}
|
|
1675
|
+
grouped(program.command("install"), GROUP.setup)
|
|
1676
|
+
.description("Install compact global MCP for detected Claude Code/Cursor/Codex/Grok configuration files")
|
|
1677
|
+
.option("--hosts <ids>", "comma-separated claude,cursor,codex,grok (default: detected config directories)")
|
|
1678
|
+
.option("--home <path>", "home directory override", homedir())
|
|
1679
|
+
.option("--dry-run", "show planned writes without changing files")
|
|
1680
|
+
.option("--migrate-trail <repo>", "copy .trail/learnings and replace verified legacy MCP entries")
|
|
1681
|
+
.action((opts) => {
|
|
1682
|
+
try {
|
|
1683
|
+
console.log(installGlobal({ ...opts, hosts: opts.hosts?.split(",") }).join("\n"));
|
|
1684
|
+
}
|
|
1685
|
+
catch (error) {
|
|
1686
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1687
|
+
process.exitCode = 1;
|
|
1688
|
+
}
|
|
1689
|
+
});
|
|
1690
|
+
grouped(program.command("uninstall"), GROUP.setup)
|
|
1691
|
+
.description(`Remove every file and config entry ${"julius"} has written to this repo (the inverse of init)`)
|
|
1692
|
+
.argument("[dir]", "target repo directory", ".")
|
|
1693
|
+
.option("-y, --yes", "actually remove (without this, prints what it would remove and exits)")
|
|
1694
|
+
.option("--global", "undo the transactional global MCP install; preserve unrelated configuration")
|
|
1695
|
+
.option("--home <path>", "home directory override for --global", homedir())
|
|
1696
|
+
.option("--dry-run", "preview --global uninstall")
|
|
1697
|
+
.option("--keep-cache", "keep julius/ and the .gitignore entries — wiring only")
|
|
1698
|
+
.option("--no-global", "leave out-of-repo files alone (~/.codex, ~/.gemini)")
|
|
1699
|
+
.action((dir, opts) => {
|
|
1700
|
+
if (opts.global === true) {
|
|
1701
|
+
try {
|
|
1702
|
+
console.log(uninstallGlobal(opts).join("\n"));
|
|
1703
|
+
}
|
|
1704
|
+
catch (error) {
|
|
1705
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
1706
|
+
process.exitCode = 1;
|
|
1707
|
+
}
|
|
1708
|
+
return;
|
|
1709
|
+
}
|
|
1710
|
+
const repo = resolve(dir);
|
|
1711
|
+
const home = homedir();
|
|
1712
|
+
const common = { home, global: opts.global, cache: opts.keepCache ? false : true };
|
|
1713
|
+
if (!opts.yes) {
|
|
1714
|
+
console.error(formatRetractions(planRetract(repo, common), false));
|
|
1715
|
+
console.error("\nDry run — nothing was touched. Re-run with -y to remove.");
|
|
1716
|
+
if (opts.global !== false)
|
|
1717
|
+
console.error("Entries marked [machine-wide] affect every project; --no-global skips them.");
|
|
1718
|
+
return;
|
|
1719
|
+
}
|
|
1720
|
+
const done = runRetract(repo, { ...common, apply: true });
|
|
1721
|
+
console.error(formatRetractions(done, true));
|
|
1722
|
+
const bad = changed(done).filter((r) => r.action === "skipped-unparseable");
|
|
1723
|
+
console.error(bad.length
|
|
1724
|
+
? `\n⚠ ${bad.length} file(s) could not be parsed and were left as-is — see above.`
|
|
1725
|
+
: `\n✓ ${brand()} fully removed. \`${cmd("julius init")}\` re-wires from scratch.`);
|
|
1726
|
+
});
|
|
1727
|
+
/* -------------------------------------------------------------------------- */
|
|
1728
|
+
/* julius login · logout · workspace */
|
|
1729
|
+
/* -------------------------------------------------------------------------- */
|
|
1730
|
+
/**
|
|
1731
|
+
* `julius login`: connect this machine to a Julius workspace by hand. Normally
|
|
1732
|
+
* nobody runs it: Claude offers the same link once there's a learning to
|
|
1733
|
+
* share. Prints the link, opens it, and waits for the person to sign in and
|
|
1734
|
+
* pick repos, then uploads those repos' learnings.
|
|
1735
|
+
*/
|
|
1736
|
+
function loginCommand(name = "login") {
|
|
1737
|
+
return new Command(name)
|
|
1738
|
+
.description("Connect this machine to a Julius workspace: sign in, pick the repos it gets, invite your team")
|
|
1739
|
+
.argument("[dir]", "the repo you're in, ticked first in the picker", ".")
|
|
1740
|
+
.option("--server <url>", "a self-hosted Julius, e.g. https://julius.acme.internal (requires JULIUS_URL; no hosted service is configured)")
|
|
1741
|
+
.action(async (dir, opts) => {
|
|
1742
|
+
const repo = resolve(dir);
|
|
1743
|
+
const server = opts.server?.trim().replace(/\/+$/, "");
|
|
1744
|
+
if (server) {
|
|
1745
|
+
if (!/^https?:\/\//.test(server)) {
|
|
1746
|
+
console.error(`✗ --server takes a URL, like https://julius.acme.internal`);
|
|
1747
|
+
process.exitCode = 1;
|
|
1748
|
+
return;
|
|
1749
|
+
}
|
|
1750
|
+
process.env.JULIUS_URL = server;
|
|
1751
|
+
}
|
|
1752
|
+
const cloud = readCloud();
|
|
1753
|
+
if (cloud) {
|
|
1754
|
+
console.error(`✓ already connected to workspace ${cloud.workspace.name} · ${cloud.workspace.url}`);
|
|
1755
|
+
return;
|
|
1756
|
+
}
|
|
1757
|
+
rememberRepo(repo);
|
|
1758
|
+
const url = loginLink(repo);
|
|
1759
|
+
console.error(`· sign in and pick the repos your workspace gets:\n ${url}`);
|
|
1760
|
+
if (process.stdout.isTTY)
|
|
1761
|
+
openBrowser(url);
|
|
1762
|
+
console.error("· waiting for you to finish in the browser (ctrl-c stops; Claude picks it up later too)");
|
|
1763
|
+
const got = await waitForConnect({ waitMs: 10 * 60 * 1000 });
|
|
1764
|
+
if (got && "cloud" in got)
|
|
1765
|
+
printLines(cloudLines(repo, { command: "note", agent: false }));
|
|
1766
|
+
else if (got && "error" in got) {
|
|
1767
|
+
console.error(`✗ ${got.error} · run ${cmd("julius login")} again for a new link`);
|
|
1768
|
+
process.exitCode = 1;
|
|
1769
|
+
}
|
|
1770
|
+
else
|
|
1771
|
+
console.error(`· not connected yet · the link stays good for a day`);
|
|
1772
|
+
});
|
|
1773
|
+
}
|
|
1774
|
+
function logoutCommand(name = "logout") {
|
|
1775
|
+
return new Command(name)
|
|
1776
|
+
.description("Disconnect this machine from its Julius workspace (learnings stay in your repos)")
|
|
1777
|
+
.action(() => {
|
|
1778
|
+
const cloud = readCloud();
|
|
1779
|
+
clearPending();
|
|
1780
|
+
if (!clearCloud()) {
|
|
1781
|
+
console.error("· not connected to a workspace");
|
|
1782
|
+
return;
|
|
1783
|
+
}
|
|
1784
|
+
console.error(`✓ disconnected from workspace ${cloud?.workspace.name ?? ""} · learnings stay in your repos' .julius/`.replace(" ", " "));
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
/** The repo at `repo`, as the workspace names it. */
|
|
1788
|
+
function workspaceRepo(repo) {
|
|
1789
|
+
const place = repoPlace(repo);
|
|
1790
|
+
return { key: place.key, name: repoName(place.key, place.checkout), checkout: place.checkout, git: place.git };
|
|
1791
|
+
}
|
|
1792
|
+
function workspaceCommand(name = "workspace") {
|
|
1793
|
+
const ws = new Command(name)
|
|
1794
|
+
.description("Your Julius workspace: its repos, the team page and the invite link")
|
|
1795
|
+
.argument("[dir]", "repository root", ".")
|
|
1796
|
+
.option("--json", "output as JSON")
|
|
1797
|
+
.action(async (dir, opts) => {
|
|
1798
|
+
const repo = resolve(dir);
|
|
1799
|
+
const cloud = readCloud();
|
|
1800
|
+
if (!cloud) {
|
|
1801
|
+
console.log("· not connected to a workspace");
|
|
1802
|
+
console.log(`· Claude offers a link once this repo has learnings, or run ${cmd("julius login")}`);
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
const me = await fetchMe(cloud);
|
|
1806
|
+
if (isError(me)) {
|
|
1807
|
+
console.error(`✗ ${me.error}`);
|
|
1808
|
+
process.exitCode = 1;
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
// What the workspace has now, for every command that reads cloud.json.
|
|
1812
|
+
writeCloud({ ...cloud, workspace: me.workspace, repos: me.repos.map((r) => r.key) });
|
|
1813
|
+
if (opts.json) {
|
|
1814
|
+
console.log(JSON.stringify(me, null, 2));
|
|
1815
|
+
return;
|
|
1816
|
+
}
|
|
1817
|
+
console.log(`${me.workspace.name} · ${me.workspace.url}`);
|
|
1818
|
+
console.log(`invite ${me.workspace.invite_url}`);
|
|
1819
|
+
console.log("");
|
|
1820
|
+
const here = workspaceRepo(repo);
|
|
1821
|
+
const width = Math.max(...me.repos.map((r) => r.name.length), here.name.length) + 3;
|
|
1822
|
+
for (const r of me.repos) {
|
|
1823
|
+
const by = r.added_by ? ` · added by ${r.added_by}` : "";
|
|
1824
|
+
console.log(` ✓ ${r.name.padEnd(width)}${r.learnings} learning${r.learnings === 1 ? "" : "s"}${by}`);
|
|
1825
|
+
}
|
|
1826
|
+
if (here.git && !me.repos.some((r) => r.key === here.key)) {
|
|
1827
|
+
console.log(` · ${here.name.padEnd(width)}not in the workspace · ${cmd("julius workspace add")} shares its learnings`);
|
|
1828
|
+
}
|
|
1829
|
+
});
|
|
1830
|
+
ws.command("add")
|
|
1831
|
+
.description("Add this repo to your workspace and share its learnings")
|
|
1832
|
+
.argument("[dir]", "repository root", ".")
|
|
1833
|
+
.action(async (dir) => {
|
|
1834
|
+
const repo = resolve(dir);
|
|
1835
|
+
const cloud = readCloud();
|
|
1836
|
+
if (!cloud) {
|
|
1837
|
+
console.error(`✗ not connected to a workspace · run ${cmd("julius login")}`);
|
|
1838
|
+
process.exitCode = 1;
|
|
1839
|
+
return;
|
|
1840
|
+
}
|
|
1841
|
+
const here = workspaceRepo(repo);
|
|
1842
|
+
if (!here.git) {
|
|
1843
|
+
console.error("✗ not a git repository");
|
|
1844
|
+
process.exitCode = 1;
|
|
1845
|
+
return;
|
|
1846
|
+
}
|
|
1847
|
+
const added = await addRepo(cloud, { key: here.key, name: here.name });
|
|
1848
|
+
if (isError(added)) {
|
|
1849
|
+
console.error(`✗ ${added.error}`);
|
|
1850
|
+
process.exitCode = 1;
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
const next = { ...cloud, repos: added.repos.map((r) => r.key) };
|
|
1854
|
+
writeCloud(next);
|
|
1855
|
+
rememberRepo(repo);
|
|
1856
|
+
const res = await syncRepo(here.checkout, next);
|
|
1857
|
+
if (isError(res)) {
|
|
1858
|
+
console.error(`✓ added ${here.name} to ${cloud.workspace.name} · its learnings go up in the background (${res.error})`);
|
|
1859
|
+
return;
|
|
1860
|
+
}
|
|
1861
|
+
console.error(`✓ added ${here.name} to ${cloud.workspace.name} · shared ${res.learnings} learning${res.learnings === 1 ? "" : "s"}`);
|
|
1862
|
+
console.error(`· ${cloud.workspace.url}`);
|
|
1863
|
+
});
|
|
1864
|
+
return ws;
|
|
1865
|
+
}
|
|
1866
|
+
/* -------------------------------------------------------------------------- */
|
|
1867
|
+
/* julius team · julius check */
|
|
1868
|
+
/* -------------------------------------------------------------------------- */
|
|
1869
|
+
/** Fold a long line at `width`, indenting what wraps. */
|
|
1870
|
+
function wrap(text, width, indent) {
|
|
1871
|
+
const out = [];
|
|
1872
|
+
let line = "";
|
|
1873
|
+
for (const word of text.split(/\s+/)) {
|
|
1874
|
+
if (line && line.length + 1 + word.length > width) {
|
|
1875
|
+
out.push(line);
|
|
1876
|
+
line = indent + word;
|
|
1877
|
+
}
|
|
1878
|
+
else
|
|
1879
|
+
line = line ? `${line} ${word}` : word;
|
|
1880
|
+
}
|
|
1881
|
+
if (line)
|
|
1882
|
+
out.push(line);
|
|
1883
|
+
return out;
|
|
1884
|
+
}
|
|
1885
|
+
function teamCommand(name = "team") {
|
|
1886
|
+
return new Command(name)
|
|
1887
|
+
.description("What the team learned this week, who's working on what, and where work overlaps")
|
|
1888
|
+
.argument("[dir]", "repository root", ".")
|
|
1889
|
+
.option("--days <n>", "how far back to look", "7")
|
|
1890
|
+
.option("--json", "output as JSON")
|
|
1891
|
+
.action(async (dir, opts) => {
|
|
1892
|
+
const repo = resolve(dir);
|
|
1893
|
+
const days = Math.max(1, Math.min(90, Number(opts.days) || 7));
|
|
1894
|
+
const cloud = readCloud();
|
|
1895
|
+
if (!cloud) {
|
|
1896
|
+
localTeam(repo, days, opts.json === true);
|
|
1897
|
+
return;
|
|
1898
|
+
}
|
|
1899
|
+
maybeSyncInBackground(repo);
|
|
1900
|
+
const here = workspaceRepo(repo);
|
|
1901
|
+
const t = await fetchTeam(cloud, { repo: cloud.repos.includes(here.key) ? here.key : undefined, days });
|
|
1902
|
+
if (isError(t)) {
|
|
1903
|
+
console.error(`✗ ${t.error}`);
|
|
1904
|
+
process.exitCode = 1;
|
|
1905
|
+
return;
|
|
1906
|
+
}
|
|
1907
|
+
if (opts.json) {
|
|
1908
|
+
console.log(JSON.stringify(t, null, 2));
|
|
1909
|
+
return;
|
|
1910
|
+
}
|
|
1911
|
+
const period = days === 7 ? "this week" : `the last ${days} days`;
|
|
1912
|
+
console.log(`${period} in ${t.repo || t.workspace}`);
|
|
1913
|
+
console.log(`${t.people} ${t.people === 1 ? "person" : "people"} · ${t.sessions} session${t.sessions === 1 ? "" : "s"} · ` +
|
|
1914
|
+
`${t.new_learnings} new learning${t.new_learnings === 1 ? "" : "s"} · reused ${t.reused}×`);
|
|
1915
|
+
if (t.members.length) {
|
|
1916
|
+
console.log("");
|
|
1917
|
+
const nameW = Math.max(...t.members.map((m) => m.name.length)) + 3;
|
|
1918
|
+
const topicW = Math.min(36, Math.max(...t.members.map((m) => m.topics.join(", ").length)) + 3);
|
|
1919
|
+
for (const m of t.members) {
|
|
1920
|
+
const learnings = m.learnings ? `${m.learnings} learning${m.learnings === 1 ? "" : "s"}` : "";
|
|
1921
|
+
const reused = m.reused ? ` reused ${m.reused}×` : "";
|
|
1922
|
+
console.log(` ${m.name.padEnd(nameW)}${m.topics.join(", ").padEnd(topicW)}${learnings.padEnd(12)}${reused}`.trimEnd());
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
const overlaps = [...t.overlaps.map((o) => o.text), ...branchOverlapTexts(repo)];
|
|
1926
|
+
if (overlaps.length) {
|
|
1927
|
+
console.log("\noverlap");
|
|
1928
|
+
for (const o of overlaps)
|
|
1929
|
+
for (const [i, l] of wrap(o, 66, " ").entries())
|
|
1930
|
+
console.log(i === 0 ? ` ● ${l}` : l);
|
|
1931
|
+
}
|
|
1932
|
+
if (t.url)
|
|
1933
|
+
console.log(`\n team page: ${t.url}`);
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
/** Pairs of teammates' pushed branches that change the same files, from this clone's branch cache. */
|
|
1937
|
+
function branchOverlapTexts(repo, now = Date.now()) {
|
|
1938
|
+
const branches = readBranchCache(repo)?.branches ?? [];
|
|
1939
|
+
const out = [];
|
|
1940
|
+
for (let i = 0; i < branches.length; i++) {
|
|
1941
|
+
for (let j = i + 1; j < branches.length; j++) {
|
|
1942
|
+
const a = branches[i];
|
|
1943
|
+
const b = branches[j];
|
|
1944
|
+
if (!a.author || !b.author || a.author === b.author)
|
|
1945
|
+
continue;
|
|
1946
|
+
const shared = a.files.filter((f) => !f.startsWith(".julius/") && b.files.includes(f));
|
|
1947
|
+
if (!shared.length)
|
|
1948
|
+
continue;
|
|
1949
|
+
const files = shared.length <= 2 ? shared.join(" and ") : `${shared.slice(0, 2).join(", ")} and ${shared.length - 2} more`;
|
|
1950
|
+
out.push(`${a.author}'s ${a.ref.replace(/^origin\//, "")} (pushed ${pushedWhen(a.at, now)}) and ${b.author}'s ${b.ref.replace(/^origin\//, "")} (pushed ${pushedWhen(b.at, now)}) both change ${files}`);
|
|
1951
|
+
if (out.length >= 5)
|
|
1952
|
+
return out;
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
return out;
|
|
1956
|
+
}
|
|
1957
|
+
/**
|
|
1958
|
+
* `julius team` before this machine is connected: what this clone can see on
|
|
1959
|
+
* its own. Who wrote which learnings lately, and where teammates' pushed
|
|
1960
|
+
* branches overlap. Reuse and the team page need the workspace.
|
|
1961
|
+
*/
|
|
1962
|
+
function localTeam(repo, days, json) {
|
|
1963
|
+
maybeRefreshBranches(repo);
|
|
1964
|
+
const since = new Date(Date.now() - days * 24 * 60 * 60 * 1000).toISOString().slice(0, 10);
|
|
1965
|
+
const recent = listNotes(repo).filter((n) => n.scope === "repo" && n.date >= since);
|
|
1966
|
+
const byAuthor = new Map();
|
|
1967
|
+
for (const n of recent)
|
|
1968
|
+
byAuthor.set(n.author || "someone", [...(byAuthor.get(n.author || "someone") ?? []), n]);
|
|
1969
|
+
const overlaps = branchOverlapTexts(repo);
|
|
1970
|
+
if (json) {
|
|
1971
|
+
console.log(JSON.stringify({ days, learnings: recent.length, members: [...byAuthor].map(([name, ns]) => ({ name, learnings: ns.length, titles: ns.map((n) => n.title) })), overlaps }, null, 2));
|
|
1972
|
+
return;
|
|
1973
|
+
}
|
|
1974
|
+
const here = workspaceRepo(repo);
|
|
1975
|
+
console.log(`${days === 7 ? "this week" : `the last ${days} days`} in ${here.name} · from this clone`);
|
|
1976
|
+
console.log(`${byAuthor.size} ${byAuthor.size === 1 ? "person" : "people"} · ${recent.length} new learning${recent.length === 1 ? "" : "s"}`);
|
|
1977
|
+
if (byAuthor.size) {
|
|
1978
|
+
console.log("");
|
|
1979
|
+
const nameW = Math.max(...[...byAuthor.keys()].map((k) => k.length)) + 3;
|
|
1980
|
+
for (const [name, ns] of byAuthor) {
|
|
1981
|
+
const latest = ns[0].title.length > 40 ? `${ns[0].title.slice(0, 39)}…` : ns[0].title;
|
|
1982
|
+
console.log(` ${name.padEnd(nameW)}${latest.padEnd(42)}${ns.length} learning${ns.length === 1 ? "" : "s"}`);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
if (overlaps.length) {
|
|
1986
|
+
console.log("\noverlap");
|
|
1987
|
+
for (const o of overlaps)
|
|
1988
|
+
for (const [i, l] of wrap(o, 66, " ").entries())
|
|
1989
|
+
console.log(i === 0 ? ` ● ${l}` : l);
|
|
1990
|
+
}
|
|
1991
|
+
console.log("\n· reuse and the team page, across your repos, are in a Julius workspace");
|
|
1992
|
+
printLines(cloudLines(repo, { command: "check" }));
|
|
1993
|
+
}
|
|
1994
|
+
function teamCheckCommand(name = "check") {
|
|
1995
|
+
return new Command(name)
|
|
1996
|
+
.description("Check your branch's diff against everything the team has learned: the repo's learnings, yours and your skills")
|
|
1997
|
+
.argument("[dir]", "repository root", ".")
|
|
1998
|
+
.option("--base <ref>", "compare against where the branch left this ref (default: origin's default branch)")
|
|
1999
|
+
.option("--json", "output as JSON")
|
|
2000
|
+
.action(async (dir, opts) => {
|
|
2001
|
+
await runTeamCheck(resolve(dir), opts);
|
|
2002
|
+
});
|
|
2003
|
+
}
|
|
2004
|
+
/** A unified diff without the sections for `.julius/` files: a learning is never the change being checked. */
|
|
2005
|
+
function withoutJuliusFiles(diff) {
|
|
2006
|
+
return diff
|
|
2007
|
+
.split(/(?=^diff --git )/m)
|
|
2008
|
+
.filter((part) => !/^diff --git a\/\.julius\//.test(part))
|
|
2009
|
+
.join("");
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* `julius check`, on this machine: the branch's diff against the learnings in
|
|
2013
|
+
* the repo's `.julius/` (teammates' pushed branches included), this person's
|
|
2014
|
+
* own, and the repo's skills. No sign-in, no server. Exits 1 on a conflict.
|
|
2015
|
+
*/
|
|
2016
|
+
async function runTeamCheck(repo, opts) {
|
|
2017
|
+
const d = branchDiff(repo, opts.base);
|
|
2018
|
+
if (!d) {
|
|
2019
|
+
console.error("✗ not a git repository");
|
|
2020
|
+
process.exitCode = 1;
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
const files = d.files.filter((f) => !f.startsWith(".julius/"));
|
|
2024
|
+
const me = noteAuthor(repo);
|
|
2025
|
+
// Learnings this branch changed, as they were before it: the check reads those,
|
|
2026
|
+
// and changing a teammate's is a finding of its own.
|
|
2027
|
+
const atBase = learningsAtBase(repo, d.from, d.files);
|
|
2028
|
+
const edits = teammateEdits(repo, atBase, me);
|
|
2029
|
+
if (files.length === 0 && edits.length === 0) {
|
|
2030
|
+
console.log(`· nothing to check: no changes against ${d.base}`);
|
|
2031
|
+
return;
|
|
2032
|
+
}
|
|
2033
|
+
maybeRefreshBranches(repo);
|
|
2034
|
+
if (d.truncated)
|
|
2035
|
+
console.error("⚠ the diff is over 400 KB; only the first 400 KB is checked");
|
|
2036
|
+
const r = checkLocally({ diff: withoutJuliusFiles(d.diff), files, notes: withBaseLearnings(liveLearnings(listNotes(repo)), atBase), skills: listSkills(repo), asker: me });
|
|
2037
|
+
r.findings.unshift(...edits);
|
|
2038
|
+
const sources = r.findings.map((f) => f.source).filter((s) => s.path);
|
|
2039
|
+
recordActivity({
|
|
2040
|
+
repo: repoPlace(repo).key,
|
|
2041
|
+
kind: "check",
|
|
2042
|
+
asker: me,
|
|
2043
|
+
session: sessionKey(repo) ?? `${me}-${new Date().toISOString().slice(0, 10)}`,
|
|
2044
|
+
query: "",
|
|
2045
|
+
files,
|
|
2046
|
+
shown_paths: [...new Set(sources.map((s) => s.path.slice(s.path.lastIndexOf("/") + 1)))],
|
|
2047
|
+
shown_authors: [...new Set(sources.map((s) => s.author ?? ""))],
|
|
2048
|
+
at: new Date().toISOString(),
|
|
2049
|
+
});
|
|
2050
|
+
const overlaps = overlapsWith(repo, files, me).slice(0, 3);
|
|
2051
|
+
if (opts.json) {
|
|
2052
|
+
console.log(JSON.stringify({ ...r, overlaps }, null, 2));
|
|
2053
|
+
}
|
|
2054
|
+
else {
|
|
2055
|
+
printCheck(r);
|
|
2056
|
+
if (overlaps.length)
|
|
2057
|
+
console.log(`\n${overlaps.map((o) => formatOverlap(o)).join("\n")}`);
|
|
2058
|
+
printLines(cloudLines(repo, { command: "check" }));
|
|
2059
|
+
}
|
|
2060
|
+
maybeSyncInBackground(repo);
|
|
2061
|
+
if (r.findings.some((f) => f.verdict === "conflict"))
|
|
2062
|
+
process.exitCode = 1;
|
|
2063
|
+
}
|
|
2064
|
+
function printCheck(r) {
|
|
2065
|
+
console.log(`checking ${r.files} changed file${r.files === 1 ? "" : "s"} against ${r.notes} learning${r.notes === 1 ? "" : "s"} and ${r.skills} skill${r.skills === 1 ? "" : "s"}\n`);
|
|
2066
|
+
const conflicts = r.findings.filter((f) => f.verdict === "conflict");
|
|
2067
|
+
for (const f of [...conflicts, ...r.findings.filter((x) => x.verdict !== "conflict")]) {
|
|
2068
|
+
const mark = f.verdict === "conflict" ? "✗" : "✓";
|
|
2069
|
+
console.log(`${mark} ${f.file}${f.line ? `:${f.line}` : ""}`);
|
|
2070
|
+
console.log(` ${f.summary}`);
|
|
2071
|
+
const s = f.source;
|
|
2072
|
+
if (f.verdict === "conflict" && s.quote) {
|
|
2073
|
+
const who = [s.author, s.date ? shortDate(s.date) : ""].filter(Boolean).join(" · ");
|
|
2074
|
+
for (const l of wrap(`${who ? `${who}: ` : ""}${s.quote}`, 70, " "))
|
|
2075
|
+
console.log(` ${l.trimStart()}`);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
if (r.findings.length === 0)
|
|
2079
|
+
console.log("✓ nothing the team has learned bears on this change");
|
|
2080
|
+
console.log("");
|
|
2081
|
+
console.log(conflicts.length
|
|
2082
|
+
? `· ${conflicts.length} conflict${conflicts.length === 1 ? "" : "s"} · fix ${conflicts.length === 1 ? "it" : "them"}, or say why in the commit message or PR description`
|
|
2083
|
+
: "· no conflicts");
|
|
2084
|
+
}
|
|
2085
|
+
/** Tokens saved by this repo's agent sessions touched in the last 7 days. */
|
|
2086
|
+
function savedThisWeek(repo, now = Date.now()) {
|
|
2087
|
+
const since = now - 7 * 24 * 60 * 60 * 1000;
|
|
2088
|
+
let total = 0;
|
|
2089
|
+
for (const id of listSessionIds(repo)) {
|
|
2090
|
+
try {
|
|
2091
|
+
if (statSync(join(sessionDir(repo), `${id}.json`)).mtimeMs < since)
|
|
2092
|
+
continue;
|
|
2093
|
+
}
|
|
2094
|
+
catch {
|
|
2095
|
+
continue;
|
|
2096
|
+
}
|
|
2097
|
+
total += readSession(repo, id).savedTokens ?? 0;
|
|
2098
|
+
}
|
|
2099
|
+
return total;
|
|
2100
|
+
}
|
|
2101
|
+
/** 212345 → `212k`, 1_250_000 → `1.3M`. */
|
|
2102
|
+
function shortCount(n) {
|
|
2103
|
+
if (n >= 1_000_000)
|
|
2104
|
+
return `${(n / 1_000_000).toFixed(1)}M`;
|
|
2105
|
+
if (n >= 1_000)
|
|
2106
|
+
return `${Math.round(n / 1_000)}k`;
|
|
2107
|
+
return String(n);
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* `julius status`: what was `julius stats`, on one
|
|
2111
|
+
* screen. The code map and whether it matches the code, the learnings for
|
|
2112
|
+
* this repo, the workspace, and what the agents saved this week.
|
|
2113
|
+
*/
|
|
2114
|
+
function statusCommand(name = "status") {
|
|
2115
|
+
return new Command(name)
|
|
2116
|
+
.description("Code map, learnings and tokens saved, on one screen")
|
|
2117
|
+
.argument(...DIR_ARG)
|
|
2118
|
+
.option("--json", "machine-readable output")
|
|
2119
|
+
.action(async (dirArg, opts) => {
|
|
2120
|
+
const repo = queryRoot(dirArg);
|
|
2121
|
+
const graph = loadGraphCached(contextDirFor(repo, program.opts().dir));
|
|
2122
|
+
const g = graph ? await engineFrom().checkGraph(repo) : null;
|
|
2123
|
+
const fresh = g && !g.missing ? g.ok : null;
|
|
2124
|
+
const kept = keepsNotes(repo);
|
|
2125
|
+
const all = kept ? listNotes(repo) : [];
|
|
2126
|
+
const inRepo = all.filter((n) => n.scope === "repo" && !n.ref).length;
|
|
2127
|
+
const onBranches = all.filter((n) => n.ref).length;
|
|
2128
|
+
const personal = all.filter((n) => n.scope === "personal").length;
|
|
2129
|
+
const cloud = readCloud();
|
|
2130
|
+
const shared = cloud ? inWorkspace(repo, cloud) : false;
|
|
2131
|
+
const saved = savedThisWeek(repo);
|
|
2132
|
+
if (opts.json) {
|
|
2133
|
+
console.log(JSON.stringify({
|
|
2134
|
+
codeMap: graph ? { nodes: graph.meta.nodeCount, inSync: fresh } : null,
|
|
2135
|
+
learnings: kept ? { repo: inRepo, branches: onBranches, personal } : null,
|
|
2136
|
+
workspace: cloud ? { name: cloud.workspace.name, url: cloud.workspace.url, repos: cloud.repos.length, thisRepo: shared } : null,
|
|
2137
|
+
week: { savedTokens: saved },
|
|
2138
|
+
}, null, 2));
|
|
2139
|
+
return;
|
|
2140
|
+
}
|
|
2141
|
+
const fmt = (x) => x.toLocaleString("en-US");
|
|
2142
|
+
const row = (k, v) => console.log(`${k.padEnd(11)} ${v}`);
|
|
2143
|
+
if (!graph)
|
|
2144
|
+
row("code map", `✗ not built · run ${cmd("julius build")}`);
|
|
2145
|
+
else if (fresh === false)
|
|
2146
|
+
row("code map", `⚠ ${fmt(graph.meta.nodeCount)} nodes · behind the code, refreshed on the next query`);
|
|
2147
|
+
else
|
|
2148
|
+
row("code map", `✓ ${fmt(graph.meta.nodeCount)} nodes · in sync with the code`);
|
|
2149
|
+
if (kept) {
|
|
2150
|
+
const parts = [`${inRepo} for the team in ${LEARNINGS_DIR}/`];
|
|
2151
|
+
if (onBranches)
|
|
2152
|
+
parts.push(`${onBranches} on teammates' branches`);
|
|
2153
|
+
if (personal)
|
|
2154
|
+
parts.push(`${personal} just for you, on this machine`);
|
|
2155
|
+
row("learnings", parts.join(" · "));
|
|
2156
|
+
}
|
|
2157
|
+
if (!cloud) {
|
|
2158
|
+
if (cloudEnabled())
|
|
2159
|
+
row("workspace", "not connected · Claude offers a link once there are learnings to share");
|
|
2160
|
+
}
|
|
2161
|
+
else
|
|
2162
|
+
row("workspace", `${cloud.workspace.name} · ${cloud.repos.length} repo${cloud.repos.length === 1 ? "" : "s"}${shared ? ", this one included" : `, not this one (${cmd("julius workspace add")})`} · ${cloud.workspace.url}`);
|
|
2163
|
+
row("this week", saved > 0 ? `~${shortCount(saved)} tokens saved` : "nothing saved yet");
|
|
2164
|
+
});
|
|
2165
|
+
}
|
|
2166
|
+
{
|
|
2167
|
+
for (const c of [teamCheckCommand(), teamCommand()])
|
|
2168
|
+
program.addCommand(c.helpGroup(GROUP.memory));
|
|
2169
|
+
// Signing in waits until it gives a team more than committing .julius/ does.
|
|
2170
|
+
for (const c of [workspaceCommand(), loginCommand(), logoutCommand()])
|
|
2171
|
+
program.addCommand(c.helpGroup(GROUP.cloud), { hidden: !cloudEnabled() });
|
|
2172
|
+
program.addCommand(statusCommand().helpGroup(GROUP.setup));
|
|
2173
|
+
// Help lists the groups in this order, and the commands within each.
|
|
2174
|
+
const order = ["ask", "grep", "skeleton", "callers", "map", "note", "check", "team", "learn", "skills", "init", "build", "status", "upgrade", "uninstall", "telemetry", "workspace", "login", "logout", "blast"];
|
|
2175
|
+
const rank = (c) => {
|
|
2176
|
+
const i = order.indexOf(c.name());
|
|
2177
|
+
return i === -1 ? order.length : i;
|
|
2178
|
+
};
|
|
2179
|
+
program.commands.sort((a, b) => rank(a) - rank(b));
|
|
2180
|
+
// One line each in the list; `julius <command> --help` keeps the long text.
|
|
2181
|
+
const summaries = {
|
|
2182
|
+
ask: "ranked answer, with the code inlined at each file:line",
|
|
2183
|
+
grep: "every occurrence, grouped by enclosing symbol",
|
|
2184
|
+
skeleton: "a file's whole API in ~200 tokens",
|
|
2185
|
+
callers: "who calls it, or what it calls with --direction out",
|
|
2186
|
+
map: "directory clusters, hubs and hotspots",
|
|
2187
|
+
note: "save what this session worked out, as a learning in .julius/",
|
|
2188
|
+
learn: "turn a correction into a takeaway on a skill",
|
|
2189
|
+
skills: "list skills, show one, fold takeaways in, publish to the repo",
|
|
2190
|
+
init: "wire julius into your agents",
|
|
2191
|
+
build: "rebuild the code map · --check fails if it's stale",
|
|
2192
|
+
status: "code map, learnings and tokens saved",
|
|
2193
|
+
upgrade: "install the latest julius",
|
|
2194
|
+
uninstall: "remove everything julius wrote to this repo",
|
|
2195
|
+
telemetry: "show or turn off the anonymous usage stats",
|
|
2196
|
+
check: "check your diff against everything the team has learned",
|
|
2197
|
+
team: "what the team learned this week, and where work overlaps",
|
|
2198
|
+
workspace: "your workspace's repos, team page and invite link",
|
|
2199
|
+
login: "connect a Julius workspace (Claude offers you the link)",
|
|
2200
|
+
logout: "disconnect this machine from its workspace",
|
|
2201
|
+
blast: "what depends on the lines this diff touched",
|
|
2202
|
+
};
|
|
2203
|
+
for (const c of program.commands)
|
|
2204
|
+
if (summaries[c.name()])
|
|
2205
|
+
c.summary(summaries[c.name()]);
|
|
2206
|
+
program.addHelpText("after", "\njulius <command> --help for flags");
|
|
2207
|
+
}
|
|
2208
|
+
registerEconomyCommands(program);
|
|
2209
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
2210
|
+
console.error(err instanceof Error ? err.message : err);
|
|
2211
|
+
process.exit(1);
|
|
2212
|
+
});
|
|
2213
|
+
//# sourceMappingURL=cli.js.map
|