akm-cli 0.9.16-alpha.1 → 0.9.16
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 +56 -132
- package/dist/assets/hints/cli-hints-full.md +13 -6
- package/dist/assets/tasks/core/index-refresh.yml +1 -1
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +3 -6
- package/dist/cli/retired-commands.js +0 -4
- package/dist/cli/unknown-flags.js +3 -36
- package/dist/commands/env/env-binding.js +4 -4
- package/dist/commands/env/env-cli.js +3 -3
- package/dist/commands/improve/collapse-detector.js +2 -2
- package/dist/commands/improve/consolidate.js +4 -6
- package/dist/commands/improve/improve-cli.js +20 -15
- package/dist/commands/improve/reflect.js +23 -2
- package/dist/commands/lint/base-linter.js +9 -0
- package/dist/commands/lint/env-key-rules.js +2 -2
- package/dist/commands/proposal/propose.js +15 -1
- package/dist/commands/proposal/repository.js +3 -12
- package/dist/commands/proposal/validators/proposal-quality-validators.js +40 -3
- package/dist/commands/proposal/validators/proposal-validators.js +5 -4
- package/dist/commands/read/curate.js +44 -34
- package/dist/commands/read/search.js +35 -54
- package/dist/commands/read/show.js +21 -2
- package/dist/commands/registry-cli.js +5 -5
- package/dist/commands/sources/add-cli.js +59 -16
- package/dist/commands/sources/bundle-cli.js +35 -11
- package/dist/commands/sources/bundle-config-ops.js +30 -0
- package/dist/commands/sources/dangerous-env-audit.js +4 -4
- package/dist/commands/sources/info.js +8 -8
- package/dist/commands/sources/installed-stashes.js +55 -61
- package/dist/commands/sources/source-add.js +39 -38
- package/dist/commands/sources/source-manage.js +34 -12
- package/dist/commands/sources/stash-cli.js +111 -119
- package/dist/commands/sources/stash-skeleton.js +6 -3
- package/dist/commands/tasks/explain.js +4 -1
- package/dist/commands/tasks/tasks-cli.js +31 -9
- package/dist/commands/tasks/tasks.js +239 -194
- package/dist/commands/tasks/validate.js +20 -32
- package/dist/core/activation-policy.js +4 -4
- package/dist/core/adapter/adapters/akm-adapter.js +8 -35
- package/dist/core/adapter/adapters/akm-metadata.js +1 -11
- package/dist/core/adapter/execution-source.js +10 -29
- package/dist/core/asset/asset-placement.js +0 -35
- package/dist/core/config/config-schema.js +64 -8
- package/dist/core/config/config-sources.js +96 -2
- package/dist/core/config/config.js +190 -24
- package/dist/core/config/legacy-source-shape-shim.js +9 -0
- package/dist/core/config/schema/embedding.js +30 -7
- package/dist/core/config/schema/execution.js +23 -0
- package/dist/core/config/schema/experimental.js +1 -1
- package/dist/core/config/schema/scheduler.js +20 -0
- package/dist/core/config/schema/search.js +10 -12
- package/dist/core/config/schema/sources-bundles.js +32 -1
- package/dist/core/content-safety.js +52 -0
- package/dist/core/errors.js +2 -5
- package/dist/core/maintenance-barrier.js +11 -13
- package/dist/core/paths.js +11 -0
- package/dist/core/run-lock.js +2 -5
- package/dist/core/state/migrations.js +1 -26
- package/dist/core/state-db.js +27 -63
- package/dist/core/type-presentation.js +1 -1
- package/dist/core/write-source.js +13 -8
- package/dist/indexer/bundle-identity-guard.js +45 -8
- package/dist/indexer/ensure-index.js +0 -5
- package/dist/indexer/index-db-contention.js +56 -0
- package/dist/indexer/index-rebuild-lock.js +73 -0
- package/dist/indexer/index-written-assets.js +171 -133
- package/dist/indexer/indexer.js +1621 -458
- package/dist/indexer/lookup/adapter-concept-owner.js +5 -19
- package/dist/indexer/materialize-embeddings.js +785 -0
- package/dist/indexer/passes/dir-staleness.js +161 -0
- package/dist/indexer/passes/metadata.js +1 -18
- package/dist/indexer/scan/drain-dir.js +70 -27
- package/dist/indexer/search/db-search.js +89 -373
- package/dist/indexer/search/ranking-contributors.js +16 -21
- package/dist/indexer/search/ranking.js +57 -135
- package/dist/indexer/search/search-source.js +29 -11
- package/dist/integrations/agent/execution-lowering.js +3 -2
- package/dist/integrations/agent/execution-preparation.js +32 -1
- package/dist/integrations/agent/prompts.js +1 -1
- package/dist/integrations/agent/request-lowering.js +3 -2
- package/dist/llm/client.js +3 -11
- package/dist/llm/embedder.js +3 -10
- package/dist/llm/embedders/remote.js +104 -133
- package/dist/llm/feature-gate.js +2 -4
- package/dist/llm/rerank-client.js +3 -3
- package/dist/output/html-render.js +2 -1
- package/dist/output/shapes/passthrough.js +2 -1
- package/dist/output/stdout.js +24 -0
- package/dist/output/text/command-format.js +13 -19
- package/dist/output/text/helpers.js +1 -1
- package/dist/output/text/index.js +2 -5
- package/dist/output/text.js +4 -3
- package/dist/registry/resolve.js +37 -10
- package/dist/scripts/akm-migrate-node.js +15197 -11351
- package/dist/scripts/akm-migrate.js +15514 -11668
- package/dist/setup/semantic-assets.js +2 -2
- package/dist/setup/setup.js +3 -3
- package/dist/setup/steps/connection.js +2 -3
- package/dist/setup/steps/tasks.js +29 -36
- package/dist/sources/providers/git-install.js +17 -11
- package/dist/sources/providers/git-provider.js +12 -5
- package/dist/sources/providers/git-stash.js +38 -16
- package/dist/sources/snapshot-fetchers/website-ingest.js +3 -3
- package/dist/storage/repositories/embedding-salvage-repository.js +184 -0
- package/dist/storage/repositories/index-connection.js +3 -1
- package/dist/storage/repositories/index-entries-repository.js +68 -77
- package/dist/storage/repositories/index-entry-schema.js +25 -16
- package/dist/storage/repositories/index-fts-repository.js +263 -29
- package/dist/storage/repositories/index-meta-repository.js +29 -0
- package/dist/storage/repositories/index-schema.js +122 -115
- package/dist/storage/repositories/index-utility-repository.js +1 -1
- package/dist/storage/repositories/index-vec-repository.js +435 -22
- package/dist/tasks/activation-config.js +90 -0
- package/dist/tasks/backends/cron.js +9 -0
- package/dist/tasks/backends/launchd.js +1 -0
- package/dist/tasks/backends/schtasks.js +2 -0
- package/dist/tasks/embedded.js +4 -5
- package/dist/tasks/scheduler-binding.js +2 -2
- package/dist/tasks/scheduler-sync-preview.js +8 -1
- package/dist/tasks/scheduler-sync.js +19 -10
- package/dist/tasks/source/parse-task-source.js +10 -113
- package/dist/tasks/source/project-v4.js +2 -2
- package/dist/tasks/source/task-source-v4.js +4 -12
- package/dist/tasks/source/task-to-v3.js +4 -12
- package/dist/tasks/source/task-to-v4.js +40 -7
- package/docs/migration/README.md +1 -0
- package/docs/migration/release-notes/0.9.15.md +36 -34
- package/docs/migration/release-notes/0.9.16.md +60 -98
- package/docs/migration/release-notes/README.md +0 -5
- package/docs/migration/v0.9.1-to-v0.9.2.md +6 -9
- package/docs/reference/cli.md +124 -122
- package/docs/reference/configuration.md +137 -133
- package/docs/reference/data-and-telemetry.md +1 -2
- package/docs/reference/tasks.md +34 -29
- package/package.json +1 -1
- package/schemas/akm-config.json +170 -6
- package/schemas/akm-task.json +1 -2
- package/dist/commands/sources/index-status.js +0 -99
- package/dist/core/hash.js +0 -18
- package/dist/indexer/drain.js +0 -306
- package/dist/indexer/embedding-identity.js +0 -20
- package/dist/indexer/enrich.js +0 -260
- package/dist/indexer/reconcile.js +0 -890
- package/dist/indexer/scan/parse-file.js +0 -66
- package/dist/indexer/units/unit.js +0 -159
- package/dist/llm/embedders/provider-limits.js +0 -288
- package/dist/storage/repositories/files-repository.js +0 -181
- package/dist/storage/repositories/units-repository.js +0 -510
package/dist/registry/resolve.js
CHANGED
|
@@ -11,6 +11,29 @@ import { NotFoundError, UsageError } from "../core/errors.js";
|
|
|
11
11
|
import { asRecord, asString, GITHUB_API_BASE, githubHeaders } from "../integrations/github.js";
|
|
12
12
|
import { cancelRegistryResponse, fetchRegistryResponse } from "./network.js";
|
|
13
13
|
import { isExactSemver, isSemverRange, maxSatisfying } from "./semver.js";
|
|
14
|
+
/**
|
|
15
|
+
* Pass an HTTPS bearer credential to Git without placing it in the remote URL
|
|
16
|
+
* or argv. The value exists only in the child-process environment and is never
|
|
17
|
+
* persisted or included in diagnostics.
|
|
18
|
+
*/
|
|
19
|
+
export function gitCredentialEnvironment(credential) {
|
|
20
|
+
if (!credential)
|
|
21
|
+
return { ...process.env };
|
|
22
|
+
if (/[\r\n\0]/.test(credential)) {
|
|
23
|
+
throw new UsageError("Git credential contains an invalid control character.");
|
|
24
|
+
}
|
|
25
|
+
const configuredCount = process.env.GIT_CONFIG_COUNT;
|
|
26
|
+
const nextIndex = configuredCount === undefined ? 0 : Number(configuredCount);
|
|
27
|
+
if (!Number.isSafeInteger(nextIndex) || nextIndex < 0) {
|
|
28
|
+
throw new UsageError("GIT_CONFIG_COUNT must be a non-negative integer before a Git credential can be added.");
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
...process.env,
|
|
32
|
+
GIT_CONFIG_COUNT: String(nextIndex + 1),
|
|
33
|
+
[`GIT_CONFIG_KEY_${nextIndex}`]: "http.extraHeader",
|
|
34
|
+
[`GIT_CONFIG_VALUE_${nextIndex}`]: `Authorization: Bearer ${credential}`,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
14
37
|
/**
|
|
15
38
|
* Validate that a URL is safe to pass to git.
|
|
16
39
|
* Allowlists https:, http:, ssh:, git: schemes and git@ SSH shorthand.
|
|
@@ -122,16 +145,16 @@ function detectRegistrySearchId(ref) {
|
|
|
122
145
|
lines.push("Or search for the installable ref:", ` akm search "${segments.length > 2 ? segments[segments.length - 1] : rest}" --from registry`, "Then install using the installRef value from the result:", " akm bundle add github:owner/repo", " akm bundle add npm:package-name");
|
|
123
146
|
return lines.join("\n");
|
|
124
147
|
}
|
|
125
|
-
export async function resolveRegistryArtifact(parsed) {
|
|
148
|
+
export async function resolveRegistryArtifact(parsed, options) {
|
|
126
149
|
switch (parsed.source) {
|
|
127
150
|
case "npm":
|
|
128
151
|
return resolveNpmArtifact(parsed);
|
|
129
152
|
case "local":
|
|
130
153
|
return resolveLocalArtifact(parsed);
|
|
131
154
|
case "git":
|
|
132
|
-
return resolveGitArtifact(parsed);
|
|
155
|
+
return resolveGitArtifact(parsed, options?.gitCredential);
|
|
133
156
|
case "github":
|
|
134
|
-
return resolveGithubArtifact(parsed);
|
|
157
|
+
return resolveGithubArtifact(parsed, options?.gitCredential);
|
|
135
158
|
}
|
|
136
159
|
}
|
|
137
160
|
function parseNpmRef(input, originalRef) {
|
|
@@ -427,12 +450,12 @@ async function resolveNpmArtifact(parsed) {
|
|
|
427
450
|
allowPrivateRegistryOrigin: npmPolicy.allowPrivateRegistryOrigin,
|
|
428
451
|
};
|
|
429
452
|
}
|
|
430
|
-
async function resolveGithubArtifact(parsed) {
|
|
453
|
+
async function resolveGithubArtifact(parsed, credential) {
|
|
431
454
|
const gitUrl = `https://github.com/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}.git`;
|
|
432
455
|
const repoBase = `${GITHUB_API_BASE}/repos/${encodeURIComponent(parsed.owner)}/${encodeURIComponent(parsed.repo)}`;
|
|
433
456
|
// Prefer git-backed installs so private GitHub repos work with the user's
|
|
434
457
|
// normal git credential helper rather than requiring API-specific auth.
|
|
435
|
-
const gitResolvedRevision = resolveGitRevisionFromRemote(gitUrl, parsed.requestedRef);
|
|
458
|
+
const gitResolvedRevision = resolveGitRevisionFromRemote(gitUrl, parsed.requestedRef, credential);
|
|
436
459
|
if (gitResolvedRevision) {
|
|
437
460
|
return {
|
|
438
461
|
id: parsed.id,
|
|
@@ -443,7 +466,7 @@ async function resolveGithubArtifact(parsed) {
|
|
|
443
466
|
resolvedRevision: gitResolvedRevision,
|
|
444
467
|
};
|
|
445
468
|
}
|
|
446
|
-
const headers = githubHeaders();
|
|
469
|
+
const headers = { ...githubHeaders(), ...(credential ? { Authorization: `Bearer ${credential}` } : {}) };
|
|
447
470
|
if (parsed.requestedRef) {
|
|
448
471
|
const commit = await tryFetchJson(`${repoBase}/commits/${encodeURIComponent(parsed.requestedRef)}`, headers, GITHUB_API_POLICY);
|
|
449
472
|
const resolvedRevision = asString(commit?.sha) ?? parsed.requestedRef;
|
|
@@ -485,19 +508,23 @@ async function resolveGithubArtifact(parsed) {
|
|
|
485
508
|
resolvedRevision: asString(commit?.sha) ?? defaultBranch,
|
|
486
509
|
};
|
|
487
510
|
}
|
|
488
|
-
function resolveGitRevisionFromRemote(url, requestedRef) {
|
|
511
|
+
function resolveGitRevisionFromRemote(url, requestedRef, credential) {
|
|
489
512
|
validateGitUrl(url);
|
|
490
513
|
const ref = requestedRef ?? "HEAD";
|
|
491
514
|
if (requestedRef)
|
|
492
515
|
validateGitRef(requestedRef);
|
|
493
|
-
const result = spawnSync("git", ["ls-remote", url, ref], {
|
|
516
|
+
const result = spawnSync("git", ["ls-remote", url, ref], {
|
|
517
|
+
encoding: "utf8",
|
|
518
|
+
timeout: 30_000,
|
|
519
|
+
env: gitCredentialEnvironment(credential),
|
|
520
|
+
});
|
|
494
521
|
if (result.status !== 0)
|
|
495
522
|
return undefined;
|
|
496
523
|
const firstLine = result.stdout.trim().split(/\r?\n/)[0];
|
|
497
524
|
return firstLine?.split(/\s/)[0] || undefined;
|
|
498
525
|
}
|
|
499
|
-
async function resolveGitArtifact(parsed) {
|
|
500
|
-
const resolvedRevision = resolveGitRevisionFromRemote(parsed.url, parsed.requestedRef);
|
|
526
|
+
async function resolveGitArtifact(parsed, credential) {
|
|
527
|
+
const resolvedRevision = resolveGitRevisionFromRemote(parsed.url, parsed.requestedRef, credential);
|
|
501
528
|
if (!resolvedRevision) {
|
|
502
529
|
// Unlike the GitHub path (which falls back to the REST API on a failed
|
|
503
530
|
// `git ls-remote`), a plain git source has no fallback resolver — an
|