akm-cli 0.9.16-alpha.1 → 0.9.16-alpha.2

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.
Files changed (144) hide show
  1. package/CHANGELOG.md +40 -132
  2. package/dist/assets/hints/cli-hints-full.md +13 -6
  3. package/dist/assets/tasks/core/index-refresh.yml +1 -1
  4. package/dist/assets/tasks/improve/akm-improve-catchup.yml +3 -6
  5. package/dist/cli/retired-commands.js +0 -4
  6. package/dist/cli/unknown-flags.js +3 -36
  7. package/dist/commands/env/env-binding.js +4 -4
  8. package/dist/commands/env/env-cli.js +3 -3
  9. package/dist/commands/improve/collapse-detector.js +2 -2
  10. package/dist/commands/improve/consolidate.js +4 -6
  11. package/dist/commands/improve/improve-cli.js +20 -15
  12. package/dist/commands/improve/reflect.js +23 -2
  13. package/dist/commands/lint/base-linter.js +9 -0
  14. package/dist/commands/lint/env-key-rules.js +2 -2
  15. package/dist/commands/proposal/propose.js +15 -1
  16. package/dist/commands/proposal/repository.js +3 -12
  17. package/dist/commands/proposal/validators/proposal-quality-validators.js +40 -3
  18. package/dist/commands/proposal/validators/proposal-validators.js +5 -4
  19. package/dist/commands/read/curate.js +44 -34
  20. package/dist/commands/read/search.js +35 -54
  21. package/dist/commands/read/show.js +21 -2
  22. package/dist/commands/registry-cli.js +5 -5
  23. package/dist/commands/sources/add-cli.js +59 -16
  24. package/dist/commands/sources/bundle-cli.js +35 -11
  25. package/dist/commands/sources/bundle-config-ops.js +30 -0
  26. package/dist/commands/sources/dangerous-env-audit.js +4 -4
  27. package/dist/commands/sources/info.js +8 -8
  28. package/dist/commands/sources/installed-stashes.js +55 -61
  29. package/dist/commands/sources/source-add.js +39 -38
  30. package/dist/commands/sources/source-manage.js +34 -12
  31. package/dist/commands/sources/stash-cli.js +111 -119
  32. package/dist/commands/sources/stash-skeleton.js +6 -3
  33. package/dist/commands/tasks/explain.js +4 -1
  34. package/dist/commands/tasks/tasks-cli.js +31 -9
  35. package/dist/commands/tasks/tasks.js +239 -194
  36. package/dist/commands/tasks/validate.js +20 -32
  37. package/dist/core/activation-policy.js +4 -4
  38. package/dist/core/adapter/adapters/akm-adapter.js +8 -35
  39. package/dist/core/adapter/adapters/akm-metadata.js +1 -11
  40. package/dist/core/adapter/execution-source.js +10 -29
  41. package/dist/core/asset/asset-placement.js +0 -35
  42. package/dist/core/config/config-schema.js +64 -8
  43. package/dist/core/config/config-sources.js +96 -2
  44. package/dist/core/config/config.js +190 -24
  45. package/dist/core/config/legacy-source-shape-shim.js +9 -0
  46. package/dist/core/config/schema/embedding.js +30 -7
  47. package/dist/core/config/schema/execution.js +23 -0
  48. package/dist/core/config/schema/experimental.js +1 -1
  49. package/dist/core/config/schema/scheduler.js +20 -0
  50. package/dist/core/config/schema/search.js +10 -12
  51. package/dist/core/config/schema/sources-bundles.js +32 -1
  52. package/dist/core/content-safety.js +52 -0
  53. package/dist/core/errors.js +2 -5
  54. package/dist/core/maintenance-barrier.js +11 -13
  55. package/dist/core/paths.js +11 -0
  56. package/dist/core/run-lock.js +2 -5
  57. package/dist/core/state/migrations.js +1 -26
  58. package/dist/core/state-db.js +27 -63
  59. package/dist/core/type-presentation.js +1 -1
  60. package/dist/core/write-source.js +13 -8
  61. package/dist/indexer/bundle-identity-guard.js +45 -8
  62. package/dist/indexer/ensure-index.js +0 -5
  63. package/dist/indexer/index-db-contention.js +56 -0
  64. package/dist/indexer/index-rebuild-lock.js +73 -0
  65. package/dist/indexer/index-written-assets.js +171 -133
  66. package/dist/indexer/indexer.js +1621 -458
  67. package/dist/indexer/lookup/adapter-concept-owner.js +5 -19
  68. package/dist/indexer/materialize-embeddings.js +785 -0
  69. package/dist/indexer/passes/dir-staleness.js +161 -0
  70. package/dist/indexer/passes/metadata.js +1 -18
  71. package/dist/indexer/scan/drain-dir.js +70 -27
  72. package/dist/indexer/search/db-search.js +89 -373
  73. package/dist/indexer/search/ranking-contributors.js +16 -21
  74. package/dist/indexer/search/ranking.js +57 -135
  75. package/dist/indexer/search/search-source.js +29 -11
  76. package/dist/integrations/agent/execution-lowering.js +3 -2
  77. package/dist/integrations/agent/execution-preparation.js +32 -1
  78. package/dist/integrations/agent/prompts.js +1 -1
  79. package/dist/integrations/agent/request-lowering.js +3 -2
  80. package/dist/llm/client.js +3 -11
  81. package/dist/llm/embedder.js +3 -10
  82. package/dist/llm/embedders/remote.js +104 -133
  83. package/dist/llm/feature-gate.js +2 -4
  84. package/dist/llm/rerank-client.js +3 -3
  85. package/dist/output/shapes/passthrough.js +2 -1
  86. package/dist/output/text/command-format.js +13 -19
  87. package/dist/output/text/helpers.js +1 -1
  88. package/dist/output/text/index.js +2 -5
  89. package/dist/registry/resolve.js +37 -10
  90. package/dist/scripts/akm-migrate-node.js +15197 -11351
  91. package/dist/scripts/akm-migrate.js +15514 -11668
  92. package/dist/setup/semantic-assets.js +2 -2
  93. package/dist/setup/setup.js +3 -3
  94. package/dist/setup/steps/connection.js +2 -3
  95. package/dist/setup/steps/tasks.js +29 -36
  96. package/dist/sources/providers/git-install.js +17 -11
  97. package/dist/sources/providers/git-provider.js +12 -5
  98. package/dist/sources/providers/git-stash.js +38 -16
  99. package/dist/sources/snapshot-fetchers/website-ingest.js +3 -3
  100. package/dist/storage/repositories/embedding-salvage-repository.js +184 -0
  101. package/dist/storage/repositories/index-connection.js +3 -1
  102. package/dist/storage/repositories/index-entries-repository.js +68 -77
  103. package/dist/storage/repositories/index-entry-schema.js +25 -16
  104. package/dist/storage/repositories/index-fts-repository.js +263 -29
  105. package/dist/storage/repositories/index-meta-repository.js +29 -0
  106. package/dist/storage/repositories/index-schema.js +122 -115
  107. package/dist/storage/repositories/index-utility-repository.js +1 -1
  108. package/dist/storage/repositories/index-vec-repository.js +435 -22
  109. package/dist/tasks/activation-config.js +90 -0
  110. package/dist/tasks/backends/cron.js +9 -0
  111. package/dist/tasks/backends/launchd.js +1 -0
  112. package/dist/tasks/backends/schtasks.js +2 -0
  113. package/dist/tasks/embedded.js +4 -5
  114. package/dist/tasks/scheduler-binding.js +2 -2
  115. package/dist/tasks/scheduler-sync-preview.js +8 -1
  116. package/dist/tasks/scheduler-sync.js +19 -10
  117. package/dist/tasks/source/parse-task-source.js +10 -113
  118. package/dist/tasks/source/project-v4.js +2 -2
  119. package/dist/tasks/source/task-source-v4.js +4 -12
  120. package/dist/tasks/source/task-to-v3.js +4 -12
  121. package/dist/tasks/source/task-to-v4.js +40 -7
  122. package/docs/migration/README.md +1 -0
  123. package/docs/migration/release-notes/0.9.15.md +36 -34
  124. package/docs/migration/release-notes/0.9.16.md +60 -98
  125. package/docs/migration/release-notes/README.md +0 -5
  126. package/docs/migration/v0.9.1-to-v0.9.2.md +6 -9
  127. package/docs/reference/cli.md +124 -122
  128. package/docs/reference/configuration.md +137 -133
  129. package/docs/reference/data-and-telemetry.md +1 -2
  130. package/docs/reference/tasks.md +34 -29
  131. package/package.json +1 -1
  132. package/schemas/akm-config.json +170 -6
  133. package/schemas/akm-task.json +1 -2
  134. package/dist/commands/sources/index-status.js +0 -99
  135. package/dist/core/hash.js +0 -18
  136. package/dist/indexer/drain.js +0 -306
  137. package/dist/indexer/embedding-identity.js +0 -20
  138. package/dist/indexer/enrich.js +0 -260
  139. package/dist/indexer/reconcile.js +0 -890
  140. package/dist/indexer/scan/parse-file.js +0 -66
  141. package/dist/indexer/units/unit.js +0 -159
  142. package/dist/llm/embedders/provider-limits.js +0 -288
  143. package/dist/storage/repositories/files-repository.js +0 -181
  144. package/dist/storage/repositories/units-repository.js +0 -510
@@ -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], { encoding: "utf8", timeout: 30_000 });
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