kirograph 0.13.1 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +191 -8
- package/dist/bin/commands/caveman.js +7 -2
- package/dist/bin/commands/caveman.js.map +2 -2
- package/dist/bin/commands/compression.js +109 -0
- package/dist/bin/commands/compression.js.map +7 -0
- package/dist/bin/commands/context.js +31 -24
- package/dist/bin/commands/context.js.map +2 -2
- package/dist/bin/commands/exec.js +107 -0
- package/dist/bin/commands/exec.js.map +7 -0
- package/dist/bin/commands/gain.js +119 -0
- package/dist/bin/commands/gain.js.map +7 -0
- package/dist/bin/commands/help.js +10 -1
- package/dist/bin/commands/help.js.map +2 -2
- package/dist/bin/commands/query.js +5 -1
- package/dist/bin/commands/query.js.map +2 -2
- package/dist/bin/commands/uninit.js +1 -1
- package/dist/bin/commands/uninit.js.map +2 -2
- package/dist/bin/commands/utils.js +16 -0
- package/dist/bin/commands/utils.js.map +2 -2
- package/dist/bin/installer/config-prompt.js +9 -2
- package/dist/bin/installer/config-prompt.js.map +2 -2
- package/dist/bin/installer/hooks.js +19 -1
- package/dist/bin/installer/hooks.js.map +2 -2
- package/dist/bin/installer/index.js +6 -1
- package/dist/bin/installer/index.js.map +2 -2
- package/dist/bin/installer/steering.js +116 -40
- package/dist/bin/installer/steering.js.map +2 -2
- package/dist/bin/installer/targets/index.js.map +1 -1
- package/dist/bin/installer/targets/kiro.js +4 -2
- package/dist/bin/installer/targets/kiro.js.map +2 -2
- package/dist/bin/kirograph.js +7 -1
- package/dist/bin/kirograph.js.map +3 -3
- package/dist/compression/filters/aws.js +418 -0
- package/dist/compression/filters/aws.js.map +7 -0
- package/dist/compression/filters/docker.js +153 -0
- package/dist/compression/filters/docker.js.map +7 -0
- package/dist/compression/filters/files.js +150 -0
- package/dist/compression/filters/files.js.map +7 -0
- package/dist/compression/filters/generic.js +86 -0
- package/dist/compression/filters/generic.js.map +7 -0
- package/dist/compression/filters/git.js +272 -0
- package/dist/compression/filters/git.js.map +7 -0
- package/dist/compression/filters/github.js +137 -0
- package/dist/compression/filters/github.js.map +7 -0
- package/dist/compression/filters/lint.js +280 -0
- package/dist/compression/filters/lint.js.map +7 -0
- package/dist/compression/filters/misc.js +212 -0
- package/dist/compression/filters/misc.js.map +7 -0
- package/dist/compression/filters/package.js +151 -0
- package/dist/compression/filters/package.js.map +7 -0
- package/dist/compression/filters/test.js +266 -0
- package/dist/compression/filters/test.js.map +7 -0
- package/dist/compression/index.js +144 -0
- package/dist/compression/index.js.map +7 -0
- package/dist/compression/naive-cost.js +94 -0
- package/dist/compression/naive-cost.js.map +7 -0
- package/dist/compression/tracker.js +228 -0
- package/dist/compression/tracker.js.map +7 -0
- package/dist/compression/types.js +17 -0
- package/dist/compression/types.js.map +7 -0
- package/dist/config.js +18 -1
- package/dist/config.js.map +2 -2
- package/dist/mcp/tool-names.js +3 -1
- package/dist/mcp/tool-names.js.map +2 -2
- package/dist/mcp/tools.js +170 -4
- package/dist/mcp/tools.js.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -313,7 +313,7 @@ Quick symbol search by name. Returns locations only, no code.
|
|
|
313
313
|
| Parameter | Type | Default | Description |
|
|
314
314
|
|-----------|------|---------|-------------|
|
|
315
315
|
| `query` | string | required | Symbol name or partial name |
|
|
316
|
-
| `kind` | string |
|
|
316
|
+
| `kind` | string | - | Filter: `function`, `method`, `class`, `interface`, `type_alias`, `variable`, `route`, `component` |
|
|
317
317
|
| `limit` | number | 10 | Max results (1–100) |
|
|
318
318
|
| `projectPath` | string | cwd | Project root path |
|
|
319
319
|
|
|
@@ -420,9 +420,9 @@ List the indexed file structure with filtering and format options.
|
|
|
420
420
|
|
|
421
421
|
| Parameter | Type | Default | Description |
|
|
422
422
|
|-----------|------|---------|-------------|
|
|
423
|
-
| `filterPath` | string |
|
|
424
|
-
| `pattern` | string |
|
|
425
|
-
| `maxDepth` | number |
|
|
423
|
+
| `filterPath` | string | - | Filter by directory prefix (e.g., `src/`) |
|
|
424
|
+
| `pattern` | string | - | Filter by glob pattern (e.g., `**/*.ts`) |
|
|
425
|
+
| `maxDepth` | number | - | Limit tree depth |
|
|
426
426
|
| `format` | string | `tree` | `tree`, `flat`, or `grouped` |
|
|
427
427
|
| `includeMetadata` | boolean | true | Include language and symbol counts |
|
|
428
428
|
| `projectPath` | string | cwd | Project root path |
|
|
@@ -457,7 +457,7 @@ Get coupling metrics for all packages or a specific one.
|
|
|
457
457
|
|
|
458
458
|
| Parameter | Type | Default | Description |
|
|
459
459
|
|-----------|------|---------|-------------|
|
|
460
|
-
| `packageId` | string |
|
|
460
|
+
| `packageId` | string | - | Package ID (e.g. `pkg:npm:src/auth`). Omit for all packages. |
|
|
461
461
|
| `projectPath` | string | cwd | Project root path |
|
|
462
462
|
|
|
463
463
|
Returns per-package: **Ca** (afferent: how many other packages depend on this one), **Ce** (efferent: how many packages this one depends on), and **instability** (`Ce / (Ca + Ce)`, 0 = maximally stable, 1 = maximally unstable). When `packageId` is given, also returns the full list of incoming and outgoing package dependencies.
|
|
@@ -506,6 +506,31 @@ Compare the current graph state against a saved snapshot. Shows added/removed sy
|
|
|
506
506
|
|
|
507
507
|
Use `kirograph snapshot save` (CLI) to save a snapshot before a refactor or PR. Run `kirograph_diff` after to see what changed structurally.
|
|
508
508
|
|
|
509
|
+
### `kirograph_exec`
|
|
510
|
+
|
|
511
|
+
Run a shell command and return token-optimized output. Automatically filters noise from git, test runners, linters, build tools, docker, and package managers.
|
|
512
|
+
|
|
513
|
+
| Parameter | Type | Default | Description |
|
|
514
|
+
|-----------|------|---------|-------------|
|
|
515
|
+
| `command` | string | required | Shell command to execute |
|
|
516
|
+
| `cwd` | string | project root | Working directory |
|
|
517
|
+
| `level` | string | `normal` | Compression level: `normal`, `aggressive`, `ultra` |
|
|
518
|
+
| `timeout` | number | 60 | Timeout in seconds |
|
|
519
|
+
| `projectPath` | string | cwd | Project root path |
|
|
520
|
+
|
|
521
|
+
**How it works:** Executes the command, detects the command family (git, test, lint, etc.), applies the appropriate filter strategy, and returns compressed output with a savings footer. Error output is always preserved. Does not require KiroGraph to be initialized, works standalone.
|
|
522
|
+
|
|
523
|
+
### `kirograph_gain`
|
|
524
|
+
|
|
525
|
+
Show token savings statistics from compressed command outputs.
|
|
526
|
+
|
|
527
|
+
| Parameter | Type | Default | Description |
|
|
528
|
+
|-----------|------|---------|-------------|
|
|
529
|
+
| `period` | string | `session` | Time period: `session`, `today`, `week`, `all` |
|
|
530
|
+
| `projectPath` | string | cwd | Project root path |
|
|
531
|
+
|
|
532
|
+
Returns total commands, original/compressed token counts, savings percentage, breakdown by command family, and recent command history.
|
|
533
|
+
|
|
509
534
|
## CLI Reference
|
|
510
535
|
|
|
511
536
|
### Setup
|
|
@@ -632,6 +657,163 @@ Caveman mode never touches code blocks, file paths, URLs, or technical terms, on
|
|
|
632
657
|
|
|
633
658
|
**Auto-clarity exceptions:** the agent temporarily reverts to normal prose for security warnings, confirmations of irreversible actions (delete, overwrite, force-push), and multi-step sequences where fragment order could cause misunderstanding. Compressed style resumes immediately after.
|
|
634
659
|
|
|
660
|
+
### Shell Compression (`kirograph_exec`)
|
|
661
|
+
|
|
662
|
+
KiroGraph includes a built-in shell compression engine inspired by [rtk](https://github.com/rtk-ai/rtk). The `kirograph_exec` MCP tool runs shell commands and returns token-optimized output, saving 60-90% of tokens on verbose commands like git, test runners, linters, and build tools.
|
|
663
|
+
|
|
664
|
+
**Why it's useful:** LLM context is expensive. A raw `git status` might be 2,000 tokens; compressed it's 200. A passing test suite might be 25,000 tokens of noise; compressed it's a single "PASSED: 42/42 tests" line. The compression engine knows how to extract the signal from each command family.
|
|
665
|
+
|
|
666
|
+
Supported command families:
|
|
667
|
+
|
|
668
|
+
| Family | Commands | Typical savings |
|
|
669
|
+
|--------|----------|----------------|
|
|
670
|
+
| Git | status, log, diff, push, pull, commit, add, fetch, branch, stash | 75-96% |
|
|
671
|
+
| GitHub CLI | gh pr list/view, gh issue list, gh run list/view | 60-80% |
|
|
672
|
+
| Test runners | jest, vitest, pytest, cargo test, go test, rspec, minitest, playwright | 80-90% |
|
|
673
|
+
| Linters/build | eslint, tsc, ruff, clippy, cargo build, prettier, biome, golangci-lint, rubocop, next build | 70-85% |
|
|
674
|
+
| File listings | ls, find, tree | 60-80% |
|
|
675
|
+
| Search | grep, rg/ripgrep (grouped by file) | 60-80% |
|
|
676
|
+
| Diff | diff file1 file2 (condensed context) | 50-70% |
|
|
677
|
+
| Docker/k8s | docker ps, images, logs, compose ps, kubectl pods, logs, services | 70-80% |
|
|
678
|
+
| Package managers | npm/pnpm install/list, pip list/install/outdated, bundle install/list, prisma generate | 75-92% |
|
|
679
|
+
| AWS | sts, ec2, lambda, logs, cloudformation, dynamodb, iam, s3, ecs, sqs, sns | 60-88% |
|
|
680
|
+
| Network | curl (strip progress/headers), wget (strip progress bars) | 50-70% |
|
|
681
|
+
|
|
682
|
+
**Supported commands (full list):**
|
|
683
|
+
|
|
684
|
+
```
|
|
685
|
+
# Git
|
|
686
|
+
kirograph exec git status # Compact status
|
|
687
|
+
kirograph exec git log -n 10 # One-line commits
|
|
688
|
+
kirograph exec git diff # Condensed diff
|
|
689
|
+
kirograph exec git add . # → "ok"
|
|
690
|
+
kirograph exec git commit -m "msg" # → "ok abc1234"
|
|
691
|
+
kirograph exec git push # → "ok main → origin/main"
|
|
692
|
+
kirograph exec git pull # → "ok 3 files +10 -2"
|
|
693
|
+
|
|
694
|
+
# GitHub CLI
|
|
695
|
+
kirograph exec gh pr list # Compact PR listing
|
|
696
|
+
kirograph exec gh pr view 42 # PR details + checks
|
|
697
|
+
kirograph exec gh issue list # Compact issue listing
|
|
698
|
+
kirograph exec gh run list # Workflow run status
|
|
699
|
+
|
|
700
|
+
# Test Runners
|
|
701
|
+
kirograph exec jest # Failures only
|
|
702
|
+
kirograph exec vitest run # Failures only
|
|
703
|
+
kirograph exec playwright test # E2E results (failures only)
|
|
704
|
+
kirograph exec pytest # Python tests (-90%)
|
|
705
|
+
kirograph exec go test ./... # Go tests (-90%)
|
|
706
|
+
kirograph exec cargo test # Cargo tests (-90%)
|
|
707
|
+
kirograph exec rake test # Ruby minitest (-90%)
|
|
708
|
+
kirograph exec rspec # RSpec tests (-60%+)
|
|
709
|
+
|
|
710
|
+
# Build & Lint
|
|
711
|
+
kirograph exec eslint . # Grouped by rule/file
|
|
712
|
+
kirograph exec tsc --noEmit # TypeScript errors grouped by file
|
|
713
|
+
kirograph exec next build # Next.js build compact
|
|
714
|
+
kirograph exec prettier --check . # Files needing formatting
|
|
715
|
+
kirograph exec cargo build # Cargo build (-80%)
|
|
716
|
+
kirograph exec cargo clippy # Cargo clippy (-80%)
|
|
717
|
+
kirograph exec ruff check # Python linting (-80%)
|
|
718
|
+
kirograph exec golangci-lint run # Go linting (-85%)
|
|
719
|
+
kirograph exec rubocop # Ruby linting (-60%+)
|
|
720
|
+
kirograph exec biome check . # Biome linting
|
|
721
|
+
|
|
722
|
+
# Files & Search
|
|
723
|
+
kirograph exec ls -la src/ # Structured directory listing
|
|
724
|
+
kirograph exec find . -name "*.ts" # Grouped by directory
|
|
725
|
+
kirograph exec tree # Truncated with summary
|
|
726
|
+
kirograph exec grep -r "pattern" . # Grouped search results
|
|
727
|
+
kirograph exec rg "pattern" # Grouped search results
|
|
728
|
+
kirograph exec diff file1 file2 # Condensed diff
|
|
729
|
+
|
|
730
|
+
# Package Managers
|
|
731
|
+
kirograph exec npm install # → "ok +5 packages"
|
|
732
|
+
kirograph exec npm list # Compact dependency tree
|
|
733
|
+
kirograph exec pip list # Python packages
|
|
734
|
+
kirograph exec pip install -r req.txt # Strip progress bars
|
|
735
|
+
kirograph exec bundle install # Strip "Using" lines
|
|
736
|
+
kirograph exec prisma generate # Strip ASCII art
|
|
737
|
+
|
|
738
|
+
# AWS
|
|
739
|
+
kirograph exec aws sts get-caller-identity # One-line identity
|
|
740
|
+
kirograph exec aws ec2 describe-instances # Compact instance list
|
|
741
|
+
kirograph exec aws lambda list-functions # Name/runtime/memory
|
|
742
|
+
kirograph exec aws logs get-log-events ... # Timestamped messages only
|
|
743
|
+
kirograph exec aws cloudformation describe-stack-events ... # Failures first
|
|
744
|
+
kirograph exec aws dynamodb scan ... # Unwraps type annotations
|
|
745
|
+
kirograph exec aws iam list-roles # Strips policy documents
|
|
746
|
+
kirograph exec aws s3 ls s3://bucket # Truncated listing
|
|
747
|
+
|
|
748
|
+
# Containers
|
|
749
|
+
kirograph exec docker ps # Compact container list
|
|
750
|
+
kirograph exec docker images # Compact image list
|
|
751
|
+
kirograph exec docker logs container # Deduplicated logs
|
|
752
|
+
kirograph exec docker compose ps # Compose services
|
|
753
|
+
kirograph exec kubectl get pods # Compact pod list
|
|
754
|
+
kirograph exec kubectl logs pod # Deduplicated logs
|
|
755
|
+
kirograph exec kubectl get svc # Compact service list
|
|
756
|
+
|
|
757
|
+
# Network
|
|
758
|
+
kirograph exec curl https://api.example.com/data # Strip progress/headers
|
|
759
|
+
kirograph exec wget https://example.com/file.zip # Strip progress bars
|
|
760
|
+
```
|
|
761
|
+
|
|
762
|
+
Three compression levels:
|
|
763
|
+
|
|
764
|
+
| Level | Style |
|
|
765
|
+
|-------|-------|
|
|
766
|
+
| `normal` | Balanced: removes noise, keeps structure *(default)* |
|
|
767
|
+
| `aggressive` | More compact: groups by category, limits output |
|
|
768
|
+
| `ultra` | Maximum compression: counts and summaries only |
|
|
769
|
+
|
|
770
|
+
```bash
|
|
771
|
+
kirograph compression normal # balanced (default)
|
|
772
|
+
kirograph compression aggressive # more compact
|
|
773
|
+
kirograph compression ultra # maximum compression
|
|
774
|
+
kirograph compression off # disable hook (tool still available)
|
|
775
|
+
kirograph compression # show current level
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
Set during `kirograph install` (interactive arrow-key menu) or any time after. When set to anything other than `off`, a `preToolUse` hook reminds the agent to use `kirograph_exec` for supported commands. The configured level is used as the default when the agent doesn't specify one explicitly.
|
|
779
|
+
|
|
780
|
+
**Error preservation:** Failed commands always show full diagnostic output regardless of compression level. The engine detects error patterns and preserves detail when it matters.
|
|
781
|
+
|
|
782
|
+
**Token analytics:**
|
|
783
|
+
|
|
784
|
+
```bash
|
|
785
|
+
kirograph gain # summary stats
|
|
786
|
+
kirograph gain --graph # ASCII graph (last 30 days)
|
|
787
|
+
kirograph gain --history # recent command history
|
|
788
|
+
kirograph gain --daily # day-by-day breakdown
|
|
789
|
+
kirograph gain --json # JSON export
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
The `kirograph_gain` MCP tool exposes the same stats to the agent.
|
|
793
|
+
|
|
794
|
+
### Savings Heuristics
|
|
795
|
+
|
|
796
|
+
`kirograph gain` tracks two types of savings: compression (measured exactly) and graph tools (estimated via heuristics). For graph tools, the system estimates what the agent *would have spent* doing the same work without KiroGraph, based on typical agent behavior:
|
|
797
|
+
|
|
798
|
+
| Tool | What the agent would do manually | Estimated naive cost |
|
|
799
|
+
|------|----------------------------------|---------------------|
|
|
800
|
+
| `kirograph_context` | Read 5-10 files to orient on a task | ~7,500-15,000 tokens |
|
|
801
|
+
| `kirograph_search` | Run grep + read top matches | ~3,300 tokens |
|
|
802
|
+
| `kirograph_callers` | Grep for symbol + read each calling file | ~8,300 tokens |
|
|
803
|
+
| `kirograph_callees` | Read function body + grep for each call | ~3,900 tokens |
|
|
804
|
+
| `kirograph_impact` | Recursive grep + read per depth level | ~6,900 × depth |
|
|
805
|
+
| `kirograph_node` | Read the full file containing the symbol | ~1,500 tokens |
|
|
806
|
+
| `kirograph_files` | Run `find` or `ls -R` | ~2,000 tokens |
|
|
807
|
+
| `kirograph_path` | Trace connections manually (multiple grep + read) | ~7,700 tokens |
|
|
808
|
+
| `kirograph_type_hierarchy` | Grep for extends/implements + read each file | ~5,400 tokens |
|
|
809
|
+
| `kirograph_dead_code` | Not feasible manually (read every file) | 5× output, min 15,000 |
|
|
810
|
+
| `kirograph_hotspots` | Not feasible manually (count edges for every symbol) | 5× output, min 15,000 |
|
|
811
|
+
| `kirograph_architecture` | Not feasible manually | 4× output, min 7,500 |
|
|
812
|
+
|
|
813
|
+
Constants used: 1,500 tokens per average source file (~200 lines), 800 tokens per grep result set, 2,000 tokens per directory listing. These are conservative estimates; in practice agents often read more files, retry failed searches, and explore dead ends.
|
|
814
|
+
|
|
815
|
+
**Coexistence with Caveman Mode:** Compression and caveman mode are complementary, they compress different things. Caveman mode compresses the agent's *prose responses* (the text it writes around tool results); it never touches code or tool output. Shell compression compresses *shell command output* (the raw data coming back from shell commands); it never touches how the agent communicates. They stack: with both enabled, shell commands return 60-90% fewer tokens *and* the agent's explanations around those results are also shorter. Pick both independently during `kirograph install`. The "ultra + ultra" combo gives maximum token savings on both fronts.
|
|
816
|
+
|
|
635
817
|
### Architecture Analysis *(requires `enableArchitecture: true`)*
|
|
636
818
|
|
|
637
819
|
Visualize the detected package graph, architectural layers, and package dependencies.
|
|
@@ -862,10 +1044,11 @@ KiroGraph stores its config in `.kirograph/config.json`. You can edit it directl
|
|
|
862
1044
|
| `semanticEngine` | string | `cosine` | Search engine: `cosine`, `sqlite-vec`, `orama`, `pglite`, `lancedb`, `qdrant`, or `typesense` |
|
|
863
1045
|
| `useVecIndex` | boolean | `false` | Deprecated alias for `semanticEngine: "sqlite-vec"` |
|
|
864
1046
|
| `enableArchitecture` | boolean | `false` | Enable architecture analysis (package graph + layer detection, opt-in) |
|
|
865
|
-
| `architectureLayers` | object |
|
|
1047
|
+
| `architectureLayers` | object | - | Custom layer definitions: `{ "layerName": ["glob/**"] }` |
|
|
866
1048
|
| `minLogLevel` | string | `warn` | Log level: `debug`, `info`, `warn`, `error` |
|
|
867
1049
|
| `fuzzyResolutionThreshold` | number | `0.5` | Name matching threshold for cross-file resolution (0.0–1.0) |
|
|
868
1050
|
| `cavemanMode` | string | `off` | Agent communication style: `off`, `lite`, `full`, `ultra` |
|
|
1051
|
+
| `shellCompressionLevel` | string | `normal` | Shell command compression level: `off`, `normal`, `aggressive`, `ultra` |
|
|
869
1052
|
|
|
870
1053
|
Default exclude patterns: `node_modules/**`, `dist/**`, `build/**`, `.git/**`, `*.min.js`, `.kirograph/**`
|
|
871
1054
|
|
|
@@ -893,7 +1076,7 @@ Run `kirograph install` to be guided through model and engine selection interact
|
|
|
893
1076
|
| `onnx-community/embeddinggemma-300m-ONNX` | 768 | ~300MB | Google Gemma-based. Multilingual, 2048-token context window. |
|
|
894
1077
|
| `Xenova/all-MiniLM-L6-v2` | 384 | ~23MB | Lightweight, fast. Lower accuracy. |
|
|
895
1078
|
| `BAAI/bge-base-en-v1.5` | 768 | ~110MB | Strong general-purpose alternative to nomic. |
|
|
896
|
-
| Custom | any |
|
|
1079
|
+
| Custom | any | - | Any HuggingFace `feature-extraction` model. Provide ID + output dimension. |
|
|
897
1080
|
|
|
898
1081
|
The embedding dimension is stored in `embeddingDim` in `.kirograph/config.json` and used to initialise all vector engines correctly. Switching models requires a full re-index (`kirograph index --force`).
|
|
899
1082
|
|
|
@@ -927,7 +1110,7 @@ The graph store (`kirograph.db`) always holds nodes, edges, files, and all struc
|
|
|
927
1110
|
|
|
928
1111
|
| Engine | Search type | Extra deps | Native? | Best for |
|
|
929
1112
|
|--------|-------------|------------|---------|----------|
|
|
930
|
-
| `cosine` *(default)* | Exact cosine, linear scan | none |
|
|
1113
|
+
| `cosine` *(default)* | Exact cosine, linear scan | none | - | Small / medium projects, zero setup |
|
|
931
1114
|
| `sqlite-vec` | ANN (approximate), sub-linear | `better-sqlite3`, `sqlite-vec` | yes | Large codebases, fast ANN search |
|
|
932
1115
|
| `orama` | Hybrid (full-text + vector) | `@orama/orama`, `@orama/plugin-data-persistence` | no (pure JS) | Best result quality, no native deps |
|
|
933
1116
|
| `pglite` | Hybrid (full-text + vector), exact | `@electric-sql/pglite` | no (pure WASM) | Exact results, no native deps, PostgreSQL semantics |
|
|
@@ -101,7 +101,12 @@ function register(program) {
|
|
|
101
101
|
const kiroDir = path.join(cwd, ".kiro");
|
|
102
102
|
const steeringPath = path.join(kiroDir, "steering", "kirograph.md");
|
|
103
103
|
if (fs.existsSync(steeringPath)) {
|
|
104
|
-
(0,
|
|
104
|
+
const config = await (0, import_config.loadConfig)(cwd);
|
|
105
|
+
(0, import_steering.writeSteering)(kiroDir, {
|
|
106
|
+
cavemanMode: normalized,
|
|
107
|
+
enableCompression: config.shellCompressionLevel !== "off",
|
|
108
|
+
shellCompressionLevel: config.shellCompressionLevel
|
|
109
|
+
});
|
|
105
110
|
}
|
|
106
111
|
const agentPath = path.join(kiroDir, "agents", "kirograph.json");
|
|
107
112
|
if (fs.existsSync(agentPath)) {
|
|
@@ -119,7 +124,7 @@ function register(program) {
|
|
|
119
124
|
}
|
|
120
125
|
console.log();
|
|
121
126
|
if (normalized === "off") {
|
|
122
|
-
console.log(` ${import_ui.green}\u2713${import_ui.reset} Caveman mode ${import_ui.violet}${import_ui.bold}off${import_ui.reset}${import_ui.dim}
|
|
127
|
+
console.log(` ${import_ui.green}\u2713${import_ui.reset} Caveman mode ${import_ui.violet}${import_ui.bold}off${import_ui.reset}${import_ui.dim} . Agent will respond normally from next session.${import_ui.reset}`);
|
|
123
128
|
console.log(joke());
|
|
124
129
|
} else {
|
|
125
130
|
console.log(` ${import_ui.green}\u2713${import_ui.reset} Caveman mode set to ${import_ui.violet}${import_ui.bold}${normalized}${import_ui.reset}`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/commands/caveman.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * kg caveman [off|lite|full|ultra] \u2014 set caveman mode for this project\n * kg caveman \u2014 show current mode\n */\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { Command } from 'commander';\nimport { loadConfig, updateConfig } from '../../config';\nimport { CAVEMAN_RULES, CavemanMode } from '../installer/caveman';\nimport { writeSteering } from '../installer/steering';\nimport { writeCliAgent } from '../installer/cli-agent';\nimport { upsertGeneratedBlock } from '../installer/common';\nimport { buildAgentInstructions } from '../installer/instructions';\nimport { bold, dim, green, reset, violet } from '../ui';\n\nconst JOKES = [\n 'Ugh. Words hard. Code easy.',\n 'Caveman not need article. Caveman have rock.',\n 'Why say lot word when few word do trick?',\n 'Token saved = mammoth fed.',\n 'Caveman compress speech. Caveman also compress mammoth.',\n 'Me not lazy. Me efficient.',\n 'Short answer good answer. Long answer... ugh.',\n 'Caveman invent fire. Caveman invent brief response.',\n 'No filler word. Only meat.',\n 'Grunt once. Mean much.',\n];\n\nfunction joke(): string {\n const line = JOKES[Math.floor(Math.random() * JOKES.length)];\n return `\\n ${violet}\uD83E\uDEA8 ${line}${reset}`;\n}\n\nconst MODES: Array<{ name: string; desc: string }> = [\n { name: 'off', desc: 'normal responses' },\n { name: 'lite', desc: 'compact, no filler, full sentences' },\n { name: 'full', desc: 'fragments, no articles, short synonyms' },\n { name: 'ultra', desc: 'maximum compression, abbreviations, \u2192 for causality' },\n];\n\nexport function register(program: Command): void {\n program\n .command('caveman [mode]')\n .description('Set caveman communication style for the Kiro agent (off | lite | full | ultra)')\n .action(async (mode: string | undefined) => {\n const cwd = process.cwd();\n\n // No mode argument: show current status\n if (!mode) {\n let current = 'off';\n try {\n const config = await loadConfig(cwd);\n current = config.cavemanMode ?? 'off';\n } catch { /* no .kirograph/ */ }\n\n console.log();\n console.log(` ${dim}Caveman mode${reset} ${violet}${bold}${current}${reset}`);\n console.log();\n console.log(` ${dim}Available modes:${reset}`);\n for (const m of MODES) {\n const active = m.name === current;\n const marker = active ? `${green}\u25CF${reset}` : `${dim}\u25CB${reset}`;\n const nameStr = active ? `${violet}${bold}${m.name}${reset}` : `${dim}${m.name}${reset}`;\n const nameW = m.name.length;\n const pad = ' '.repeat(6 - nameW);\n console.log(` ${marker} ${nameStr}${pad}${dim}${m.desc}${reset}`);\n }\n console.log();\n console.log(` ${dim}Change:${reset} kg caveman ${dim}<mode>${reset}`);\n console.log(joke());\n console.log();\n return;\n }\n\n const normalized = mode.toLowerCase();\n const valid = MODES.map(m => m.name);\n if (!valid.includes(normalized)) {\n console.error(` ${dim}Unknown mode:${reset} ${normalized}${dim}. Choose from: off, lite, full, ultra${reset}`);\n process.exit(1);\n }\n\n await updateConfig(cwd, { cavemanMode: normalized as CavemanMode | 'off' });\n\n const kiroDir = path.join(cwd, '.kiro');\n\n // Regenerate steering file if .kiro/steering/kirograph.md exists\n const steeringPath = path.join(kiroDir, 'steering', 'kirograph.md');\n if (fs.existsSync(steeringPath)) {\n writeSteering(kiroDir, normalized as CavemanMode | 'off');\n }\n\n // Regenerate CLI agent config if .kiro/agents/kirograph.json exists\n const agentPath = path.join(kiroDir, 'agents', 'kirograph.json');\n if (fs.existsSync(agentPath)) {\n writeCliAgent(kiroDir);\n }\n\n for (const file of ['claude.md', 'codex.md']) {\n const instructionsPath = path.join(cwd, '.kirograph', file);\n if (fs.existsSync(instructionsPath)) {\n fs.writeFileSync(instructionsPath, buildAgentInstructions(normalized as CavemanMode | 'off'));\n }\n }\n const agentsPath = path.join(cwd, 'AGENTS.md');\n if (fs.existsSync(agentsPath) && fs.readFileSync(agentsPath, 'utf8').includes('<!-- kirograph:codex:start -->')) {\n upsertGeneratedBlock(agentsPath, 'codex', '## KiroGraph', buildAgentInstructions(normalized as CavemanMode | 'off'));\n }\n\n console.log();\n if (normalized === 'off') {\n console.log(` ${green}\u2713${reset} Caveman mode ${violet}${bold}off${reset}${dim}
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,WAAsB;AACtB,SAAoB;AAEpB,oBAAyC;AACzC,qBAA2C;AAC3C,sBAA8B;AAC9B,uBAA8B;AAC9B,oBAAqC;AACrC,0BAAuC;AACvC,gBAAgD;AAEhD,MAAM,QAAQ;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,OAAe;AACtB,QAAM,OAAO,MAAM,KAAK,M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rE;AACA,cAAQ,IAAI;AACZ,cAAQ,IAAI,KAAK,aAAG,UAAU,eAAK,eAAe,aAAG,SAAS,eAAK,EAAE;AACrE,cAAQ,IAAI,KAAK,CAAC;AAClB,cAAQ,IAAI;AACZ;AAAA,IACF;AAEA,UAAM,aAAa,KAAK,YAAY;AACpC,UAAM,QAAQ,MAAM,IAAI,OAAK,EAAE,IAAI;AACnC,QAAI,CAAC,MAAM,SAAS,UAAU,GAAG;AAC/B,cAAQ,MAAM,KAAK,aAAG,gBAAgB,eAAK,IAAI,UAAU,GAAG,aAAG,wCAAwC,eAAK,EAAE;AAC9G,cAAQ,KAAK,CAAC;AAAA,IAChB;AAEA,cAAM,4BAAa,KAAK,EAAE,aAAa,WAAkC,CAAC;AAE1E,UAAM,UAAU,KAAK,KAAK,KAAK,OAAO;AAGtC,UAAM,eAAe,KAAK,KAAK,SAAS,YAAY,cAAc;AAClE,QAAI,GAAG,WAAW,YAAY,GAAG;AAC/B,yCAAc,SAAS,
|
|
4
|
+
"sourcesContent": ["/**\n * kg caveman [off|lite|full|ultra] \u2014 set caveman mode for this project\n * kg caveman \u2014 show current mode\n */\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { Command } from 'commander';\nimport { loadConfig, updateConfig } from '../../config';\nimport { CAVEMAN_RULES, CavemanMode } from '../installer/caveman';\nimport { writeSteering } from '../installer/steering';\nimport { writeCliAgent } from '../installer/cli-agent';\nimport { upsertGeneratedBlock } from '../installer/common';\nimport { buildAgentInstructions } from '../installer/instructions';\nimport { bold, dim, green, reset, violet } from '../ui';\n\nconst JOKES = [\n 'Ugh. Words hard. Code easy.',\n 'Caveman not need article. Caveman have rock.',\n 'Why say lot word when few word do trick?',\n 'Token saved = mammoth fed.',\n 'Caveman compress speech. Caveman also compress mammoth.',\n 'Me not lazy. Me efficient.',\n 'Short answer good answer. Long answer... ugh.',\n 'Caveman invent fire. Caveman invent brief response.',\n 'No filler word. Only meat.',\n 'Grunt once. Mean much.',\n];\n\nfunction joke(): string {\n const line = JOKES[Math.floor(Math.random() * JOKES.length)];\n return `\\n ${violet}\uD83E\uDEA8 ${line}${reset}`;\n}\n\nconst MODES: Array<{ name: string; desc: string }> = [\n { name: 'off', desc: 'normal responses' },\n { name: 'lite', desc: 'compact, no filler, full sentences' },\n { name: 'full', desc: 'fragments, no articles, short synonyms' },\n { name: 'ultra', desc: 'maximum compression, abbreviations, \u2192 for causality' },\n];\n\nexport function register(program: Command): void {\n program\n .command('caveman [mode]')\n .description('Set caveman communication style for the Kiro agent (off | lite | full | ultra)')\n .action(async (mode: string | undefined) => {\n const cwd = process.cwd();\n\n // No mode argument: show current status\n if (!mode) {\n let current = 'off';\n try {\n const config = await loadConfig(cwd);\n current = config.cavemanMode ?? 'off';\n } catch { /* no .kirograph/ */ }\n\n console.log();\n console.log(` ${dim}Caveman mode${reset} ${violet}${bold}${current}${reset}`);\n console.log();\n console.log(` ${dim}Available modes:${reset}`);\n for (const m of MODES) {\n const active = m.name === current;\n const marker = active ? `${green}\u25CF${reset}` : `${dim}\u25CB${reset}`;\n const nameStr = active ? `${violet}${bold}${m.name}${reset}` : `${dim}${m.name}${reset}`;\n const nameW = m.name.length;\n const pad = ' '.repeat(6 - nameW);\n console.log(` ${marker} ${nameStr}${pad}${dim}${m.desc}${reset}`);\n }\n console.log();\n console.log(` ${dim}Change:${reset} kg caveman ${dim}<mode>${reset}`);\n console.log(joke());\n console.log();\n return;\n }\n\n const normalized = mode.toLowerCase();\n const valid = MODES.map(m => m.name);\n if (!valid.includes(normalized)) {\n console.error(` ${dim}Unknown mode:${reset} ${normalized}${dim}. Choose from: off, lite, full, ultra${reset}`);\n process.exit(1);\n }\n\n await updateConfig(cwd, { cavemanMode: normalized as CavemanMode | 'off' });\n\n const kiroDir = path.join(cwd, '.kiro');\n\n // Regenerate steering file if .kiro/steering/kirograph.md exists\n const steeringPath = path.join(kiroDir, 'steering', 'kirograph.md');\n if (fs.existsSync(steeringPath)) {\n const config = await loadConfig(cwd);\n writeSteering(kiroDir, {\n cavemanMode: normalized as CavemanMode | 'off',\n enableCompression: config.shellCompressionLevel !== 'off',\n shellCompressionLevel: config.shellCompressionLevel,\n });\n }\n\n // Regenerate CLI agent config if .kiro/agents/kirograph.json exists\n const agentPath = path.join(kiroDir, 'agents', 'kirograph.json');\n if (fs.existsSync(agentPath)) {\n writeCliAgent(kiroDir);\n }\n\n for (const file of ['claude.md', 'codex.md']) {\n const instructionsPath = path.join(cwd, '.kirograph', file);\n if (fs.existsSync(instructionsPath)) {\n fs.writeFileSync(instructionsPath, buildAgentInstructions(normalized as CavemanMode | 'off'));\n }\n }\n const agentsPath = path.join(cwd, 'AGENTS.md');\n if (fs.existsSync(agentsPath) && fs.readFileSync(agentsPath, 'utf8').includes('<!-- kirograph:codex:start -->')) {\n upsertGeneratedBlock(agentsPath, 'codex', '## KiroGraph', buildAgentInstructions(normalized as CavemanMode | 'off'));\n }\n\n console.log();\n if (normalized === 'off') {\n console.log(` ${green}\u2713${reset} Caveman mode ${violet}${bold}off${reset}${dim} . Agent will respond normally from next session.${reset}`);\n console.log(joke());\n } else {\n console.log(` ${green}\u2713${reset} Caveman mode set to ${violet}${bold}${normalized}${reset}`);\n console.log(` ${dim}Takes effect on next agent session.${reset}`);\n console.log();\n console.log(` ${dim}Rules preview:${reset}`);\n console.log();\n for (const line of CAVEMAN_RULES[normalized].split('\\n')) {\n if (line.startsWith('## ')) {\n console.log(` ${violet}${bold}${line.slice(3)}${reset}`);\n } else if (line === '') {\n console.log();\n } else {\n console.log(` ${dim}${line}${reset}`);\n }\n }\n console.log(joke());\n }\n console.log();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,WAAsB;AACtB,SAAoB;AAEpB,oBAAyC;AACzC,qBAA2C;AAC3C,sBAA8B;AAC9B,uBAA8B;AAC9B,oBAAqC;AACrC,0BAAuC;AACvC,gBAAgD;AAEhD,MAAM,Q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
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var compression_exports = {};
|
|
30
|
+
__export(compression_exports, {
|
|
31
|
+
register: () => register
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(compression_exports);
|
|
34
|
+
var path = __toESM(require("path"));
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var import_config = require("../../config");
|
|
37
|
+
var import_steering = require("../installer/steering");
|
|
38
|
+
var import_hooks = require("../installer/hooks");
|
|
39
|
+
var import_ui = require("../ui");
|
|
40
|
+
const LEVELS = [
|
|
41
|
+
{ name: "off", desc: "no compression hook or steering (tool still available)" },
|
|
42
|
+
{ name: "normal", desc: "balanced: removes noise, keeps structure" },
|
|
43
|
+
{ name: "aggressive", desc: "more compact: groups by category, limits output" },
|
|
44
|
+
{ name: "ultra", desc: "maximum compression: counts and summaries only" }
|
|
45
|
+
];
|
|
46
|
+
function register(program) {
|
|
47
|
+
program.command("compression [level]").description("Set shell compression level for kirograph_exec (off | normal | aggressive | ultra)").action(async (level) => {
|
|
48
|
+
const cwd = process.cwd();
|
|
49
|
+
if (!level) {
|
|
50
|
+
let current = "normal";
|
|
51
|
+
try {
|
|
52
|
+
const config2 = await (0, import_config.loadConfig)(cwd);
|
|
53
|
+
current = config2.shellCompressionLevel ?? "normal";
|
|
54
|
+
} catch {
|
|
55
|
+
}
|
|
56
|
+
console.log();
|
|
57
|
+
console.log(` ${import_ui.dim}Shell compression${import_ui.reset} ${import_ui.violet}${import_ui.bold}${current}${import_ui.reset}`);
|
|
58
|
+
console.log();
|
|
59
|
+
console.log(` ${import_ui.dim}Available levels:${import_ui.reset}`);
|
|
60
|
+
for (const l of LEVELS) {
|
|
61
|
+
const active = l.name === current;
|
|
62
|
+
const marker = active ? `${import_ui.green}\u25CF${import_ui.reset}` : `${import_ui.dim}\u25CB${import_ui.reset}`;
|
|
63
|
+
const nameStr = active ? `${import_ui.violet}${import_ui.bold}${l.name}${import_ui.reset}` : `${import_ui.dim}${l.name}${import_ui.reset}`;
|
|
64
|
+
const nameW = l.name.length;
|
|
65
|
+
const pad = " ".repeat(12 - nameW);
|
|
66
|
+
console.log(` ${marker} ${nameStr}${pad}${import_ui.dim}${l.desc}${import_ui.reset}`);
|
|
67
|
+
}
|
|
68
|
+
console.log();
|
|
69
|
+
console.log(` ${import_ui.dim}Change:${import_ui.reset} kg compression ${import_ui.dim}<level>${import_ui.reset}`);
|
|
70
|
+
console.log();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const normalized = level.toLowerCase() === "on" ? "normal" : level.toLowerCase();
|
|
74
|
+
const valid = LEVELS.map((l) => l.name);
|
|
75
|
+
if (!valid.includes(normalized)) {
|
|
76
|
+
console.error(` ${import_ui.dim}Unknown level:${import_ui.reset} ${normalized}${import_ui.dim}. Choose from: off, normal, aggressive, ultra${import_ui.reset}`);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
const shellCompressionLevel = normalized;
|
|
80
|
+
const config = await (0, import_config.updateConfig)(cwd, { shellCompressionLevel });
|
|
81
|
+
const enableCompression = shellCompressionLevel !== "off";
|
|
82
|
+
const kiroDir = path.join(cwd, ".kiro");
|
|
83
|
+
const steeringPath = path.join(kiroDir, "steering", "kirograph.md");
|
|
84
|
+
if (fs.existsSync(steeringPath)) {
|
|
85
|
+
(0, import_steering.writeSteering)(kiroDir, { cavemanMode: config.cavemanMode, enableCompression, shellCompressionLevel });
|
|
86
|
+
}
|
|
87
|
+
const hooksDir = path.join(kiroDir, "hooks");
|
|
88
|
+
if (fs.existsSync(hooksDir)) {
|
|
89
|
+
(0, import_hooks.writeHooks)(kiroDir, { enableCompression });
|
|
90
|
+
}
|
|
91
|
+
console.log();
|
|
92
|
+
if (shellCompressionLevel === "off") {
|
|
93
|
+
console.log(` ${import_ui.green}\u2713${import_ui.reset} Shell compression ${import_ui.violet}${import_ui.bold}off${import_ui.reset}`);
|
|
94
|
+
console.log(` ${import_ui.dim}kirograph_exec is still available but the agent won't be prompted to use it.${import_ui.reset}`);
|
|
95
|
+
console.log(` ${import_ui.dim}The compression hook and steering section have been removed.${import_ui.reset}`);
|
|
96
|
+
} else {
|
|
97
|
+
console.log(` ${import_ui.green}\u2713${import_ui.reset} Shell compression set to ${import_ui.violet}${import_ui.bold}${shellCompressionLevel}${import_ui.reset}`);
|
|
98
|
+
console.log(` ${import_ui.dim}kirograph_exec will use "${shellCompressionLevel}" as the default level.${import_ui.reset}`);
|
|
99
|
+
console.log(` ${import_ui.dim}The agent will be guided to use it for git, test, lint, build, and docker commands.${import_ui.reset}`);
|
|
100
|
+
}
|
|
101
|
+
console.log(` ${import_ui.dim}Takes effect on next agent session.${import_ui.reset}`);
|
|
102
|
+
console.log();
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
register
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=compression.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/bin/commands/compression.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * kg compression [off|normal|aggressive|ultra] \u2014 set compression level for this project\n * kg compression \u2014 show current level\n */\n\nimport * as path from 'path';\nimport * as fs from 'fs';\nimport { Command } from 'commander';\nimport { loadConfig, updateConfig, KiroGraphConfig } from '../../config';\nimport { writeSteering } from '../installer/steering';\nimport { writeHooks } from '../installer/hooks';\nimport { bold, dim, green, reset, violet } from '../ui';\n\ntype CompressionLevel = KiroGraphConfig['shellCompressionLevel'];\n\nconst LEVELS: Array<{ name: string; desc: string }> = [\n { name: 'off', desc: 'no compression hook or steering (tool still available)' },\n { name: 'normal', desc: 'balanced: removes noise, keeps structure' },\n { name: 'aggressive', desc: 'more compact: groups by category, limits output' },\n { name: 'ultra', desc: 'maximum compression: counts and summaries only' },\n];\n\nexport function register(program: Command): void {\n program\n .command('compression [level]')\n .description('Set shell compression level for kirograph_exec (off | normal | aggressive | ultra)')\n .action(async (level: string | undefined) => {\n const cwd = process.cwd();\n\n // No argument: show current status\n if (!level) {\n let current: CompressionLevel = 'normal';\n try {\n const config = await loadConfig(cwd);\n current = config.shellCompressionLevel ?? 'normal';\n } catch { /* no .kirograph/ */ }\n\n console.log();\n console.log(` ${dim}Shell compression${reset} ${violet}${bold}${current}${reset}`);\n console.log();\n console.log(` ${dim}Available levels:${reset}`);\n for (const l of LEVELS) {\n const active = l.name === current;\n const marker = active ? `${green}\u25CF${reset}` : `${dim}\u25CB${reset}`;\n const nameStr = active ? `${violet}${bold}${l.name}${reset}` : `${dim}${l.name}${reset}`;\n const nameW = l.name.length;\n const pad = ' '.repeat(12 - nameW);\n console.log(` ${marker} ${nameStr}${pad}${dim}${l.desc}${reset}`);\n }\n console.log();\n console.log(` ${dim}Change:${reset} kg compression ${dim}<level>${reset}`);\n console.log();\n return;\n }\n\n // Support legacy \"on\" \u2192 \"normal\"\n const normalized = level.toLowerCase() === 'on' ? 'normal' : level.toLowerCase();\n const valid = LEVELS.map(l => l.name);\n if (!valid.includes(normalized)) {\n console.error(` ${dim}Unknown level:${reset} ${normalized}${dim}. Choose from: off, normal, aggressive, ultra${reset}`);\n process.exit(1);\n }\n\n const shellCompressionLevel = normalized as CompressionLevel;\n const config = await updateConfig(cwd, { shellCompressionLevel });\n const enableCompression = shellCompressionLevel !== 'off';\n\n const kiroDir = path.join(cwd, '.kiro');\n\n // Regenerate steering file if it exists\n const steeringPath = path.join(kiroDir, 'steering', 'kirograph.md');\n if (fs.existsSync(steeringPath)) {\n writeSteering(kiroDir, { cavemanMode: config.cavemanMode, enableCompression, shellCompressionLevel });\n }\n\n // Regenerate hooks if hooks dir exists\n const hooksDir = path.join(kiroDir, 'hooks');\n if (fs.existsSync(hooksDir)) {\n writeHooks(kiroDir, { enableCompression });\n }\n\n console.log();\n if (shellCompressionLevel === 'off') {\n console.log(` ${green}\u2713${reset} Shell compression ${violet}${bold}off${reset}`);\n console.log(` ${dim}kirograph_exec is still available but the agent won't be prompted to use it.${reset}`);\n console.log(` ${dim}The compression hook and steering section have been removed.${reset}`);\n } else {\n console.log(` ${green}\u2713${reset} Shell compression set to ${violet}${bold}${shellCompressionLevel}${reset}`);\n console.log(` ${dim}kirograph_exec will use \"${shellCompressionLevel}\" as the default level.${reset}`);\n console.log(` ${dim}The agent will be guided to use it for git, test, lint, build, and docker commands.${reset}`);\n }\n console.log(` ${dim}Tak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IAC5F,OAAO;AACL,cAAQ,IAAI,KAAK,eAAK,SAAI,eAAK,6BAA6B,gBAAM,GAAG,cAAI,GAAG,qBAAqB,GAAG,eAAK,EAAE;AAC3G,cAAQ,IAAI,KAAK,aAAG,4BAA4B,qBAAqB,0BAA0B,eAAK,EAAE;AACtG,cAAQ,IAAI,KAAK,aAAG,sFAAsF,eAAK,EAAE;AAAA,IACnH;AACA,YAAQ,IAAI,KAAK,aAAG,sCAAsC,eAAK,EAAE;AACjE,YAAQ,IAAI;AAAA,EACd,CAAC;AACL;",
|
|
6
|
+
"names": ["config"]
|
|
7
|
+
}
|
|
@@ -25,52 +25,59 @@ var import_ui = require("../ui");
|
|
|
25
25
|
function register(program) {
|
|
26
26
|
program.command("context <task>").description("Build relevant code context for a task").option("--max-nodes <n>", "Max symbols to include", "20").option("--no-code", "Exclude code snippets").option("--format <fmt>", "Output format: markdown, json", "markdown").action(async (task, opts) => {
|
|
27
27
|
const KiroGraph = (await Promise.resolve().then(() => require("../../index.js"))).default;
|
|
28
|
-
const
|
|
28
|
+
const { trackCliToolSaving } = await Promise.resolve().then(() => require("./utils.js"));
|
|
29
|
+
const cwd = process.cwd();
|
|
30
|
+
const cg = await KiroGraph.open(cwd);
|
|
29
31
|
const ctx = await cg.buildContext(task, {
|
|
30
32
|
maxNodes: parseInt(opts.maxNodes),
|
|
31
33
|
includeCode: opts.code
|
|
32
34
|
});
|
|
35
|
+
let output;
|
|
33
36
|
if (opts.format === "json") {
|
|
34
|
-
|
|
37
|
+
output = JSON.stringify({
|
|
35
38
|
task: ctx.task,
|
|
36
39
|
summary: ctx.summary,
|
|
37
40
|
entryPoints: ctx.entryPoints.map((n) => ({ kind: n.kind, name: n.name, file: n.filePath, line: n.startLine })),
|
|
38
41
|
relatedNodes: ctx.relatedNodes.map((n) => ({ kind: n.kind, name: n.name, file: n.filePath, line: n.startLine })),
|
|
39
42
|
codeSnippets: Object.fromEntries(ctx.codeSnippets)
|
|
40
|
-
}, null, 2)
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
}, null, 2);
|
|
44
|
+
console.log(output);
|
|
45
|
+
} else {
|
|
46
|
+
const lines = [];
|
|
47
|
+
lines.push(`
|
|
45
48
|
${(0, import_ui.section)("Context:")} ${import_ui.violet}${import_ui.bold}${ctx.task}${import_ui.reset}
|
|
46
49
|
`);
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
lines.push(` ${import_ui.dim}${ctx.summary}${import_ui.reset}`);
|
|
51
|
+
if (ctx.entryPoints.length > 0) {
|
|
52
|
+
lines.push(`
|
|
50
53
|
${(0, import_ui.section)("Entry Points")}
|
|
51
54
|
`);
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
for (const n of ctx.entryPoints) {
|
|
56
|
+
lines.push(` ${import_ui.violet}${import_ui.bold}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
57
|
+
if (ctx.codeSnippets.has(n.id)) {
|
|
58
|
+
lines.push(`
|
|
56
59
|
${import_ui.dim}\`\`\`${import_ui.reset}`);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
60
|
+
for (const line of (ctx.codeSnippets.get(n.id) ?? "").split("\n")) {
|
|
61
|
+
lines.push(` ${line}`);
|
|
62
|
+
}
|
|
63
|
+
lines.push(` ${import_ui.dim}\`\`\`${import_ui.reset}
|
|
61
64
|
`);
|
|
65
|
+
}
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log(`
|
|
68
|
+
if (ctx.relatedNodes.length > 0) {
|
|
69
|
+
lines.push(`
|
|
67
70
|
${(0, import_ui.section)("Related Symbols")}
|
|
68
71
|
`);
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
for (const n of ctx.relatedNodes) {
|
|
73
|
+
lines.push(` ${import_ui.dim}\xB7${import_ui.reset} ${import_ui.violet}${n.name}${import_ui.reset} ${import_ui.dim}${n.kind} ${n.filePath}:${n.startLine}${import_ui.reset}`);
|
|
74
|
+
}
|
|
75
|
+
lines.push("");
|
|
71
76
|
}
|
|
72
|
-
|
|
77
|
+
output = lines.join("\n");
|
|
78
|
+
console.log(output);
|
|
73
79
|
}
|
|
80
|
+
trackCliToolSaving(cwd, "kirograph_context", output, { maxNodes: parseInt(opts.maxNodes) });
|
|
74
81
|
cg.close();
|
|
75
82
|
});
|
|
76
83
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/bin/commands/context.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport { dim, reset, violet, bold, section } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('context <task>')\n .description('Build relevant code context for a task')\n .option('--max-nodes <n>', 'Max symbols to include', '20')\n .option('--no-code', 'Exclude code snippets')\n .option('--format <fmt>', 'Output format: markdown, json', 'markdown')\n .action(async (task: string, opts: { maxNodes: string; code: boolean; format: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAAkD;AAE3C,SAAS,SAAS,SAAwB;AAC/C,UACG,QAAQ,gBAAgB,EACxB,YAAY,wCAAwC,EACpD,OAAO,mBAAmB,0BAA0B,IAAI,EACxD,OAAO,aAAa,uBAAuB,EAC3C,OAAO,kBAAkB,iCAAiC,UAAU,EACpE,OAAO,OAAO,MAAc,SAA8D;AACzF,UAAM,aAAa,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,gBAAgB,CAAC,GAAG;AAClF,UAAM,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport { dim, reset, violet, bold, section } from '../ui';\n\nexport function register(program: Command): void {\n program\n .command('context <task>')\n .description('Build relevant code context for a task')\n .option('--max-nodes <n>', 'Max symbols to include', '20')\n .option('--no-code', 'Exclude code snippets')\n .option('--format <fmt>', 'Output format: markdown, json', 'markdown')\n .action(async (task: string, opts: { maxNodes: string; code: boolean; format: string }) => {\n const KiroGraph = (await Promise.resolve().then(() => require('../../index.js'))).default;\n const { trackCliToolSaving } = await Promise.resolve().then(() => require('./utils.js'));\n\n const cwd = process.cwd();\n const cg = await KiroGraph.open(cwd);\n const ctx = await cg.buildContext(task, {\n maxNodes: parseInt(opts.maxNodes),\n includeCode: opts.code,\n });\n\n let output: string;\n\n if (opts.format === 'json') {\n output = JSON.stringify({\n task: ctx.task,\n summary: ctx.summary,\n entryPoints: ctx.entryPoints.map((n: any) => ({ kind: n.kind, name: n.name, file: n.filePath, line: n.startLine })),\n relatedNodes: ctx.relatedNodes.map((n: any) => ({ kind: n.kind, name: n.name, file: n.filePath, line: n.startLine })),\n codeSnippets: Object.fromEntries(ctx.codeSnippets),\n }, null, 2);\n console.log(output);\n } else {\n // Markdown output\n const lines: string[] = [];\n lines.push(`\\n ${section('Context:')} ${violet}${bold}${ctx.task}${reset}\\n`);\n lines.push(` ${dim}${ctx.summary}${reset}`);\n if (ctx.entryPoints.length > 0) {\n lines.push(`\\n ${section('Entry Points')}\\n`);\n for (const n of ctx.entryPoints) {\n lines.push(` ${violet}${bold}${n.name}${reset} ${dim}${n.kind} ${n.filePath}:${n.startLine}${reset}`);\n if (ctx.codeSnippets.has(n.id)) {\n lines.push(`\\n ${dim}\\`\\`\\`${reset}`);\n for (const line of (ctx.codeSnippets.get(n.id) ?? '').split('\\n')) {\n lines.push(` ${line}`);\n }\n lines.push(` ${dim}\\`\\`\\`${reset}\\n`);\n }\n }\n }\n if (ctx.relatedNodes.length > 0) {\n lines.push(`\\n ${section('Related Symbols')}\\n`);\n for (const n of ctx.relatedNodes) {\n lines.push(` ${dim}\u00B7${reset} ${violet}${n.name}${reset} ${dim}${n.kind} ${n.filePath}:${n.startLine}${reset}`);\n }\n lines.push('');\n }\n output = lines.join('\\n');\n console.log(output);\n }\n\n // Track graph tool savings\n trackCliToolSaving(cwd, 'kirograph_context', output, { maxNodes: parseInt(opts.maxNodes) });\n\n cg.close();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gBAAkD;AAE3C,SAAS,SAAS,SAAwB;AAC/C,UACG,QAAQ,gBAAgB,EACxB,YAAY,wCAAwC,EACpD,OAAO,mBAAmB,0BAA0B,IAAI,EACxD,OAAO,aAAa,uBAAuB,EAC3C,OAAO,kBAAkB,iCAAiC,UAAU,EACpE,OAAO,OAAO,MAAc,SAA8D;AACzF,UAAM,aAAa,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,gBAAgB,CAAC,GAAG;AAClF,UAAM,EAAE,mBAAmB,IAAI,MAAM,QAAQ,QAAQ,EAAE,KAAK,MAAM,QAAQ,YAAY,CAAC;AAEvF,UAAM,MAAM,QAAQ,IAAI;AACxB,UAAM,KAAK,MAAM,UAAU,KAAK,GAAG;AACnC,UAAM,MAAM,MAAM,GAAG,aAAa,MAAM;AAAA,MACtC,UAAU,SAAS,KAAK,QAAQ;AAAA,MAChC,aAAa,KAAK;AAAA,IACpB,CAAC;AAED,QAAI;AAEJ,QAAI,KAAK,WAAW,QAAQ;AAC1B,eAAS,KAAK,UAAU;AAAA,QACtB,MAAM,IAAI;AAAA,QACV,SAAS,IAAI;AAAA,QACb,aAAa,IAAI,YAAY,IAAI,CAAC,OAAY,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE,UAAU,EAAE;AAAA,QAClH,cAAc,IAAI,aAAa,IAAI,CAAC,OAAY,EAAE,MAAM,EAAE,MAAM,MAAM,EAAE,MAAM,MAAM,EAAE,UAAU,MAAM,EAAE,UAAU,EAAE;AAAA,QACpH,cAAc,OAAO,YAAY,IAAI,YAAY;AAAA,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