akm-cli 0.6.1 → 0.7.0-rc1
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 +66 -0
- package/dist/{cli.js → src/cli.js} +620 -26
- package/dist/{commands → src/commands}/config-cli.js +5 -4
- package/dist/src/commands/distill.js +283 -0
- package/dist/src/commands/events.js +108 -0
- package/dist/src/commands/history.js +120 -0
- package/dist/{commands → src/commands}/installed-stashes.js +1 -1
- package/dist/src/commands/proposal.js +119 -0
- package/dist/src/commands/propose.js +171 -0
- package/dist/src/commands/reflect.js +193 -0
- package/dist/{commands → src/commands}/registry-search.js +2 -1
- package/dist/{commands → src/commands}/remember.js +12 -0
- package/dist/{commands → src/commands}/search.js +74 -1
- package/dist/{commands → src/commands}/self-update.js +4 -3
- package/dist/{commands → src/commands}/show.js +44 -0
- package/dist/{core → src/core}/asset-ref.js +5 -5
- package/dist/{core → src/core}/asset-spec.js +12 -0
- package/dist/{core → src/core}/common.js +1 -1
- package/dist/{core → src/core}/config.js +175 -121
- package/dist/{core → src/core}/errors.js +4 -0
- package/dist/src/core/events.js +239 -0
- package/dist/src/core/lesson-lint.js +86 -0
- package/dist/src/core/proposals.js +406 -0
- package/dist/src/core/warn.js +72 -0
- package/dist/{core → src/core}/write-source.js +80 -5
- package/dist/{indexer → src/indexer}/db-search.js +113 -24
- package/dist/{indexer → src/indexer}/db.js +76 -23
- package/dist/{indexer → src/indexer}/file-context.js +0 -3
- package/dist/src/indexer/graph-boost.js +179 -0
- package/dist/src/indexer/graph-extraction.js +212 -0
- package/dist/{indexer → src/indexer}/indexer.js +73 -6
- package/dist/src/indexer/memory-inference.js +263 -0
- package/dist/{indexer → src/indexer}/metadata.js +111 -3
- package/dist/src/integrations/agent/config.js +292 -0
- package/dist/src/integrations/agent/detect.js +94 -0
- package/dist/src/integrations/agent/index.js +17 -0
- package/dist/src/integrations/agent/profiles.js +65 -0
- package/dist/src/integrations/agent/prompts.js +167 -0
- package/dist/src/integrations/agent/spawn.js +221 -0
- package/dist/{integrations → src/integrations}/lockfile.js +0 -26
- package/dist/{llm → src/llm}/client.js +33 -2
- package/dist/src/llm/feature-gate.js +108 -0
- package/dist/src/llm/graph-extract.js +107 -0
- package/dist/src/llm/index-passes.js +35 -0
- package/dist/src/llm/memory-infer.js +86 -0
- package/dist/{output → src/output}/renderers.js +60 -1
- package/dist/src/output/shapes.js +516 -0
- package/dist/{output → src/output}/text.js +447 -4
- package/dist/{registry → src/registry}/build-index.js +14 -4
- package/dist/{registry → src/registry}/factory.js +0 -8
- package/dist/{registry → src/registry}/providers/static-index.js +3 -2
- package/dist/{registry → src/registry}/resolve.js +68 -2
- package/dist/{setup → src/setup}/setup.js +43 -5
- package/dist/{sources → src/sources}/providers/git.js +7 -15
- package/dist/tests/add-website-source.test.js +119 -0
- package/dist/tests/agent/agent-config-loader.test.js +70 -0
- package/dist/tests/agent/agent-config.test.js +221 -0
- package/dist/tests/agent/agent-detect.test.js +100 -0
- package/dist/tests/agent/agent-spawn.test.js +234 -0
- package/dist/tests/agent-output.test.js +186 -0
- package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +103 -0
- package/dist/tests/architecture/agent-spawn-seam.test.js +193 -0
- package/dist/tests/architecture/llm-stateless-seam.test.js +112 -0
- package/dist/tests/asset-ref.test.js +192 -0
- package/dist/tests/asset-registry.test.js +103 -0
- package/dist/tests/asset-spec.test.js +241 -0
- package/dist/tests/bench/attribution.test.js +995 -0
- package/dist/tests/bench/cleanup-sigint.test.js +83 -0
- package/dist/tests/bench/cleanup.js +203 -0
- package/dist/tests/bench/cleanup.test.js +166 -0
- package/dist/tests/bench/cli.js +683 -0
- package/dist/tests/bench/cli.test.js +177 -0
- package/dist/tests/bench/compare.test.js +556 -0
- package/dist/tests/bench/corpus.js +314 -0
- package/dist/tests/bench/corpus.test.js +258 -0
- package/dist/tests/bench/driver.js +346 -0
- package/dist/tests/bench/driver.test.js +443 -0
- package/dist/tests/bench/evolve-metrics.js +179 -0
- package/dist/tests/bench/evolve-metrics.test.js +187 -0
- package/dist/tests/bench/evolve.js +580 -0
- package/dist/tests/bench/evolve.test.js +616 -0
- package/dist/tests/bench/failure-modes.test.js +300 -0
- package/dist/tests/bench/feedback-integrity.test.js +456 -0
- package/dist/tests/bench/leakage.test.js +125 -0
- package/dist/tests/bench/learning-curve.test.js +133 -0
- package/dist/tests/bench/metrics.js +2319 -0
- package/dist/tests/bench/metrics.test.js +1144 -0
- package/dist/tests/bench/no-os-tmpdir-invariant.test.js +43 -0
- package/dist/tests/bench/report.js +1821 -0
- package/dist/tests/bench/report.test.js +989 -0
- package/dist/tests/bench/runner.js +536 -0
- package/dist/tests/bench/runner.test.js +958 -0
- package/dist/tests/bench/search-bridge.test.js +331 -0
- package/dist/tests/bench/tmp.js +41 -0
- package/dist/tests/bench/trajectory.js +116 -0
- package/dist/tests/bench/trajectory.test.js +127 -0
- package/dist/tests/bench/verifier.js +109 -0
- package/dist/tests/bench/verifier.test.js +118 -0
- package/dist/tests/bench/workflow-evaluator.js +557 -0
- package/dist/tests/bench/workflow-evaluator.test.js +421 -0
- package/dist/tests/bench/workflow-spec.js +358 -0
- package/dist/tests/bench/workflow-spec.test.js +363 -0
- package/dist/tests/bench/workflow-trace.js +438 -0
- package/dist/tests/bench/workflow-trace.test.js +254 -0
- package/dist/tests/benchmark-search-quality.js +536 -0
- package/dist/tests/benchmark-suite.js +1441 -0
- package/dist/tests/capture-cli.test.js +112 -0
- package/dist/tests/cli-errors.test.js +203 -0
- package/dist/tests/commands/events.test.js +370 -0
- package/dist/tests/commands/history.test.js +223 -0
- package/dist/tests/commands/import.test.js +103 -0
- package/dist/tests/commands/proposal-cli.test.js +209 -0
- package/dist/tests/commands/reflect-propose-cli.test.js +333 -0
- package/dist/tests/commands/remember.test.js +97 -0
- package/dist/tests/commands/scope-flags.test.js +300 -0
- package/dist/tests/commands/search.test.js +537 -0
- package/dist/tests/commands/show-indexer-parity.test.js +117 -0
- package/dist/tests/commands/show.test.js +294 -0
- package/dist/tests/common.test.js +266 -0
- package/dist/tests/completions.test.js +142 -0
- package/dist/tests/config-cli.test.js +193 -0
- package/dist/tests/config-llm-features.test.js +139 -0
- package/dist/tests/config.test.js +544 -0
- package/dist/tests/contracts/migration-baseline.test.js +43 -0
- package/dist/tests/contracts/reflect-propose-envelope.test.js +139 -0
- package/dist/tests/contracts/spec-helpers.js +46 -0
- package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +228 -0
- package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +56 -0
- package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +34 -0
- package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +94 -0
- package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +39 -0
- package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +44 -0
- package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +47 -0
- package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +40 -0
- package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +58 -0
- package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +34 -0
- package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +75 -0
- package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +36 -0
- package/dist/tests/core/write-source.test.js +366 -0
- package/dist/tests/curate-command.test.js +87 -0
- package/dist/tests/db-scoring.test.js +201 -0
- package/dist/tests/db.test.js +654 -0
- package/dist/tests/distill-cli-flag.test.js +208 -0
- package/dist/tests/distill.test.js +515 -0
- package/dist/tests/docker-install.test.js +120 -0
- package/dist/tests/e2e.test.js +1398 -0
- package/dist/tests/embedder.test.js +340 -0
- package/dist/tests/embedding-model-config.test.js +379 -0
- package/dist/tests/feedback-command.test.js +172 -0
- package/dist/tests/file-context.test.js +552 -0
- package/dist/tests/fixtures/scripts/git/summarize-diff.js +9 -0
- package/dist/tests/fixtures/scripts/lint/eslint-check.js +7 -0
- package/dist/tests/fixtures/stashes/load.js +166 -0
- package/dist/tests/fixtures/stashes/load.test.js +88 -0
- package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +12 -0
- package/dist/tests/frontmatter.test.js +190 -0
- package/dist/tests/fts-field-weighting.test.js +254 -0
- package/dist/tests/fuzzy-search.test.js +230 -0
- package/dist/tests/git-provider-clone.test.js +45 -0
- package/dist/tests/github.test.js +161 -0
- package/dist/tests/graph-boost-ranking.test.js +305 -0
- package/dist/tests/graph-extraction.test.js +282 -0
- package/dist/tests/helpers/usage-events.js +8 -0
- package/dist/tests/index-pass-llm.test.js +161 -0
- package/dist/tests/indexer.test.js +559 -0
- package/dist/tests/info-command.test.js +166 -0
- package/dist/tests/init.test.js +69 -0
- package/dist/tests/install-script.test.js +246 -0
- package/dist/tests/integration/agent-real-profile.test.js +94 -0
- package/dist/tests/issue-36-repro.test.js +304 -0
- package/dist/tests/issues-191-194.test.js +160 -0
- package/dist/tests/lesson-lint.test.js +111 -0
- package/dist/tests/llm-client.test.js +115 -0
- package/dist/tests/llm-feature-gate.test.js +151 -0
- package/dist/tests/llm.test.js +139 -0
- package/dist/tests/lockfile.test.js +216 -0
- package/dist/tests/manifest.test.js +205 -0
- package/dist/tests/markdown.test.js +126 -0
- package/dist/tests/matchers-unit.test.js +189 -0
- package/dist/tests/memory-inference.test.js +299 -0
- package/dist/tests/merge-scoring.test.js +136 -0
- package/dist/tests/metadata.test.js +313 -0
- package/dist/tests/migration-help.test.js +89 -0
- package/dist/tests/origin-resolve.test.js +124 -0
- package/dist/tests/output-baseline.test.js +217 -0
- package/dist/tests/output-shapes-unit.test.js +476 -0
- package/dist/tests/parallel-search.test.js +272 -0
- package/dist/tests/parameter-metadata.test.js +365 -0
- package/dist/tests/paths.test.js +177 -0
- package/dist/tests/progressive-disclosure.test.js +280 -0
- package/dist/tests/proposals.test.js +279 -0
- package/dist/tests/proposed-quality.test.js +271 -0
- package/dist/tests/provider-registry.test.js +32 -0
- package/dist/tests/ranking-regression.test.js +548 -0
- package/dist/tests/reflect-propose.test.js +455 -0
- package/dist/tests/registry-build-index.test.js +378 -0
- package/dist/tests/registry-cli.test.js +290 -0
- package/dist/tests/registry-index-v2.test.js +430 -0
- package/dist/tests/registry-install.test.js +728 -0
- package/dist/tests/registry-providers/parity.test.js +189 -0
- package/dist/tests/registry-providers/skills-sh.test.js +309 -0
- package/dist/tests/registry-providers/static-index.test.js +204 -0
- package/dist/tests/registry-resolve.test.js +126 -0
- package/dist/tests/registry-search.test.js +723 -0
- package/dist/tests/remember-frontmatter.test.js +380 -0
- package/dist/tests/remember-unit.test.js +123 -0
- package/dist/tests/ripgrep-install.test.js +251 -0
- package/dist/tests/ripgrep-resolve.test.js +108 -0
- package/dist/tests/ripgrep.test.js +163 -0
- package/dist/tests/save-command.test.js +94 -0
- package/dist/tests/save-trust-qa-fixes.test.js +270 -0
- package/dist/tests/scoring-pipeline.test.js +648 -0
- package/dist/tests/search-include-proposed-cli.test.js +118 -0
- package/dist/tests/self-update.test.js +442 -0
- package/dist/tests/semantic-search-e2e.test.js +512 -0
- package/dist/tests/semantic-status.test.js +471 -0
- package/dist/tests/setup-run.integration.js +877 -0
- package/dist/tests/setup-wizard.test.js +198 -0
- package/dist/tests/setup.test.js +131 -0
- package/dist/tests/source-add.test.js +11 -0
- package/dist/tests/source-clone.test.js +254 -0
- package/dist/tests/source-manage.test.js +366 -0
- package/dist/tests/source-providers/filesystem.test.js +82 -0
- package/dist/tests/source-providers/git.test.js +252 -0
- package/dist/tests/source-providers/website.test.js +128 -0
- package/dist/tests/source-qa-fixes.test.js +268 -0
- package/dist/tests/source-registry.test.js +350 -0
- package/dist/tests/source-resolve.test.js +100 -0
- package/dist/tests/source-source.test.js +221 -0
- package/dist/tests/source.test.js +533 -0
- package/dist/tests/tar-utils-scan.test.js +73 -0
- package/dist/tests/toggle-components.test.js +73 -0
- package/dist/tests/usage-telemetry.test.js +265 -0
- package/dist/tests/utility-scoring.test.js +558 -0
- package/dist/tests/vault-load-error.test.js +78 -0
- package/dist/tests/vault-qa-fixes.test.js +194 -0
- package/dist/tests/vault.test.js +429 -0
- package/dist/tests/vector-search.test.js +608 -0
- package/dist/tests/walker.test.js +252 -0
- package/dist/tests/wave2-cluster-bc.test.js +228 -0
- package/dist/tests/wave2-cluster-d.test.js +180 -0
- package/dist/tests/wave2-cluster-e.test.js +179 -0
- package/dist/tests/wiki-qa-fixes.test.js +270 -0
- package/dist/tests/wiki.test.js +529 -0
- package/dist/tests/workflow-cli.test.js +271 -0
- package/dist/tests/workflow-markdown.test.js +171 -0
- package/dist/tests/workflow-path-escape.test.js +132 -0
- package/dist/tests/workflow-qa-fixes.test.js +377 -0
- package/dist/tests/workflows/indexer-rejection.test.js +213 -0
- package/docs/README.md +8 -0
- package/docs/migration/release-notes/0.7.0.md +244 -0
- package/package.json +2 -2
- package/dist/core/warn.js +0 -27
- package/dist/output/shapes.js +0 -212
- /package/dist/{commands → src/commands}/completions.js +0 -0
- /package/dist/{commands → src/commands}/curate.js +0 -0
- /package/dist/{commands → src/commands}/info.js +0 -0
- /package/dist/{commands → src/commands}/init.js +0 -0
- /package/dist/{commands → src/commands}/install-audit.js +0 -0
- /package/dist/{commands → src/commands}/migration-help.js +0 -0
- /package/dist/{commands → src/commands}/source-add.js +0 -0
- /package/dist/{commands → src/commands}/source-clone.js +0 -0
- /package/dist/{commands → src/commands}/source-manage.js +0 -0
- /package/dist/{commands → src/commands}/vault.js +0 -0
- /package/dist/{core → src/core}/asset-registry.js +0 -0
- /package/dist/{core → src/core}/frontmatter.js +0 -0
- /package/dist/{core → src/core}/markdown.js +0 -0
- /package/dist/{core → src/core}/paths.js +0 -0
- /package/dist/{indexer → src/indexer}/manifest.js +0 -0
- /package/dist/{indexer → src/indexer}/matchers.js +0 -0
- /package/dist/{indexer → src/indexer}/search-fields.js +0 -0
- /package/dist/{indexer → src/indexer}/search-source.js +0 -0
- /package/dist/{indexer → src/indexer}/semantic-status.js +0 -0
- /package/dist/{indexer → src/indexer}/usage-events.js +0 -0
- /package/dist/{indexer → src/indexer}/walker.js +0 -0
- /package/dist/{integrations → src/integrations}/github.js +0 -0
- /package/dist/{llm → src/llm}/embedder.js +0 -0
- /package/dist/{llm → src/llm}/embedders/cache.js +0 -0
- /package/dist/{llm → src/llm}/embedders/local.js +0 -0
- /package/dist/{llm → src/llm}/embedders/remote.js +0 -0
- /package/dist/{llm → src/llm}/embedders/types.js +0 -0
- /package/dist/{llm → src/llm}/metadata-enhance.js +0 -0
- /package/dist/{output → src/output}/cli-hints.js +0 -0
- /package/dist/{output → src/output}/context.js +0 -0
- /package/dist/{registry → src/registry}/create-provider-registry.js +0 -0
- /package/dist/{registry → src/registry}/origin-resolve.js +0 -0
- /package/dist/{registry → src/registry}/providers/index.js +0 -0
- /package/dist/{registry → src/registry}/providers/skills-sh.js +0 -0
- /package/dist/{registry → src/registry}/providers/types.js +0 -0
- /package/dist/{registry → src/registry}/types.js +0 -0
- /package/dist/{setup → src/setup}/detect.js +0 -0
- /package/dist/{setup → src/setup}/ripgrep-install.js +0 -0
- /package/dist/{setup → src/setup}/ripgrep-resolve.js +0 -0
- /package/dist/{setup → src/setup}/steps.js +0 -0
- /package/dist/{sources → src/sources}/include.js +0 -0
- /package/dist/{sources → src/sources}/provider-factory.js +0 -0
- /package/dist/{sources → src/sources}/provider.js +0 -0
- /package/dist/{sources → src/sources}/providers/filesystem.js +0 -0
- /package/dist/{sources → src/sources}/providers/index.js +0 -0
- /package/dist/{sources → src/sources}/providers/install-types.js +0 -0
- /package/dist/{sources → src/sources}/providers/npm.js +0 -0
- /package/dist/{sources → src/sources}/providers/provider-utils.js +0 -0
- /package/dist/{sources → src/sources}/providers/sync-from-ref.js +0 -0
- /package/dist/{sources → src/sources}/providers/tar-utils.js +0 -0
- /package/dist/{sources → src/sources}/providers/website.js +0 -0
- /package/dist/{sources → src/sources}/resolve.js +0 -0
- /package/dist/{sources → src/sources}/types.js +0 -0
- /package/dist/{templates → src/templates}/wiki-templates.js +0 -0
- /package/dist/{version.js → src/version.js} +0 -0
- /package/dist/{wiki → src/wiki}/wiki.js +0 -0
- /package/dist/{workflows → src/workflows}/authoring.js +0 -0
- /package/dist/{workflows → src/workflows}/cli.js +0 -0
- /package/dist/{workflows → src/workflows}/db.js +0 -0
- /package/dist/{workflows → src/workflows}/document-cache.js +0 -0
- /package/dist/{workflows → src/workflows}/parser.js +0 -0
- /package/dist/{workflows → src/workflows}/renderer.js +0 -0
- /package/dist/{workflows → src/workflows}/runs.js +0 -0
- /package/dist/{workflows → src/workflows}/schema.js +0 -0
- /package/dist/{workflows → src/workflows}/validator.js +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { getBinDir, getCacheDir, getConfigDir, getConfigPath, getDbPath, getDefaultStashDir, getRegistryCacheDir, getRegistryIndexCacheDir, getWorkflowDbPath, } from "../src/core/paths";
|
|
4
|
+
// ── Environment helpers ─────────────────────────────────────────────────────
|
|
5
|
+
const savedEnv = {};
|
|
6
|
+
const envKeys = [
|
|
7
|
+
"XDG_CONFIG_HOME",
|
|
8
|
+
"XDG_CACHE_HOME",
|
|
9
|
+
"HOME",
|
|
10
|
+
"APPDATA",
|
|
11
|
+
"LOCALAPPDATA",
|
|
12
|
+
"USERPROFILE",
|
|
13
|
+
"AKM_CONFIG_DIR",
|
|
14
|
+
"AKM_CACHE_DIR",
|
|
15
|
+
"AKM_STASH_DIR",
|
|
16
|
+
];
|
|
17
|
+
function saveEnv() {
|
|
18
|
+
for (const key of envKeys) {
|
|
19
|
+
savedEnv[key] = process.env[key];
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
function restoreEnv() {
|
|
23
|
+
for (const key of envKeys) {
|
|
24
|
+
if (savedEnv[key] === undefined) {
|
|
25
|
+
delete process.env[key];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
process.env[key] = savedEnv[key];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
saveEnv();
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
restoreEnv();
|
|
35
|
+
});
|
|
36
|
+
// ── getConfigDir ────────────────────────────────────────────────────────────
|
|
37
|
+
describe("getConfigDir", () => {
|
|
38
|
+
test("uses XDG_CONFIG_HOME on Unix", () => {
|
|
39
|
+
const result = getConfigDir({ XDG_CONFIG_HOME: "/custom/config" }, "linux");
|
|
40
|
+
expect(result).toBe(path.join("/custom/config", "akm"));
|
|
41
|
+
});
|
|
42
|
+
test("falls back to HOME/.config on Unix when XDG_CONFIG_HOME is unset", () => {
|
|
43
|
+
const result = getConfigDir({ HOME: "/home/user" }, "linux");
|
|
44
|
+
expect(result).toBe(path.join("/home/user", ".config", "akm"));
|
|
45
|
+
});
|
|
46
|
+
test("throws on Unix when HOME and XDG_CONFIG_HOME are both unset", () => {
|
|
47
|
+
expect(() => getConfigDir({}, "linux")).toThrow("Unable to determine config directory. Set XDG_CONFIG_HOME or HOME.");
|
|
48
|
+
});
|
|
49
|
+
test("uses APPDATA on Windows", () => {
|
|
50
|
+
const result = getConfigDir({ APPDATA: String.raw `C:\Users\user\AppData\Roaming` }, "win32");
|
|
51
|
+
expect(result).toBe(path.join(String.raw `C:\Users\user\AppData\Roaming`, "akm"));
|
|
52
|
+
});
|
|
53
|
+
test("falls back to USERPROFILE on Windows when APPDATA is unset", () => {
|
|
54
|
+
const result = getConfigDir({ USERPROFILE: String.raw `C:\Users\user` }, "win32");
|
|
55
|
+
expect(result).toBe(path.join(String.raw `C:\Users\user`, "AppData", "Roaming", "akm"));
|
|
56
|
+
});
|
|
57
|
+
test("throws on Windows when APPDATA and USERPROFILE are both unset", () => {
|
|
58
|
+
expect(() => getConfigDir({}, "win32")).toThrow("Unable to determine config directory. Set APPDATA or USERPROFILE.");
|
|
59
|
+
});
|
|
60
|
+
test("trims whitespace from XDG_CONFIG_HOME", () => {
|
|
61
|
+
const result = getConfigDir({ XDG_CONFIG_HOME: " /trimmed " }, "linux");
|
|
62
|
+
expect(result).toBe(path.join("/trimmed", "akm"));
|
|
63
|
+
});
|
|
64
|
+
test("trims whitespace from HOME", () => {
|
|
65
|
+
const result = getConfigDir({ HOME: " /home/user " }, "linux");
|
|
66
|
+
expect(result).toBe(path.join("/home/user", ".config", "akm"));
|
|
67
|
+
});
|
|
68
|
+
test("ignores empty XDG_CONFIG_HOME and falls back to HOME", () => {
|
|
69
|
+
const result = getConfigDir({ XDG_CONFIG_HOME: " ", HOME: "/home/user" }, "linux");
|
|
70
|
+
expect(result).toBe(path.join("/home/user", ".config", "akm"));
|
|
71
|
+
});
|
|
72
|
+
test("ignores empty APPDATA on Windows and falls back to USERPROFILE", () => {
|
|
73
|
+
const result = getConfigDir({ APPDATA: " ", USERPROFILE: String.raw `C:\Users\user` }, "win32");
|
|
74
|
+
expect(result).toBe(path.join(String.raw `C:\Users\user`, "AppData", "Roaming", "akm"));
|
|
75
|
+
});
|
|
76
|
+
test("uses default process.env when env argument omitted", () => {
|
|
77
|
+
process.env.XDG_CONFIG_HOME = "/test-xdg";
|
|
78
|
+
const result = getConfigDir();
|
|
79
|
+
expect(result).toBe(path.join("/test-xdg", "akm"));
|
|
80
|
+
});
|
|
81
|
+
test("uses darwin platform same as linux (XDG path)", () => {
|
|
82
|
+
const result = getConfigDir({ XDG_CONFIG_HOME: "/darwin/cfg" }, "darwin");
|
|
83
|
+
expect(result).toBe(path.join("/darwin/cfg", "akm"));
|
|
84
|
+
});
|
|
85
|
+
test("AKM_CONFIG_DIR overrides all other paths", () => {
|
|
86
|
+
const result = getConfigDir({ AKM_CONFIG_DIR: "/override/config", HOME: "/home/user" }, "linux");
|
|
87
|
+
expect(result).toBe("/override/config");
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
// ── getConfigPath ───────────────────────────────────────────────────────────
|
|
91
|
+
describe("getConfigPath", () => {
|
|
92
|
+
test("returns config.json under config dir", () => {
|
|
93
|
+
process.env.XDG_CONFIG_HOME = "/test-cfg";
|
|
94
|
+
expect(getConfigPath()).toBe(path.join("/test-cfg", "akm", "config.json"));
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
// ── getCacheDir ─────────────────────────────────────────────────────────────
|
|
98
|
+
describe("getCacheDir", () => {
|
|
99
|
+
test("uses XDG_CACHE_HOME on Unix", () => {
|
|
100
|
+
delete process.env.AKM_CACHE_DIR;
|
|
101
|
+
process.env.XDG_CACHE_HOME = "/custom/cache";
|
|
102
|
+
const result = getCacheDir();
|
|
103
|
+
expect(result).toBe(path.join("/custom/cache", "akm"));
|
|
104
|
+
});
|
|
105
|
+
test("falls back to HOME/.cache on Unix when XDG_CACHE_HOME is unset", () => {
|
|
106
|
+
delete process.env.AKM_CACHE_DIR;
|
|
107
|
+
delete process.env.XDG_CACHE_HOME;
|
|
108
|
+
process.env.HOME = "/home/user";
|
|
109
|
+
const result = getCacheDir();
|
|
110
|
+
expect(result).toBe(path.join("/home/user", ".cache", "akm"));
|
|
111
|
+
});
|
|
112
|
+
test("falls back to /tmp/akm-cache when HOME is also unset", () => {
|
|
113
|
+
delete process.env.AKM_CACHE_DIR;
|
|
114
|
+
delete process.env.XDG_CACHE_HOME;
|
|
115
|
+
delete process.env.HOME;
|
|
116
|
+
const result = getCacheDir();
|
|
117
|
+
expect(result).toBe(path.join("/tmp", "akm-cache"));
|
|
118
|
+
});
|
|
119
|
+
test("AKM_CACHE_DIR overrides all other paths", () => {
|
|
120
|
+
process.env.AKM_CACHE_DIR = "/override/cache";
|
|
121
|
+
const result = getCacheDir();
|
|
122
|
+
expect(result).toBe("/override/cache");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
// ── getDbPath ───────────────────────────────────────────────────────────────
|
|
126
|
+
describe("getDbPath", () => {
|
|
127
|
+
test("returns index.db under cache dir", () => {
|
|
128
|
+
process.env.XDG_CACHE_HOME = "/cache";
|
|
129
|
+
expect(getDbPath()).toBe(path.join("/cache", "akm", "index.db"));
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe("getWorkflowDbPath", () => {
|
|
133
|
+
test("returns workflow.db under cache dir", () => {
|
|
134
|
+
process.env.XDG_CACHE_HOME = "/cache";
|
|
135
|
+
expect(getWorkflowDbPath()).toBe(path.join("/cache", "akm", "workflow.db"));
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
// ── getRegistryCacheDir ─────────────────────────────────────────────────────
|
|
139
|
+
describe("getRegistryCacheDir", () => {
|
|
140
|
+
test("returns registry subdir under cache dir", () => {
|
|
141
|
+
process.env.XDG_CACHE_HOME = "/cache";
|
|
142
|
+
expect(getRegistryCacheDir()).toBe(path.join("/cache", "akm", "registry"));
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
// ── getRegistryIndexCacheDir ────────────────────────────────────────────────
|
|
146
|
+
describe("getRegistryIndexCacheDir", () => {
|
|
147
|
+
test("returns registry-index subdir under cache dir", () => {
|
|
148
|
+
process.env.XDG_CACHE_HOME = "/cache";
|
|
149
|
+
expect(getRegistryIndexCacheDir()).toBe(path.join("/cache", "akm", "registry-index"));
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
// ── getBinDir ───────────────────────────────────────────────────────────────
|
|
153
|
+
describe("getBinDir", () => {
|
|
154
|
+
test("returns bin subdir under cache dir", () => {
|
|
155
|
+
process.env.XDG_CACHE_HOME = "/cache";
|
|
156
|
+
expect(getBinDir()).toBe(path.join("/cache", "akm", "bin"));
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
// ── getDefaultStashDir ──────────────────────────────────────────────────────
|
|
160
|
+
describe("getDefaultStashDir", () => {
|
|
161
|
+
test("returns HOME/akm on Unix", () => {
|
|
162
|
+
delete process.env.AKM_STASH_DIR;
|
|
163
|
+
process.env.HOME = "/home/user";
|
|
164
|
+
const result = getDefaultStashDir();
|
|
165
|
+
expect(result).toBe(path.join("/home/user", "akm"));
|
|
166
|
+
});
|
|
167
|
+
test("throws when HOME is unset on Unix", () => {
|
|
168
|
+
delete process.env.AKM_STASH_DIR;
|
|
169
|
+
delete process.env.HOME;
|
|
170
|
+
expect(() => getDefaultStashDir()).toThrow("Unable to determine default stash directory. Set HOME.");
|
|
171
|
+
});
|
|
172
|
+
test("AKM_STASH_DIR overrides all other paths", () => {
|
|
173
|
+
process.env.AKM_STASH_DIR = "/override/stash";
|
|
174
|
+
const result = getDefaultStashDir();
|
|
175
|
+
expect(result).toBe("/override/stash");
|
|
176
|
+
});
|
|
177
|
+
});
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { akmShowUnified as akmShow } from "../src/commands/show";
|
|
6
|
+
import { saveConfig } from "../src/core/config";
|
|
7
|
+
import { buildDbHit } from "../src/indexer/db-search";
|
|
8
|
+
// Trigger source-provider self-registration
|
|
9
|
+
import "../src/sources/providers/index";
|
|
10
|
+
const createdTmpDirs = [];
|
|
11
|
+
function createTmpDir(prefix = "akm-prog-") {
|
|
12
|
+
const dir = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
|
13
|
+
createdTmpDirs.push(dir);
|
|
14
|
+
return dir;
|
|
15
|
+
}
|
|
16
|
+
function writeFile(filePath, content = "") {
|
|
17
|
+
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
18
|
+
fs.writeFileSync(filePath, content);
|
|
19
|
+
}
|
|
20
|
+
function writeStashJson(dirPath, entries) {
|
|
21
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
22
|
+
fs.writeFileSync(path.join(dirPath, ".stash.json"), JSON.stringify({ entries }));
|
|
23
|
+
}
|
|
24
|
+
afterAll(() => {
|
|
25
|
+
for (const dir of createdTmpDirs) {
|
|
26
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
const originalXdgCacheHome = process.env.XDG_CACHE_HOME;
|
|
30
|
+
const originalXdgConfigHome = process.env.XDG_CONFIG_HOME;
|
|
31
|
+
const originalStashDir = process.env.AKM_STASH_DIR;
|
|
32
|
+
let testCacheDir = "";
|
|
33
|
+
let testConfigDir = "";
|
|
34
|
+
let stashDir = "";
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
testCacheDir = createTmpDir("akm-prog-cache-");
|
|
37
|
+
testConfigDir = createTmpDir("akm-prog-config-");
|
|
38
|
+
stashDir = createTmpDir("akm-prog-stash-");
|
|
39
|
+
for (const sub of ["scripts", "skills", "commands", "agents", "knowledge"]) {
|
|
40
|
+
fs.mkdirSync(path.join(stashDir, sub), { recursive: true });
|
|
41
|
+
}
|
|
42
|
+
process.env.XDG_CACHE_HOME = testCacheDir;
|
|
43
|
+
process.env.XDG_CONFIG_HOME = testConfigDir;
|
|
44
|
+
process.env.AKM_STASH_DIR = stashDir;
|
|
45
|
+
});
|
|
46
|
+
afterEach(() => {
|
|
47
|
+
if (originalXdgCacheHome === undefined) {
|
|
48
|
+
delete process.env.XDG_CACHE_HOME;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
process.env.XDG_CACHE_HOME = originalXdgCacheHome;
|
|
52
|
+
}
|
|
53
|
+
if (originalXdgConfigHome === undefined) {
|
|
54
|
+
delete process.env.XDG_CONFIG_HOME;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
process.env.XDG_CONFIG_HOME = originalXdgConfigHome;
|
|
58
|
+
}
|
|
59
|
+
if (originalStashDir === undefined) {
|
|
60
|
+
delete process.env.AKM_STASH_DIR;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
process.env.AKM_STASH_DIR = originalStashDir;
|
|
64
|
+
}
|
|
65
|
+
if (testCacheDir) {
|
|
66
|
+
fs.rmSync(testCacheDir, { recursive: true, force: true });
|
|
67
|
+
testCacheDir = "";
|
|
68
|
+
}
|
|
69
|
+
if (testConfigDir) {
|
|
70
|
+
fs.rmSync(testConfigDir, { recursive: true, force: true });
|
|
71
|
+
testConfigDir = "";
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
// ── Test 1: Summary show returns compact output ─────────────────────────────
|
|
75
|
+
describe("summary show", () => {
|
|
76
|
+
test("returns name, type, description and omits full content for skills", async () => {
|
|
77
|
+
const longContent = "This is a detailed skill document.\n".repeat(100);
|
|
78
|
+
// Skills use the directory/SKILL.md convention
|
|
79
|
+
writeFile(path.join(stashDir, "skills", "code-review", "SKILL.md"), `---\ndescription: Reviews code for quality issues\n---\n${longContent}`);
|
|
80
|
+
// Provide .stash.json with tags for the skill
|
|
81
|
+
writeStashJson(path.join(stashDir, "skills", "code-review"), [
|
|
82
|
+
{
|
|
83
|
+
name: "code-review",
|
|
84
|
+
type: "skill",
|
|
85
|
+
description: "Reviews code for quality issues",
|
|
86
|
+
tags: ["code", "review", "quality"],
|
|
87
|
+
filename: "SKILL.md",
|
|
88
|
+
},
|
|
89
|
+
]);
|
|
90
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
91
|
+
const result = await akmShow({ ref: "skill:code-review", detail: "summary" });
|
|
92
|
+
expect(result.type).toBe("skill");
|
|
93
|
+
expect(result.name).toBe("code-review");
|
|
94
|
+
expect(result.description).toBe("Reviews code for quality issues");
|
|
95
|
+
expect(result.tags).toEqual(["code", "review", "quality"]);
|
|
96
|
+
// Summary should NOT include the full content
|
|
97
|
+
expect(result.content).toBeUndefined();
|
|
98
|
+
expect(result.template).toBeUndefined();
|
|
99
|
+
expect(result.prompt).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
test("returns parameters for command assets in summary mode", async () => {
|
|
102
|
+
writeFile(path.join(stashDir, "commands", "release.md"), "---\ndescription: Release a new version\n---\nRelease $ARGUMENTS to production with {{env}}.");
|
|
103
|
+
writeStashJson(path.join(stashDir, "commands"), [
|
|
104
|
+
{
|
|
105
|
+
name: "release",
|
|
106
|
+
type: "command",
|
|
107
|
+
description: "Release a new version",
|
|
108
|
+
tags: ["release", "deploy"],
|
|
109
|
+
filename: "release.md",
|
|
110
|
+
},
|
|
111
|
+
]);
|
|
112
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
113
|
+
const result = await akmShow({ ref: "command:release", detail: "summary" });
|
|
114
|
+
expect(result.type).toBe("command");
|
|
115
|
+
expect(result.name).toBe("release");
|
|
116
|
+
expect(result.description).toBe("Release a new version");
|
|
117
|
+
expect(result.tags).toEqual(["release", "deploy"]);
|
|
118
|
+
expect(result.parameters).toEqual(["ARGUMENTS", "env"]);
|
|
119
|
+
// No template content in summary
|
|
120
|
+
expect(result.template).toBeUndefined();
|
|
121
|
+
expect(result.content).toBeUndefined();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
// ── Test 2: Summary output is under 200 tokens ─────────────────────────────
|
|
125
|
+
describe("summary token budget", () => {
|
|
126
|
+
test("summary response is under 200 tokens (roughly estimated)", async () => {
|
|
127
|
+
const longContent = "A ".repeat(2000); // 4000+ chars of content
|
|
128
|
+
writeFile(path.join(stashDir, "skills", "big-skill", "SKILL.md"), `---\ndescription: A moderately described skill for testing\n---\n${longContent}`);
|
|
129
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
130
|
+
const result = await akmShow({ ref: "skill:big-skill", detail: "summary" });
|
|
131
|
+
// Rough token estimate: JSON.stringify length / 4
|
|
132
|
+
const serialized = JSON.stringify(result);
|
|
133
|
+
const estimatedTokens = serialized.length / 4;
|
|
134
|
+
expect(estimatedTokens).toBeLessThan(200);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
// ── Test 3: Full show is unchanged ──────────────────────────────────────────
|
|
138
|
+
describe("full show unchanged", () => {
|
|
139
|
+
test("show without detail param returns complete content (default behavior)", async () => {
|
|
140
|
+
const content = "# Full Skill\n\nDo all the things in detail.";
|
|
141
|
+
writeFile(path.join(stashDir, "skills", "full-skill", "SKILL.md"), content);
|
|
142
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
143
|
+
const result = await akmShow({ ref: "skill:full-skill" });
|
|
144
|
+
expect(result.type).toBe("skill");
|
|
145
|
+
expect(result.content).toBe(content);
|
|
146
|
+
});
|
|
147
|
+
test("show with detail=full returns complete content", async () => {
|
|
148
|
+
const content = "# Full Skill\n\nDo all the things in detail.";
|
|
149
|
+
writeFile(path.join(stashDir, "skills", "full-skill", "SKILL.md"), content);
|
|
150
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
151
|
+
const result = await akmShow({ ref: "skill:full-skill", detail: "full" });
|
|
152
|
+
expect(result.type).toBe("skill");
|
|
153
|
+
expect(result.content).toBe(content);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
// ── Test 4: estimatedTokens is populated in search hits ─────────────────────
|
|
157
|
+
describe("estimatedTokens in search hits", () => {
|
|
158
|
+
test("buildDbHit includes estimatedTokens derived from fileSize", async () => {
|
|
159
|
+
const entry = {
|
|
160
|
+
name: "test-script",
|
|
161
|
+
type: "script",
|
|
162
|
+
description: "A test script",
|
|
163
|
+
tags: ["test"],
|
|
164
|
+
fileSize: 1000,
|
|
165
|
+
};
|
|
166
|
+
const tmpDir = createTmpDir("akm-prog-hit-");
|
|
167
|
+
const filePath = path.join(tmpDir, "scripts", "test-script.sh");
|
|
168
|
+
writeFile(filePath, "#!/bin/bash\necho hello");
|
|
169
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
170
|
+
const hit = await buildDbHit({
|
|
171
|
+
entry,
|
|
172
|
+
path: filePath,
|
|
173
|
+
score: 0.5,
|
|
174
|
+
query: "test",
|
|
175
|
+
rankingMode: "fts",
|
|
176
|
+
defaultStashDir: tmpDir,
|
|
177
|
+
allSourceDirs: [tmpDir],
|
|
178
|
+
sources: [{ path: tmpDir }],
|
|
179
|
+
config: { semanticSearchMode: "off" },
|
|
180
|
+
});
|
|
181
|
+
expect(hit.estimatedTokens).toBeDefined();
|
|
182
|
+
expect(typeof hit.estimatedTokens).toBe("number");
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
// ── Test 5: estimatedTokens approximation is reasonable ─────────────────────
|
|
186
|
+
describe("estimatedTokens approximation", () => {
|
|
187
|
+
test("a 1000-byte file should have estimatedTokens around 250 (1000/4)", async () => {
|
|
188
|
+
const entry = {
|
|
189
|
+
name: "sized-script",
|
|
190
|
+
type: "script",
|
|
191
|
+
description: "A sized script",
|
|
192
|
+
fileSize: 1000,
|
|
193
|
+
};
|
|
194
|
+
const tmpDir = createTmpDir("akm-prog-tokens-");
|
|
195
|
+
const filePath = path.join(tmpDir, "scripts", "sized-script.sh");
|
|
196
|
+
writeFile(filePath, "x".repeat(1000));
|
|
197
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
198
|
+
const hit = await buildDbHit({
|
|
199
|
+
entry,
|
|
200
|
+
path: filePath,
|
|
201
|
+
score: 0.5,
|
|
202
|
+
query: "sized",
|
|
203
|
+
rankingMode: "fts",
|
|
204
|
+
defaultStashDir: tmpDir,
|
|
205
|
+
allSourceDirs: [tmpDir],
|
|
206
|
+
sources: [{ path: tmpDir }],
|
|
207
|
+
config: { semanticSearchMode: "off" },
|
|
208
|
+
});
|
|
209
|
+
expect(hit.estimatedTokens).toBe(250);
|
|
210
|
+
});
|
|
211
|
+
test("estimatedTokens is undefined when fileSize is not set", async () => {
|
|
212
|
+
const entry = {
|
|
213
|
+
name: "no-size",
|
|
214
|
+
type: "script",
|
|
215
|
+
description: "No file size",
|
|
216
|
+
};
|
|
217
|
+
const tmpDir = createTmpDir("akm-prog-nosize-");
|
|
218
|
+
const filePath = path.join(tmpDir, "scripts", "no-size.sh");
|
|
219
|
+
writeFile(filePath, "echo hi");
|
|
220
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
221
|
+
const hit = await buildDbHit({
|
|
222
|
+
entry,
|
|
223
|
+
path: filePath,
|
|
224
|
+
score: 0.5,
|
|
225
|
+
query: "no",
|
|
226
|
+
rankingMode: "fts",
|
|
227
|
+
defaultStashDir: tmpDir,
|
|
228
|
+
allSourceDirs: [tmpDir],
|
|
229
|
+
sources: [{ path: tmpDir }],
|
|
230
|
+
config: { semanticSearchMode: "off" },
|
|
231
|
+
});
|
|
232
|
+
expect(hit.estimatedTokens).toBeUndefined();
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
// ── Test 6: Summary show works for different asset types ────────────────────
|
|
236
|
+
describe("summary show for different asset types", () => {
|
|
237
|
+
test("skill summary omits content", async () => {
|
|
238
|
+
writeFile(path.join(stashDir, "skills", "analyze", "SKILL.md"), "---\ndescription: Analyze code patterns\n---\n# Analysis Skill\n\nDetailed instructions here.");
|
|
239
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
240
|
+
const result = await akmShow({ ref: "skill:analyze", detail: "summary" });
|
|
241
|
+
expect(result.type).toBe("skill");
|
|
242
|
+
expect(result.description).toBe("Analyze code patterns");
|
|
243
|
+
expect(result.content).toBeUndefined();
|
|
244
|
+
});
|
|
245
|
+
test("command summary omits template but keeps parameters", async () => {
|
|
246
|
+
writeFile(path.join(stashDir, "commands", "deploy.md"), "---\ndescription: Deploy to env\n---\nDeploy $ARGUMENTS to {{env}}.");
|
|
247
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
248
|
+
const result = await akmShow({ ref: "command:deploy", detail: "summary" });
|
|
249
|
+
expect(result.type).toBe("command");
|
|
250
|
+
expect(result.description).toBe("Deploy to env");
|
|
251
|
+
expect(result.parameters).toBeDefined();
|
|
252
|
+
expect(result.template).toBeUndefined();
|
|
253
|
+
});
|
|
254
|
+
test("agent summary omits prompt", async () => {
|
|
255
|
+
writeFile(path.join(stashDir, "agents", "architect.md"), "---\ndescription: Architecture advisor\ntools:\n read: allow\n---\nYou are an architecture advisor. Provide detailed guidance.");
|
|
256
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
257
|
+
const result = await akmShow({ ref: "agent:architect", detail: "summary" });
|
|
258
|
+
expect(result.type).toBe("agent");
|
|
259
|
+
expect(result.description).toBe("Architecture advisor");
|
|
260
|
+
expect(result.prompt).toBeUndefined();
|
|
261
|
+
expect(result.content).toBeUndefined();
|
|
262
|
+
});
|
|
263
|
+
test("script summary omits content", async () => {
|
|
264
|
+
writeFile(path.join(stashDir, "scripts", "deploy.sh"), "#!/usr/bin/env bash\necho deploy");
|
|
265
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
266
|
+
const result = await akmShow({ ref: "script:deploy.sh", detail: "summary" });
|
|
267
|
+
expect(result.type).toBe("script");
|
|
268
|
+
expect(result.content).toBeUndefined();
|
|
269
|
+
// Summary preserves run (action metadata) but omits content body
|
|
270
|
+
expect(result.run).toBeDefined();
|
|
271
|
+
});
|
|
272
|
+
test("knowledge summary omits content", async () => {
|
|
273
|
+
writeFile(path.join(stashDir, "knowledge", "api-guide.md"), "---\ndescription: API reference guide\n---\n# API Guide\n\nLots of detailed API documentation here.");
|
|
274
|
+
saveConfig({ semanticSearchMode: "off" });
|
|
275
|
+
const result = await akmShow({ ref: "knowledge:api-guide", detail: "summary" });
|
|
276
|
+
expect(result.type).toBe("knowledge");
|
|
277
|
+
expect(result.description).toBe("API reference guide");
|
|
278
|
+
expect(result.content).toBeUndefined();
|
|
279
|
+
});
|
|
280
|
+
});
|