akm-cli 0.7.0-rc1 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{src/cli.js → cli.js} +100 -16
- package/dist/{src/commands → commands}/config-cli.js +42 -0
- package/dist/{src/commands → commands}/history.js +78 -7
- package/dist/{src/commands → commands}/registry-search.js +69 -6
- package/dist/{src/commands → commands}/search.js +30 -3
- package/dist/{src/commands → commands}/show.js +29 -0
- package/dist/{src/commands → commands}/source-add.js +5 -1
- package/dist/{src/commands → commands}/source-manage.js +7 -1
- package/dist/{src/core → core}/config.js +28 -0
- package/dist/{src/indexer → indexer}/db-search.js +1 -0
- package/dist/{src/indexer → indexer}/indexer.js +16 -2
- package/dist/{src/indexer → indexer}/matchers.js +1 -1
- package/dist/{src/indexer → indexer}/search-source.js +4 -2
- package/dist/{src/integrations → integrations}/agent/profiles.js +1 -1
- package/dist/{src/integrations → integrations}/agent/spawn.js +67 -16
- package/dist/{src/integrations → integrations}/github.js +9 -3
- package/dist/{src/llm → llm}/embedders/remote.js +37 -3
- package/dist/{src/output → output}/cli-hints.js +15 -2
- package/dist/{src/output → output}/renderers.js +3 -1
- package/dist/{src/output → output}/shapes.js +8 -1
- package/dist/{src/output → output}/text.js +156 -3
- package/dist/{src/registry → registry}/build-index.js +5 -4
- package/dist/{src/registry → registry}/providers/static-index.js +3 -1
- package/dist/{src/setup → setup}/setup.js +9 -0
- package/dist/{src/wiki → wiki}/wiki.js +54 -6
- package/dist/{src/workflows → workflows}/runs.js +37 -3
- package/package.json +8 -8
- package/dist/tests/add-website-source.test.js +0 -119
- package/dist/tests/agent/agent-config-loader.test.js +0 -70
- package/dist/tests/agent/agent-config.test.js +0 -221
- package/dist/tests/agent/agent-detect.test.js +0 -100
- package/dist/tests/agent/agent-spawn.test.js +0 -234
- package/dist/tests/agent-output.test.js +0 -186
- package/dist/tests/architecture/agent-no-llm-sdk-guard.test.js +0 -103
- package/dist/tests/architecture/agent-spawn-seam.test.js +0 -193
- package/dist/tests/architecture/llm-stateless-seam.test.js +0 -112
- package/dist/tests/asset-ref.test.js +0 -192
- package/dist/tests/asset-registry.test.js +0 -103
- package/dist/tests/asset-spec.test.js +0 -241
- package/dist/tests/bench/attribution.test.js +0 -995
- package/dist/tests/bench/cleanup-sigint.test.js +0 -83
- package/dist/tests/bench/cleanup.js +0 -203
- package/dist/tests/bench/cleanup.test.js +0 -166
- package/dist/tests/bench/cli.js +0 -683
- package/dist/tests/bench/cli.test.js +0 -177
- package/dist/tests/bench/compare.test.js +0 -556
- package/dist/tests/bench/corpus.js +0 -314
- package/dist/tests/bench/corpus.test.js +0 -258
- package/dist/tests/bench/driver.js +0 -346
- package/dist/tests/bench/driver.test.js +0 -443
- package/dist/tests/bench/evolve-metrics.js +0 -179
- package/dist/tests/bench/evolve-metrics.test.js +0 -187
- package/dist/tests/bench/evolve.js +0 -580
- package/dist/tests/bench/evolve.test.js +0 -616
- package/dist/tests/bench/failure-modes.test.js +0 -300
- package/dist/tests/bench/feedback-integrity.test.js +0 -456
- package/dist/tests/bench/leakage.test.js +0 -125
- package/dist/tests/bench/learning-curve.test.js +0 -133
- package/dist/tests/bench/metrics.js +0 -2319
- package/dist/tests/bench/metrics.test.js +0 -1144
- package/dist/tests/bench/no-os-tmpdir-invariant.test.js +0 -43
- package/dist/tests/bench/report.js +0 -1821
- package/dist/tests/bench/report.test.js +0 -989
- package/dist/tests/bench/runner.js +0 -536
- package/dist/tests/bench/runner.test.js +0 -958
- package/dist/tests/bench/search-bridge.test.js +0 -331
- package/dist/tests/bench/tmp.js +0 -41
- package/dist/tests/bench/trajectory.js +0 -116
- package/dist/tests/bench/trajectory.test.js +0 -127
- package/dist/tests/bench/verifier.js +0 -109
- package/dist/tests/bench/verifier.test.js +0 -118
- package/dist/tests/bench/workflow-evaluator.js +0 -557
- package/dist/tests/bench/workflow-evaluator.test.js +0 -421
- package/dist/tests/bench/workflow-spec.js +0 -358
- package/dist/tests/bench/workflow-spec.test.js +0 -363
- package/dist/tests/bench/workflow-trace.js +0 -438
- package/dist/tests/bench/workflow-trace.test.js +0 -254
- package/dist/tests/benchmark-search-quality.js +0 -536
- package/dist/tests/benchmark-suite.js +0 -1441
- package/dist/tests/capture-cli.test.js +0 -112
- package/dist/tests/cli-errors.test.js +0 -203
- package/dist/tests/commands/events.test.js +0 -370
- package/dist/tests/commands/history.test.js +0 -223
- package/dist/tests/commands/import.test.js +0 -103
- package/dist/tests/commands/proposal-cli.test.js +0 -209
- package/dist/tests/commands/reflect-propose-cli.test.js +0 -333
- package/dist/tests/commands/remember.test.js +0 -97
- package/dist/tests/commands/scope-flags.test.js +0 -300
- package/dist/tests/commands/search.test.js +0 -537
- package/dist/tests/commands/show-indexer-parity.test.js +0 -117
- package/dist/tests/commands/show.test.js +0 -294
- package/dist/tests/common.test.js +0 -266
- package/dist/tests/completions.test.js +0 -142
- package/dist/tests/config-cli.test.js +0 -193
- package/dist/tests/config-llm-features.test.js +0 -139
- package/dist/tests/config.test.js +0 -544
- package/dist/tests/contracts/migration-baseline.test.js +0 -43
- package/dist/tests/contracts/reflect-propose-envelope.test.js +0 -139
- package/dist/tests/contracts/spec-helpers.js +0 -46
- package/dist/tests/contracts/v1-spec-section-11-proposal-queue.test.js +0 -228
- package/dist/tests/contracts/v1-spec-section-12-agent-config.test.js +0 -56
- package/dist/tests/contracts/v1-spec-section-13-lesson-type.test.js +0 -34
- package/dist/tests/contracts/v1-spec-section-14-llm-features.test.js +0 -94
- package/dist/tests/contracts/v1-spec-section-4-1-asset-types.test.js +0 -39
- package/dist/tests/contracts/v1-spec-section-4-2-quality-rules.test.js +0 -44
- package/dist/tests/contracts/v1-spec-section-5-configuration.test.js +0 -47
- package/dist/tests/contracts/v1-spec-section-6-orchestration.test.js +0 -40
- package/dist/tests/contracts/v1-spec-section-7-module-layout.test.js +0 -58
- package/dist/tests/contracts/v1-spec-section-8-extension-points.test.js +0 -34
- package/dist/tests/contracts/v1-spec-section-9-4-cli-surface.test.js +0 -75
- package/dist/tests/contracts/v1-spec-section-9-7-llm-agent-boundary.test.js +0 -36
- package/dist/tests/core/write-source.test.js +0 -366
- package/dist/tests/curate-command.test.js +0 -87
- package/dist/tests/db-scoring.test.js +0 -201
- package/dist/tests/db.test.js +0 -654
- package/dist/tests/distill-cli-flag.test.js +0 -208
- package/dist/tests/distill.test.js +0 -515
- package/dist/tests/docker-install.test.js +0 -120
- package/dist/tests/e2e.test.js +0 -1398
- package/dist/tests/embedder.test.js +0 -340
- package/dist/tests/embedding-model-config.test.js +0 -379
- package/dist/tests/feedback-command.test.js +0 -172
- package/dist/tests/file-context.test.js +0 -552
- package/dist/tests/fixtures/scripts/git/summarize-diff.js +0 -9
- package/dist/tests/fixtures/scripts/lint/eslint-check.js +0 -7
- package/dist/tests/fixtures/stashes/load.js +0 -166
- package/dist/tests/fixtures/stashes/load.test.js +0 -88
- package/dist/tests/fixtures/stashes/ranking-baseline/scripts/mem0-search.js +0 -12
- package/dist/tests/frontmatter.test.js +0 -190
- package/dist/tests/fts-field-weighting.test.js +0 -254
- package/dist/tests/fuzzy-search.test.js +0 -230
- package/dist/tests/git-provider-clone.test.js +0 -45
- package/dist/tests/github.test.js +0 -161
- package/dist/tests/graph-boost-ranking.test.js +0 -305
- package/dist/tests/graph-extraction.test.js +0 -282
- package/dist/tests/helpers/usage-events.js +0 -8
- package/dist/tests/index-pass-llm.test.js +0 -161
- package/dist/tests/indexer.test.js +0 -559
- package/dist/tests/info-command.test.js +0 -166
- package/dist/tests/init.test.js +0 -69
- package/dist/tests/install-script.test.js +0 -246
- package/dist/tests/integration/agent-real-profile.test.js +0 -94
- package/dist/tests/issue-36-repro.test.js +0 -304
- package/dist/tests/issues-191-194.test.js +0 -160
- package/dist/tests/lesson-lint.test.js +0 -111
- package/dist/tests/llm-client.test.js +0 -115
- package/dist/tests/llm-feature-gate.test.js +0 -151
- package/dist/tests/llm.test.js +0 -139
- package/dist/tests/lockfile.test.js +0 -216
- package/dist/tests/manifest.test.js +0 -205
- package/dist/tests/markdown.test.js +0 -126
- package/dist/tests/matchers-unit.test.js +0 -189
- package/dist/tests/memory-inference.test.js +0 -299
- package/dist/tests/merge-scoring.test.js +0 -136
- package/dist/tests/metadata.test.js +0 -313
- package/dist/tests/migration-help.test.js +0 -89
- package/dist/tests/origin-resolve.test.js +0 -124
- package/dist/tests/output-baseline.test.js +0 -217
- package/dist/tests/output-shapes-unit.test.js +0 -476
- package/dist/tests/parallel-search.test.js +0 -272
- package/dist/tests/parameter-metadata.test.js +0 -365
- package/dist/tests/paths.test.js +0 -177
- package/dist/tests/progressive-disclosure.test.js +0 -280
- package/dist/tests/proposals.test.js +0 -279
- package/dist/tests/proposed-quality.test.js +0 -271
- package/dist/tests/provider-registry.test.js +0 -32
- package/dist/tests/ranking-regression.test.js +0 -548
- package/dist/tests/reflect-propose.test.js +0 -455
- package/dist/tests/registry-build-index.test.js +0 -378
- package/dist/tests/registry-cli.test.js +0 -290
- package/dist/tests/registry-index-v2.test.js +0 -430
- package/dist/tests/registry-install.test.js +0 -728
- package/dist/tests/registry-providers/parity.test.js +0 -189
- package/dist/tests/registry-providers/skills-sh.test.js +0 -309
- package/dist/tests/registry-providers/static-index.test.js +0 -204
- package/dist/tests/registry-resolve.test.js +0 -126
- package/dist/tests/registry-search.test.js +0 -723
- package/dist/tests/remember-frontmatter.test.js +0 -380
- package/dist/tests/remember-unit.test.js +0 -123
- package/dist/tests/ripgrep-install.test.js +0 -251
- package/dist/tests/ripgrep-resolve.test.js +0 -108
- package/dist/tests/ripgrep.test.js +0 -163
- package/dist/tests/save-command.test.js +0 -94
- package/dist/tests/save-trust-qa-fixes.test.js +0 -270
- package/dist/tests/scoring-pipeline.test.js +0 -648
- package/dist/tests/search-include-proposed-cli.test.js +0 -118
- package/dist/tests/self-update.test.js +0 -442
- package/dist/tests/semantic-search-e2e.test.js +0 -512
- package/dist/tests/semantic-status.test.js +0 -471
- package/dist/tests/setup-run.integration.js +0 -877
- package/dist/tests/setup-wizard.test.js +0 -198
- package/dist/tests/setup.test.js +0 -131
- package/dist/tests/source-add.test.js +0 -11
- package/dist/tests/source-clone.test.js +0 -254
- package/dist/tests/source-manage.test.js +0 -366
- package/dist/tests/source-providers/filesystem.test.js +0 -82
- package/dist/tests/source-providers/git.test.js +0 -252
- package/dist/tests/source-providers/website.test.js +0 -128
- package/dist/tests/source-qa-fixes.test.js +0 -268
- package/dist/tests/source-registry.test.js +0 -350
- package/dist/tests/source-resolve.test.js +0 -100
- package/dist/tests/source-source.test.js +0 -221
- package/dist/tests/source.test.js +0 -533
- package/dist/tests/tar-utils-scan.test.js +0 -73
- package/dist/tests/toggle-components.test.js +0 -73
- package/dist/tests/usage-telemetry.test.js +0 -265
- package/dist/tests/utility-scoring.test.js +0 -558
- package/dist/tests/vault-load-error.test.js +0 -78
- package/dist/tests/vault-qa-fixes.test.js +0 -194
- package/dist/tests/vault.test.js +0 -429
- package/dist/tests/vector-search.test.js +0 -608
- package/dist/tests/walker.test.js +0 -252
- package/dist/tests/wave2-cluster-bc.test.js +0 -228
- package/dist/tests/wave2-cluster-d.test.js +0 -180
- package/dist/tests/wave2-cluster-e.test.js +0 -179
- package/dist/tests/wiki-qa-fixes.test.js +0 -270
- package/dist/tests/wiki.test.js +0 -529
- package/dist/tests/workflow-cli.test.js +0 -271
- package/dist/tests/workflow-markdown.test.js +0 -171
- package/dist/tests/workflow-path-escape.test.js +0 -132
- package/dist/tests/workflow-qa-fixes.test.js +0 -377
- package/dist/tests/workflows/indexer-rejection.test.js +0 -213
- /package/dist/{src/commands → commands}/completions.js +0 -0
- /package/dist/{src/commands → commands}/curate.js +0 -0
- /package/dist/{src/commands → commands}/distill.js +0 -0
- /package/dist/{src/commands → commands}/events.js +0 -0
- /package/dist/{src/commands → commands}/info.js +0 -0
- /package/dist/{src/commands → commands}/init.js +0 -0
- /package/dist/{src/commands → commands}/install-audit.js +0 -0
- /package/dist/{src/commands → commands}/installed-stashes.js +0 -0
- /package/dist/{src/commands → commands}/migration-help.js +0 -0
- /package/dist/{src/commands → commands}/proposal.js +0 -0
- /package/dist/{src/commands → commands}/propose.js +0 -0
- /package/dist/{src/commands → commands}/reflect.js +0 -0
- /package/dist/{src/commands → commands}/remember.js +0 -0
- /package/dist/{src/commands → commands}/self-update.js +0 -0
- /package/dist/{src/commands → commands}/source-clone.js +0 -0
- /package/dist/{src/commands → commands}/vault.js +0 -0
- /package/dist/{src/core → core}/asset-ref.js +0 -0
- /package/dist/{src/core → core}/asset-registry.js +0 -0
- /package/dist/{src/core → core}/asset-spec.js +0 -0
- /package/dist/{src/core → core}/common.js +0 -0
- /package/dist/{src/core → core}/errors.js +0 -0
- /package/dist/{src/core → core}/events.js +0 -0
- /package/dist/{src/core → core}/frontmatter.js +0 -0
- /package/dist/{src/core → core}/lesson-lint.js +0 -0
- /package/dist/{src/core → core}/markdown.js +0 -0
- /package/dist/{src/core → core}/paths.js +0 -0
- /package/dist/{src/core → core}/proposals.js +0 -0
- /package/dist/{src/core → core}/warn.js +0 -0
- /package/dist/{src/core → core}/write-source.js +0 -0
- /package/dist/{src/indexer → indexer}/db.js +0 -0
- /package/dist/{src/indexer → indexer}/file-context.js +0 -0
- /package/dist/{src/indexer → indexer}/graph-boost.js +0 -0
- /package/dist/{src/indexer → indexer}/graph-extraction.js +0 -0
- /package/dist/{src/indexer → indexer}/manifest.js +0 -0
- /package/dist/{src/indexer → indexer}/memory-inference.js +0 -0
- /package/dist/{src/indexer → indexer}/metadata.js +0 -0
- /package/dist/{src/indexer → indexer}/search-fields.js +0 -0
- /package/dist/{src/indexer → indexer}/semantic-status.js +0 -0
- /package/dist/{src/indexer → indexer}/usage-events.js +0 -0
- /package/dist/{src/indexer → indexer}/walker.js +0 -0
- /package/dist/{src/integrations → integrations}/agent/config.js +0 -0
- /package/dist/{src/integrations → integrations}/agent/detect.js +0 -0
- /package/dist/{src/integrations → integrations}/agent/index.js +0 -0
- /package/dist/{src/integrations → integrations}/agent/prompts.js +0 -0
- /package/dist/{src/integrations → integrations}/lockfile.js +0 -0
- /package/dist/{src/llm → llm}/client.js +0 -0
- /package/dist/{src/llm → llm}/embedder.js +0 -0
- /package/dist/{src/llm → llm}/embedders/cache.js +0 -0
- /package/dist/{src/llm → llm}/embedders/local.js +0 -0
- /package/dist/{src/llm → llm}/embedders/types.js +0 -0
- /package/dist/{src/llm → llm}/feature-gate.js +0 -0
- /package/dist/{src/llm → llm}/graph-extract.js +0 -0
- /package/dist/{src/llm → llm}/index-passes.js +0 -0
- /package/dist/{src/llm → llm}/memory-infer.js +0 -0
- /package/dist/{src/llm → llm}/metadata-enhance.js +0 -0
- /package/dist/{src/output → output}/context.js +0 -0
- /package/dist/{src/registry → registry}/create-provider-registry.js +0 -0
- /package/dist/{src/registry → registry}/factory.js +0 -0
- /package/dist/{src/registry → registry}/origin-resolve.js +0 -0
- /package/dist/{src/registry → registry}/providers/index.js +0 -0
- /package/dist/{src/registry → registry}/providers/skills-sh.js +0 -0
- /package/dist/{src/registry → registry}/providers/types.js +0 -0
- /package/dist/{src/registry → registry}/resolve.js +0 -0
- /package/dist/{src/registry → registry}/types.js +0 -0
- /package/dist/{src/setup → setup}/detect.js +0 -0
- /package/dist/{src/setup → setup}/ripgrep-install.js +0 -0
- /package/dist/{src/setup → setup}/ripgrep-resolve.js +0 -0
- /package/dist/{src/setup → setup}/steps.js +0 -0
- /package/dist/{src/sources → sources}/include.js +0 -0
- /package/dist/{src/sources → sources}/provider-factory.js +0 -0
- /package/dist/{src/sources → sources}/provider.js +0 -0
- /package/dist/{src/sources → sources}/providers/filesystem.js +0 -0
- /package/dist/{src/sources → sources}/providers/git.js +0 -0
- /package/dist/{src/sources → sources}/providers/index.js +0 -0
- /package/dist/{src/sources → sources}/providers/install-types.js +0 -0
- /package/dist/{src/sources → sources}/providers/npm.js +0 -0
- /package/dist/{src/sources → sources}/providers/provider-utils.js +0 -0
- /package/dist/{src/sources → sources}/providers/sync-from-ref.js +0 -0
- /package/dist/{src/sources → sources}/providers/tar-utils.js +0 -0
- /package/dist/{src/sources → sources}/providers/website.js +0 -0
- /package/dist/{src/sources → sources}/resolve.js +0 -0
- /package/dist/{src/sources → sources}/types.js +0 -0
- /package/dist/{src/templates → templates}/wiki-templates.js +0 -0
- /package/dist/{src/version.js → version.js} +0 -0
- /package/dist/{src/workflows → workflows}/authoring.js +0 -0
- /package/dist/{src/workflows → workflows}/cli.js +0 -0
- /package/dist/{src/workflows → workflows}/db.js +0 -0
- /package/dist/{src/workflows → workflows}/document-cache.js +0 -0
- /package/dist/{src/workflows → workflows}/parser.js +0 -0
- /package/dist/{src/workflows → workflows}/renderer.js +0 -0
- /package/dist/{src/workflows → workflows}/schema.js +0 -0
- /package/dist/{src/workflows → workflows}/validator.js +0 -0
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { makeAssetRef, parseAssetRef } from "../src/core/asset-ref";
|
|
3
|
-
// ── makeAssetRef ────────────────────────────────────────────────────────────
|
|
4
|
-
describe("makeAssetRef", () => {
|
|
5
|
-
test("script ref", () => {
|
|
6
|
-
expect(makeAssetRef("script", "deploy.sh")).toBe("script:deploy.sh");
|
|
7
|
-
});
|
|
8
|
-
test("skill ref", () => {
|
|
9
|
-
expect(makeAssetRef("skill", "code-review")).toBe("skill:code-review");
|
|
10
|
-
});
|
|
11
|
-
test("nested path — slashes stay literal", () => {
|
|
12
|
-
expect(makeAssetRef("script", "azure/container-apps/scale.sh")).toBe("script:azure/container-apps/scale.sh");
|
|
13
|
-
});
|
|
14
|
-
test("name with spaces — no encoding", () => {
|
|
15
|
-
expect(makeAssetRef("script", "my script.sh")).toBe("script:my script.sh");
|
|
16
|
-
});
|
|
17
|
-
test("with local origin", () => {
|
|
18
|
-
expect(makeAssetRef("script", "deploy.sh", "local")).toBe("local//script:deploy.sh");
|
|
19
|
-
});
|
|
20
|
-
test("with npm origin — colons and @ stay literal", () => {
|
|
21
|
-
expect(makeAssetRef("script", "deploy.sh", "npm:@itlackey/openkit")).toBe("npm:@itlackey/openkit//script:deploy.sh");
|
|
22
|
-
});
|
|
23
|
-
test("with github shorthand origin", () => {
|
|
24
|
-
expect(makeAssetRef("skill", "code-review", "itlackey/dimm-city-stash")).toBe("itlackey/dimm-city-stash//skill:code-review");
|
|
25
|
-
});
|
|
26
|
-
test("with github prefixed origin", () => {
|
|
27
|
-
expect(makeAssetRef("script", "lint.sh", "github:owner/repo#v1.2")).toBe("github:owner/repo#v1.2//script:lint.sh");
|
|
28
|
-
});
|
|
29
|
-
test("nested name with origin", () => {
|
|
30
|
-
expect(makeAssetRef("script", "db/migrate/run.sh", "npm:@corp/db-tools")).toBe("npm:@corp/db-tools//script:db/migrate/run.sh");
|
|
31
|
-
});
|
|
32
|
-
test("normalizes backslashes", () => {
|
|
33
|
-
expect(makeAssetRef("script", "dir\\file.sh")).toBe("script:dir/file.sh");
|
|
34
|
-
});
|
|
35
|
-
test("no origin produces plain ref", () => {
|
|
36
|
-
expect(makeAssetRef("agent", "architect.md")).toBe("agent:architect.md");
|
|
37
|
-
expect(makeAssetRef("agent", "architect.md", undefined)).toBe("agent:architect.md");
|
|
38
|
-
});
|
|
39
|
-
test("rejects empty name", () => {
|
|
40
|
-
expect(() => makeAssetRef("script", "")).toThrow("Empty asset name");
|
|
41
|
-
});
|
|
42
|
-
test("rejects null byte", () => {
|
|
43
|
-
expect(() => makeAssetRef("script", "foo\0bar")).toThrow("Null byte");
|
|
44
|
-
});
|
|
45
|
-
test("rejects absolute path", () => {
|
|
46
|
-
expect(() => makeAssetRef("script", "/etc/passwd")).toThrow("Absolute path");
|
|
47
|
-
});
|
|
48
|
-
test("rejects path traversal", () => {
|
|
49
|
-
expect(() => makeAssetRef("script", "../outside.sh")).toThrow("Path traversal");
|
|
50
|
-
});
|
|
51
|
-
test("rejects Windows drive path", () => {
|
|
52
|
-
expect(() => makeAssetRef("script", "C:\\foo")).toThrow("Windows drive");
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
// ── parseAssetRef ───────────────────────────────────────────────────────────
|
|
56
|
-
describe("parseAssetRef", () => {
|
|
57
|
-
test("simple script ref", () => {
|
|
58
|
-
const ref = parseAssetRef("script:deploy.sh");
|
|
59
|
-
expect(ref.type).toBe("script");
|
|
60
|
-
expect(ref.name).toBe("deploy.sh");
|
|
61
|
-
expect(ref.origin).toBeUndefined();
|
|
62
|
-
});
|
|
63
|
-
test("nested path stays literal", () => {
|
|
64
|
-
const ref = parseAssetRef("script:azure/container-apps/scale.sh");
|
|
65
|
-
expect(ref.name).toBe("azure/container-apps/scale.sh");
|
|
66
|
-
});
|
|
67
|
-
test("name with spaces", () => {
|
|
68
|
-
const ref = parseAssetRef("script:my script.sh");
|
|
69
|
-
expect(ref.name).toBe("my script.sh");
|
|
70
|
-
});
|
|
71
|
-
test("local origin", () => {
|
|
72
|
-
const ref = parseAssetRef("local//script:deploy.sh");
|
|
73
|
-
expect(ref.origin).toBe("local");
|
|
74
|
-
expect(ref.type).toBe("script");
|
|
75
|
-
expect(ref.name).toBe("deploy.sh");
|
|
76
|
-
});
|
|
77
|
-
test("npm origin with scope", () => {
|
|
78
|
-
const ref = parseAssetRef("npm:@itlackey/openkit//script:deploy.sh");
|
|
79
|
-
expect(ref.origin).toBe("npm:@itlackey/openkit");
|
|
80
|
-
expect(ref.type).toBe("script");
|
|
81
|
-
expect(ref.name).toBe("deploy.sh");
|
|
82
|
-
});
|
|
83
|
-
test("github shorthand origin", () => {
|
|
84
|
-
const ref = parseAssetRef("itlackey/dimm-city-stash//skill:code-review");
|
|
85
|
-
expect(ref.origin).toBe("itlackey/dimm-city-stash");
|
|
86
|
-
expect(ref.type).toBe("skill");
|
|
87
|
-
expect(ref.name).toBe("code-review");
|
|
88
|
-
});
|
|
89
|
-
test("github origin with tag", () => {
|
|
90
|
-
const ref = parseAssetRef("github:owner/repo#v1.2//script:lint.sh");
|
|
91
|
-
expect(ref.origin).toBe("github:owner/repo#v1.2");
|
|
92
|
-
expect(ref.type).toBe("script");
|
|
93
|
-
expect(ref.name).toBe("lint.sh");
|
|
94
|
-
});
|
|
95
|
-
test("nested name with origin", () => {
|
|
96
|
-
const ref = parseAssetRef("npm:@corp/db-tools//script:db/migrate/run.sh");
|
|
97
|
-
expect(ref.origin).toBe("npm:@corp/db-tools");
|
|
98
|
-
expect(ref.name).toBe("db/migrate/run.sh");
|
|
99
|
-
});
|
|
100
|
-
test("path-based origin", () => {
|
|
101
|
-
const ref = parseAssetRef("/mnt/shared-stash//skill:code-review");
|
|
102
|
-
expect(ref.origin).toBe("/mnt/shared-stash");
|
|
103
|
-
expect(ref.type).toBe("skill");
|
|
104
|
-
expect(ref.name).toBe("code-review");
|
|
105
|
-
});
|
|
106
|
-
test("all asset types parse", () => {
|
|
107
|
-
for (const type of ["skill", "command", "agent", "knowledge", "script"]) {
|
|
108
|
-
const ref = parseAssetRef(`${type}:test`);
|
|
109
|
-
expect(ref.type).toBe(type);
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
test("normalizes backslashes in name", () => {
|
|
113
|
-
const ref = parseAssetRef("script:dir\\file.sh");
|
|
114
|
-
expect(ref.name).toBe("dir/file.sh");
|
|
115
|
-
});
|
|
116
|
-
test("throws for invalid type", () => {
|
|
117
|
-
expect(() => parseAssetRef("widget:foo")).toThrow("Invalid asset type");
|
|
118
|
-
});
|
|
119
|
-
test("throws for removed tool type", () => {
|
|
120
|
-
expect(() => parseAssetRef("tool:deploy.sh")).toThrow("Invalid asset type");
|
|
121
|
-
});
|
|
122
|
-
test("throws for missing colon", () => {
|
|
123
|
-
expect(() => parseAssetRef("scriptname")).toThrow("Invalid ref");
|
|
124
|
-
});
|
|
125
|
-
test("throws for empty origin", () => {
|
|
126
|
-
expect(() => parseAssetRef("//script:deploy.sh")).toThrow("Empty origin");
|
|
127
|
-
});
|
|
128
|
-
test("throws for empty name", () => {
|
|
129
|
-
expect(() => parseAssetRef("script:")).toThrow("Empty asset name");
|
|
130
|
-
});
|
|
131
|
-
test("throws for path traversal in name", () => {
|
|
132
|
-
expect(() => parseAssetRef("script:../outside.sh")).toThrow("Path traversal");
|
|
133
|
-
});
|
|
134
|
-
test("throws for absolute name", () => {
|
|
135
|
-
expect(() => parseAssetRef("script:/etc/passwd")).toThrow("Absolute path");
|
|
136
|
-
});
|
|
137
|
-
test("throws for null byte in name", () => {
|
|
138
|
-
expect(() => parseAssetRef("script:foo\0bar")).toThrow("Null byte");
|
|
139
|
-
});
|
|
140
|
-
test("throws for Windows drive in name", () => {
|
|
141
|
-
expect(() => parseAssetRef("script:C:\\foo")).toThrow("Windows drive");
|
|
142
|
-
});
|
|
143
|
-
test("throws for empty string", () => {
|
|
144
|
-
expect(() => parseAssetRef("")).toThrow("Empty ref");
|
|
145
|
-
});
|
|
146
|
-
test("throws for whitespace-only string", () => {
|
|
147
|
-
expect(() => parseAssetRef(" ")).toThrow("Empty ref");
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
// ── Round-trips ─────────────────────────────────────────────────────────────
|
|
151
|
-
describe("round-trip", () => {
|
|
152
|
-
test("script round-trips", () => {
|
|
153
|
-
const str = makeAssetRef("script", "deploy.sh");
|
|
154
|
-
expect(str).toBe("script:deploy.sh");
|
|
155
|
-
const parsed = parseAssetRef(str);
|
|
156
|
-
expect(parsed).toEqual({ type: "script", name: "deploy.sh", origin: undefined });
|
|
157
|
-
});
|
|
158
|
-
test("with npm origin", () => {
|
|
159
|
-
const str = makeAssetRef("script", "deploy.sh", "npm:@scope/pkg");
|
|
160
|
-
const parsed = parseAssetRef(str);
|
|
161
|
-
expect(parsed).toEqual({ type: "script", name: "deploy.sh", origin: "npm:@scope/pkg" });
|
|
162
|
-
});
|
|
163
|
-
test("nested path with origin", () => {
|
|
164
|
-
const str = makeAssetRef("script", "db/migrate/run.sh", "npm:@corp/tools");
|
|
165
|
-
const parsed = parseAssetRef(str);
|
|
166
|
-
expect(parsed).toEqual({ type: "script", name: "db/migrate/run.sh", origin: "npm:@corp/tools" });
|
|
167
|
-
});
|
|
168
|
-
test("local origin", () => {
|
|
169
|
-
const str = makeAssetRef("skill", "review", "local");
|
|
170
|
-
const parsed = parseAssetRef(str);
|
|
171
|
-
expect(parsed).toEqual({ type: "skill", name: "review", origin: "local" });
|
|
172
|
-
});
|
|
173
|
-
test("github origin with tag", () => {
|
|
174
|
-
const str = makeAssetRef("script", "lint.sh", "github:owner/repo#v2.0");
|
|
175
|
-
const parsed = parseAssetRef(str);
|
|
176
|
-
expect(parsed).toEqual({ type: "script", name: "lint.sh", origin: "github:owner/repo#v2.0" });
|
|
177
|
-
});
|
|
178
|
-
test("name with spaces", () => {
|
|
179
|
-
const str = makeAssetRef("command", "my command.md");
|
|
180
|
-
const parsed = parseAssetRef(str);
|
|
181
|
-
expect(parsed).toEqual({ type: "command", name: "my command.md", origin: undefined });
|
|
182
|
-
});
|
|
183
|
-
test("every asset type round-trips", () => {
|
|
184
|
-
for (const type of ["skill", "command", "agent", "knowledge", "script"]) {
|
|
185
|
-
const str = makeAssetRef(type, "test-asset", "owner/repo");
|
|
186
|
-
const parsed = parseAssetRef(str);
|
|
187
|
-
expect(parsed.type).toBe(type);
|
|
188
|
-
expect(parsed.name).toBe("test-asset");
|
|
189
|
-
expect(parsed.origin).toBe("owner/repo");
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
});
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { ACTION_BUILDERS, TYPE_TO_RENDERER } from "../src/core/asset-registry";
|
|
4
|
-
import { deregisterAssetType, registerAssetType } from "../src/core/asset-spec";
|
|
5
|
-
// ── Test helpers ────────────────────────────────────────────────────────────
|
|
6
|
-
const TEST_TYPE = "registry-test-widget";
|
|
7
|
-
function makeWidgetSpec(overrides = {}) {
|
|
8
|
-
return {
|
|
9
|
-
stashDir: "widgets",
|
|
10
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
11
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
12
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
13
|
-
...overrides,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
// ── Tests ───────────────────────────────────────────────────────────────────
|
|
17
|
-
describe("asset-registry singleton", () => {
|
|
18
|
-
afterEach(() => {
|
|
19
|
-
// Clean up the test type to avoid polluting other tests
|
|
20
|
-
deregisterAssetType(TEST_TYPE);
|
|
21
|
-
delete TYPE_TO_RENDERER[TEST_TYPE];
|
|
22
|
-
delete ACTION_BUILDERS[TEST_TYPE];
|
|
23
|
-
});
|
|
24
|
-
test("registerAssetType populates TYPE_TO_RENDERER when rendererName is set", () => {
|
|
25
|
-
registerAssetType(TEST_TYPE, makeWidgetSpec({ rendererName: "widget-md" }));
|
|
26
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBe("widget-md");
|
|
27
|
-
});
|
|
28
|
-
test("registerAssetType populates ACTION_BUILDERS when actionBuilder is set", () => {
|
|
29
|
-
const builder = (ref) => `akm show ${ref} -> use widget`;
|
|
30
|
-
registerAssetType(TEST_TYPE, makeWidgetSpec({ actionBuilder: builder }));
|
|
31
|
-
expect(ACTION_BUILDERS[TEST_TYPE]).toBe(builder);
|
|
32
|
-
expect(ACTION_BUILDERS[TEST_TYPE]("widget:foo")).toBe("akm show widget:foo -> use widget");
|
|
33
|
-
});
|
|
34
|
-
test("registration works regardless of import order (no deferred hooks needed)", () => {
|
|
35
|
-
// The key property: TYPE_TO_RENDERER and ACTION_BUILDERS are populated
|
|
36
|
-
// directly, not through deferred hooks. Importing asset-registry.ts
|
|
37
|
-
// before or after asset-spec.ts doesn't matter because they share the
|
|
38
|
-
// same singleton maps.
|
|
39
|
-
const builder = (ref) => `akm show ${ref} -> render widget`;
|
|
40
|
-
registerAssetType(TEST_TYPE, makeWidgetSpec({
|
|
41
|
-
rendererName: "widget-md",
|
|
42
|
-
actionBuilder: builder,
|
|
43
|
-
}));
|
|
44
|
-
// Both maps should be populated after a single registerAssetType call
|
|
45
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBe("widget-md");
|
|
46
|
-
expect(ACTION_BUILDERS[TEST_TYPE]).toBe(builder);
|
|
47
|
-
});
|
|
48
|
-
test("multiple registrations don't clobber each other", () => {
|
|
49
|
-
const type1 = `${TEST_TYPE}-1`;
|
|
50
|
-
const type2 = `${TEST_TYPE}-2`;
|
|
51
|
-
try {
|
|
52
|
-
registerAssetType(type1, makeWidgetSpec({
|
|
53
|
-
stashDir: "widgets1",
|
|
54
|
-
rendererName: "widget1-md",
|
|
55
|
-
actionBuilder: (ref) => `action1 ${ref}`,
|
|
56
|
-
}));
|
|
57
|
-
registerAssetType(type2, makeWidgetSpec({
|
|
58
|
-
stashDir: "widgets2",
|
|
59
|
-
rendererName: "widget2-md",
|
|
60
|
-
actionBuilder: (ref) => `action2 ${ref}`,
|
|
61
|
-
}));
|
|
62
|
-
expect(TYPE_TO_RENDERER[type1]).toBe("widget1-md");
|
|
63
|
-
expect(TYPE_TO_RENDERER[type2]).toBe("widget2-md");
|
|
64
|
-
expect(ACTION_BUILDERS[type1]("r")).toBe("action1 r");
|
|
65
|
-
expect(ACTION_BUILDERS[type2]("r")).toBe("action2 r");
|
|
66
|
-
}
|
|
67
|
-
finally {
|
|
68
|
-
for (const t of [type1, type2]) {
|
|
69
|
-
deregisterAssetType(t);
|
|
70
|
-
delete TYPE_TO_RENDERER[t];
|
|
71
|
-
delete ACTION_BUILDERS[t];
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
test("_setAssetTypeHooks no longer exists in asset-spec", async () => {
|
|
76
|
-
const assetSpec = await import("../src/core/asset-spec");
|
|
77
|
-
expect("_setAssetTypeHooks" in assetSpec).toBe(false);
|
|
78
|
-
});
|
|
79
|
-
test("TYPE_TO_RENDERER contains built-in types", () => {
|
|
80
|
-
expect(TYPE_TO_RENDERER.script).toBe("script-source");
|
|
81
|
-
expect(TYPE_TO_RENDERER.skill).toBe("skill-md");
|
|
82
|
-
expect(TYPE_TO_RENDERER.command).toBe("command-md");
|
|
83
|
-
expect(TYPE_TO_RENDERER.agent).toBe("agent-md");
|
|
84
|
-
expect(TYPE_TO_RENDERER.knowledge).toBe("knowledge-md");
|
|
85
|
-
expect(TYPE_TO_RENDERER.memory).toBe("memory-md");
|
|
86
|
-
});
|
|
87
|
-
test("ACTION_BUILDERS contains built-in types", () => {
|
|
88
|
-
expect(typeof ACTION_BUILDERS.script).toBe("function");
|
|
89
|
-
expect(typeof ACTION_BUILDERS.skill).toBe("function");
|
|
90
|
-
expect(typeof ACTION_BUILDERS.command).toBe("function");
|
|
91
|
-
expect(typeof ACTION_BUILDERS.agent).toBe("function");
|
|
92
|
-
expect(typeof ACTION_BUILDERS.knowledge).toBe("function");
|
|
93
|
-
expect(typeof ACTION_BUILDERS.memory).toBe("function");
|
|
94
|
-
});
|
|
95
|
-
test("spec without rendererName leaves TYPE_TO_RENDERER unchanged for that type", () => {
|
|
96
|
-
registerAssetType(TEST_TYPE, makeWidgetSpec());
|
|
97
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBeUndefined();
|
|
98
|
-
});
|
|
99
|
-
test("spec without actionBuilder leaves ACTION_BUILDERS unchanged for that type", () => {
|
|
100
|
-
registerAssetType(TEST_TYPE, makeWidgetSpec());
|
|
101
|
-
expect(ACTION_BUILDERS[TEST_TYPE]).toBeUndefined();
|
|
102
|
-
});
|
|
103
|
-
});
|
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { ACTION_BUILDERS, TYPE_TO_RENDERER } from "../src/core/asset-registry";
|
|
4
|
-
import { ASSET_SPECS, deregisterAssetType, deriveCanonicalAssetName, getAssetTypes, isRelevantAssetFile, registerAssetType, resolveAssetPathFromName, SCRIPT_EXTENSIONS, TYPE_DIRS, } from "../src/core/asset-spec";
|
|
5
|
-
// ── Constants ───────────────────────────────────────────────────────────────
|
|
6
|
-
describe("SCRIPT_EXTENSIONS", () => {
|
|
7
|
-
test("contains all expected extensions", () => {
|
|
8
|
-
for (const ext of [".sh", ".ts", ".js", ".ps1", ".cmd", ".bat", ".py", ".rb", ".go"]) {
|
|
9
|
-
expect(SCRIPT_EXTENSIONS.has(ext)).toBe(true);
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
test("does not contain non-script extensions", () => {
|
|
13
|
-
for (const ext of [".md", ".json", ".txt"]) {
|
|
14
|
-
expect(SCRIPT_EXTENSIONS.has(ext)).toBe(false);
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe("getAssetTypes", () => {
|
|
19
|
-
test("contains all built-in types", () => {
|
|
20
|
-
const types = getAssetTypes();
|
|
21
|
-
expect(types).toContain("skill");
|
|
22
|
-
expect(types).toContain("command");
|
|
23
|
-
expect(types).toContain("agent");
|
|
24
|
-
expect(types).toContain("knowledge");
|
|
25
|
-
expect(types).toContain("workflow");
|
|
26
|
-
expect(types).toContain("script");
|
|
27
|
-
expect(types).toContain("memory");
|
|
28
|
-
expect(types).toContain("vault");
|
|
29
|
-
expect(types).toContain("wiki");
|
|
30
|
-
expect(types).toContain("lesson");
|
|
31
|
-
expect(types).toHaveLength(10);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
describe("TYPE_DIRS", () => {
|
|
35
|
-
test("maps types to directory names", () => {
|
|
36
|
-
expect(TYPE_DIRS.skill).toBe("skills");
|
|
37
|
-
expect(TYPE_DIRS.command).toBe("commands");
|
|
38
|
-
expect(TYPE_DIRS.agent).toBe("agents");
|
|
39
|
-
expect(TYPE_DIRS.knowledge).toBe("knowledge");
|
|
40
|
-
expect(TYPE_DIRS.workflow).toBe("workflows");
|
|
41
|
-
expect(TYPE_DIRS.script).toBe("scripts");
|
|
42
|
-
expect(TYPE_DIRS.memory).toBe("memories");
|
|
43
|
-
expect(TYPE_DIRS.vault).toBe("vaults");
|
|
44
|
-
expect(TYPE_DIRS.lesson).toBe("lessons");
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
// ── isRelevantAssetFile ─────────────────────────────────────────────────────
|
|
48
|
-
describe("isRelevantAssetFile", () => {
|
|
49
|
-
test("script: accepts all script extensions", () => {
|
|
50
|
-
expect(isRelevantAssetFile("script", "deploy.sh")).toBe(true);
|
|
51
|
-
expect(isRelevantAssetFile("script", "run.ts")).toBe(true);
|
|
52
|
-
expect(isRelevantAssetFile("script", "script.js")).toBe(true);
|
|
53
|
-
expect(isRelevantAssetFile("script", "run.ps1")).toBe(true);
|
|
54
|
-
expect(isRelevantAssetFile("script", "run.cmd")).toBe(true);
|
|
55
|
-
expect(isRelevantAssetFile("script", "run.bat")).toBe(true);
|
|
56
|
-
expect(isRelevantAssetFile("script", "run.py")).toBe(true);
|
|
57
|
-
expect(isRelevantAssetFile("script", "main.go")).toBe(true);
|
|
58
|
-
expect(isRelevantAssetFile("script", "run.lua")).toBe(true);
|
|
59
|
-
});
|
|
60
|
-
test("script: rejects non-script files", () => {
|
|
61
|
-
expect(isRelevantAssetFile("script", "README.md")).toBe(false);
|
|
62
|
-
expect(isRelevantAssetFile("script", "package.json")).toBe(false);
|
|
63
|
-
expect(isRelevantAssetFile("script", "data.txt")).toBe(false);
|
|
64
|
-
});
|
|
65
|
-
test("skill: only accepts SKILL.md", () => {
|
|
66
|
-
expect(isRelevantAssetFile("skill", "SKILL.md")).toBe(true);
|
|
67
|
-
expect(isRelevantAssetFile("skill", "skill.md")).toBe(false);
|
|
68
|
-
expect(isRelevantAssetFile("skill", "README.md")).toBe(false);
|
|
69
|
-
expect(isRelevantAssetFile("skill", "deploy.sh")).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
test("command: accepts .md files", () => {
|
|
72
|
-
expect(isRelevantAssetFile("command", "release.md")).toBe(true);
|
|
73
|
-
expect(isRelevantAssetFile("command", "SETUP.MD")).toBe(true);
|
|
74
|
-
expect(isRelevantAssetFile("command", "script.sh")).toBe(false);
|
|
75
|
-
});
|
|
76
|
-
test("agent: accepts .md files", () => {
|
|
77
|
-
expect(isRelevantAssetFile("agent", "architect.md")).toBe(true);
|
|
78
|
-
expect(isRelevantAssetFile("agent", "coach.MD")).toBe(true);
|
|
79
|
-
expect(isRelevantAssetFile("agent", "script.ts")).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
test("knowledge: accepts .md files", () => {
|
|
82
|
-
expect(isRelevantAssetFile("knowledge", "guide.md")).toBe(true);
|
|
83
|
-
expect(isRelevantAssetFile("knowledge", "data.json")).toBe(false);
|
|
84
|
-
});
|
|
85
|
-
test("workflow: accepts .md files", () => {
|
|
86
|
-
expect(isRelevantAssetFile("workflow", "release.md")).toBe(true);
|
|
87
|
-
expect(isRelevantAssetFile("workflow", "release.txt")).toBe(false);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
// ── deriveCanonicalAssetName ────────────────────────────────────────────────
|
|
91
|
-
describe("deriveCanonicalAssetName", () => {
|
|
92
|
-
test("script: returns relative path from type root", () => {
|
|
93
|
-
const root = "/stash/scripts";
|
|
94
|
-
const file = path.join(root, "docker", "build.sh");
|
|
95
|
-
expect(deriveCanonicalAssetName("script", root, file)).toBe("docker/build.sh");
|
|
96
|
-
});
|
|
97
|
-
test("script: returns file name for flat structure", () => {
|
|
98
|
-
const root = "/stash/scripts";
|
|
99
|
-
const file = path.join(root, "deploy.sh");
|
|
100
|
-
expect(deriveCanonicalAssetName("script", root, file)).toBe("deploy.sh");
|
|
101
|
-
});
|
|
102
|
-
test("skill: returns directory name for SKILL.md", () => {
|
|
103
|
-
const root = "/stash/skills";
|
|
104
|
-
const file = path.join(root, "code-review", "SKILL.md");
|
|
105
|
-
expect(deriveCanonicalAssetName("skill", root, file)).toBe("code-review");
|
|
106
|
-
});
|
|
107
|
-
test("skill: returns undefined for SKILL.md at root", () => {
|
|
108
|
-
const root = "/stash/skills";
|
|
109
|
-
const file = path.join(root, "SKILL.md");
|
|
110
|
-
expect(deriveCanonicalAssetName("skill", root, file)).toBeUndefined();
|
|
111
|
-
});
|
|
112
|
-
test("command: returns relative path without .md extension", () => {
|
|
113
|
-
const root = "/stash/commands";
|
|
114
|
-
const file = path.join(root, "release.md");
|
|
115
|
-
expect(deriveCanonicalAssetName("command", root, file)).toBe("release");
|
|
116
|
-
});
|
|
117
|
-
test("agent: returns relative path without .md extension", () => {
|
|
118
|
-
const root = "/stash/agents";
|
|
119
|
-
const file = path.join(root, "architect.md");
|
|
120
|
-
expect(deriveCanonicalAssetName("agent", root, file)).toBe("architect");
|
|
121
|
-
});
|
|
122
|
-
test("knowledge: returns relative path without .md extension", () => {
|
|
123
|
-
const root = "/stash/knowledge";
|
|
124
|
-
const file = path.join(root, "guide.md");
|
|
125
|
-
expect(deriveCanonicalAssetName("knowledge", root, file)).toBe("guide");
|
|
126
|
-
});
|
|
127
|
-
test("workflow: returns relative path without .md extension", () => {
|
|
128
|
-
const root = "/stash/workflows";
|
|
129
|
-
const file = path.join(root, "release", "ship.md");
|
|
130
|
-
expect(deriveCanonicalAssetName("workflow", root, file)).toBe("release/ship");
|
|
131
|
-
});
|
|
132
|
-
test("script: returns relative path including subdirectory", () => {
|
|
133
|
-
const root = "/stash/scripts";
|
|
134
|
-
const file = path.join(root, "utils", "cleanup.py");
|
|
135
|
-
expect(deriveCanonicalAssetName("script", root, file)).toBe("utils/cleanup.py");
|
|
136
|
-
});
|
|
137
|
-
test("vault: top-level <name>.env → <name>", () => {
|
|
138
|
-
const root = "/stash/vaults";
|
|
139
|
-
expect(deriveCanonicalAssetName("vault", root, path.join(root, "prod.env"))).toBe("prod");
|
|
140
|
-
});
|
|
141
|
-
test("vault: top-level `.env` → `default`", () => {
|
|
142
|
-
const root = "/stash/vaults";
|
|
143
|
-
expect(deriveCanonicalAssetName("vault", root, path.join(root, ".env"))).toBe("default");
|
|
144
|
-
});
|
|
145
|
-
test("vault: nested <dir>/<name>.env → <dir>/<name>", () => {
|
|
146
|
-
const root = "/stash/vaults";
|
|
147
|
-
expect(deriveCanonicalAssetName("vault", root, path.join(root, "team", "prod.env"))).toBe("team/prod");
|
|
148
|
-
});
|
|
149
|
-
test("vault: nested <dir>/.env → <dir>/default", () => {
|
|
150
|
-
const root = "/stash/vaults";
|
|
151
|
-
expect(deriveCanonicalAssetName("vault", root, path.join(root, "team", ".env"))).toBe("team/default");
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
// ── resolveAssetPathFromName ────────────────────────────────────────────────
|
|
155
|
-
describe("resolveAssetPathFromName", () => {
|
|
156
|
-
test("script: joins type root with name", () => {
|
|
157
|
-
expect(resolveAssetPathFromName("script", "/stash/scripts", "deploy.sh")).toBe(path.join("/stash/scripts", "deploy.sh"));
|
|
158
|
-
});
|
|
159
|
-
test("skill: appends SKILL.md to name directory", () => {
|
|
160
|
-
expect(resolveAssetPathFromName("skill", "/stash/skills", "code-review")).toBe(path.join("/stash/skills", "code-review", "SKILL.md"));
|
|
161
|
-
});
|
|
162
|
-
test("command: joins type root with name", () => {
|
|
163
|
-
expect(resolveAssetPathFromName("command", "/stash/commands", "release.md")).toBe(path.join("/stash/commands", "release.md"));
|
|
164
|
-
});
|
|
165
|
-
test("workflow: joins type root with name", () => {
|
|
166
|
-
expect(resolveAssetPathFromName("workflow", "/stash/workflows", "release/ship")).toBe(path.join("/stash/workflows", "release/ship.md"));
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
// ── R3.17: registerAssetType — single-call full registration ────────────────
|
|
170
|
-
//
|
|
171
|
-
// When `registerAssetType` is called with `rendererName` and `actionBuilder`
|
|
172
|
-
// in the spec, it should automatically populate TYPE_TO_RENDERER and
|
|
173
|
-
// ACTION_BUILDERS via the asset-registry singleton.
|
|
174
|
-
// This means callers need only one `registerAssetType` call to fully integrate
|
|
175
|
-
// a new asset type with the search and renderer systems.
|
|
176
|
-
describe("registerAssetType", () => {
|
|
177
|
-
const TEST_TYPE = "widget-test-r317";
|
|
178
|
-
afterEach(() => {
|
|
179
|
-
// Clean up the test type to avoid polluting other tests
|
|
180
|
-
deregisterAssetType(TEST_TYPE);
|
|
181
|
-
delete TYPE_TO_RENDERER[TEST_TYPE];
|
|
182
|
-
delete ACTION_BUILDERS[TEST_TYPE];
|
|
183
|
-
});
|
|
184
|
-
test("adds the new type to ASSET_SPECS and TYPE_DIRS", () => {
|
|
185
|
-
registerAssetType(TEST_TYPE, {
|
|
186
|
-
stashDir: "widgets",
|
|
187
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
188
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
189
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
190
|
-
});
|
|
191
|
-
expect(ASSET_SPECS[TEST_TYPE]).toBeDefined();
|
|
192
|
-
expect(TYPE_DIRS[TEST_TYPE]).toBe("widgets");
|
|
193
|
-
expect(getAssetTypes()).toContain(TEST_TYPE);
|
|
194
|
-
});
|
|
195
|
-
test("automatically registers rendererName into TYPE_TO_RENDERER", () => {
|
|
196
|
-
registerAssetType(TEST_TYPE, {
|
|
197
|
-
stashDir: "widgets",
|
|
198
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
199
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
200
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
201
|
-
rendererName: "widget-md",
|
|
202
|
-
});
|
|
203
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBe("widget-md");
|
|
204
|
-
});
|
|
205
|
-
test("automatically registers actionBuilder into ACTION_BUILDERS", () => {
|
|
206
|
-
const builder = (ref) => `akm show ${ref} -> use widget`;
|
|
207
|
-
registerAssetType(TEST_TYPE, {
|
|
208
|
-
stashDir: "widgets",
|
|
209
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
210
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
211
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
212
|
-
actionBuilder: builder,
|
|
213
|
-
});
|
|
214
|
-
expect(ACTION_BUILDERS[TEST_TYPE]).toBe(builder);
|
|
215
|
-
expect(ACTION_BUILDERS[TEST_TYPE]?.("widget:my-widget")).toBe("akm show widget:my-widget -> use widget");
|
|
216
|
-
});
|
|
217
|
-
test("registers both rendererName and actionBuilder in a single call", () => {
|
|
218
|
-
const builder = (ref) => `akm show ${ref} -> render widget`;
|
|
219
|
-
registerAssetType(TEST_TYPE, {
|
|
220
|
-
stashDir: "widgets",
|
|
221
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
222
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
223
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
224
|
-
rendererName: "widget-md",
|
|
225
|
-
actionBuilder: builder,
|
|
226
|
-
});
|
|
227
|
-
// Both search-system hooks should be populated after the single call
|
|
228
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBe("widget-md");
|
|
229
|
-
expect(ACTION_BUILDERS[TEST_TYPE]).toBe(builder);
|
|
230
|
-
});
|
|
231
|
-
test("spec without rendererName leaves TYPE_TO_RENDERER unchanged for that type", () => {
|
|
232
|
-
registerAssetType(TEST_TYPE, {
|
|
233
|
-
stashDir: "widgets",
|
|
234
|
-
isRelevantFile: (f) => f.endsWith(".widget"),
|
|
235
|
-
toCanonicalName: (_root, fp) => path.basename(fp, ".widget"),
|
|
236
|
-
toAssetPath: (root, name) => path.join(root, `${name}.widget`),
|
|
237
|
-
// intentionally no rendererName
|
|
238
|
-
});
|
|
239
|
-
expect(TYPE_TO_RENDERER[TEST_TYPE]).toBeUndefined();
|
|
240
|
-
});
|
|
241
|
-
});
|