@agent-native/core 0.174.2-nightly-20260825214843 → 0.174.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.
@@ -69,6 +69,30 @@ declare function standaloneTemplatePromptOptions(): {
69
69
  label: string;
70
70
  hint: string;
71
71
  }[];
72
+ type RepoDiscovery = {
73
+ state: "inside";
74
+ root: string;
75
+ } | {
76
+ state: "outside";
77
+ } | {
78
+ state: "unknown";
79
+ reason: string;
80
+ };
81
+ /**
82
+ * Whether `dir` sits inside a repository, as git itself resolves it.
83
+ *
84
+ * Matching a `.git` entry by hand looks equivalent and is not: discovery also
85
+ * turns on symlinked paths, filesystem boundaries, `GIT_CEILING_DIRECTORIES`
86
+ * and `GIT_DISCOVERY_ACROSS_FILESYSTEM`. Running git is free here, since the
87
+ * only alternative to finding a repo is shelling out to `git init` anyway.
88
+ *
89
+ * "No repository" and "could not tell" are separate answers on purpose. Git
90
+ * exits 128 for a checkout it refuses — dubious ownership, a corrupt gitfile —
91
+ * as readily as for a genuinely repo-less directory, and reading the first as
92
+ * the second is how a guard against nested repositories comes to create one.
93
+ * `LC_ALL` is pinned so the message they are told apart by is not translated.
94
+ */
95
+ declare function discoverEnclosingRepo(dir: string): RepoDiscovery;
72
96
  /** Where a scaffolded template's bytes came from, recorded so
73
97
  * `agent-native template sync` can reproduce them later. */
74
98
  export interface ScaffoldTemplateResolution {
@@ -156,7 +180,7 @@ export declare function detectWorkspace(startDir: string): {
156
180
  } | null;
157
181
  export { parseWorkspaceScope };
158
182
  /** @internal — exported for E2E tests */
159
- export { scaffoldWorkspaceRoot as _scaffoldWorkspaceRoot, ensureGuardedScaffold as _ensureGuardedScaffold, scaffoldAppTemplate as _scaffoldAppTemplate, scaffoldRequiredPackages as _scaffoldRequiredPackages, postProcessStandalone as _postProcessStandalone, loadCatalog as _loadCatalog, fixPackageJsonName as _fixPackageJsonName, renameGitignore as _renameGitignore, rewriteNetlifyToml as _rewriteNetlifyToml, getCoreDependencyVersion as _getCoreDependencyVersion, getDispatchDependencyVersion as _getDispatchDependencyVersion, getToolkitDependencyVersion as _getToolkitDependencyVersion, getCorePackageVersion as _getCorePackageVersion, getGitHubTemplateRef as _getGitHubTemplateRef, getGitHubTemplateRefCandidates as _getGitHubTemplateRefCandidates, githubTarballUrl as _githubTarballUrl, findLocalTemplateFrom as _findLocalTemplateFrom, workspaceAppNameForTemplateSelection as _workspaceAppNameForTemplateSelection, startShapePromptOptions as _startShapePromptOptions, standaloneTemplatePromptOptions as _standaloneTemplatePromptOptions, parseCommunityTemplateSelection as _parseCommunityTemplateSelection, communityTemplateTrustMessage as _communityTemplateTrustMessage, communityTemplateTarballUrl as _communityTemplateTarballUrl, assertCommunityTemplateRoot as _assertCommunityTemplateRoot, assertSafeCommunityArchiveListing as _assertSafeCommunityArchiveListing, validateCommunityArchive as _validateCommunityArchive, resolveCommunityTemplateSource as _resolveCommunityTemplateSource, discoverCommunityWorkspaceApps as _discoverCommunityWorkspaceApps, normalizeCommunityWorkspaceAppDependencies as _normalizeCommunityWorkspaceAppDependencies, shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry, tarExtractArgs as _tarExtractArgs, extractTarball as _extractTarball, materializeArchiveSymlinks as _materializeArchiveSymlinks, downloadGitHubSubdir as _downloadGitHubSubdir, findLocalTemplate as _findLocalTemplate, templateSourceName as _templateSourceName, normalizeTemplateName as _normalizeTemplateName, appTitleForScaffold as _appTitleForScaffold, replacePlaceholders as _replacePlaceholders, rewriteTrackingAppId as _rewriteTrackingAppId, rewriteAgentChatAppId as _rewriteAgentChatAppId, applyScaffoldIdentity as _applyScaffoldIdentity, fixWebManifestName as _fixWebManifestName, copyDir as _copyDir, localTemplateSourceKind as _localTemplateSourceKind, REPO as _REPO, TEMPLATES_DIR as _TEMPLATES_DIR, };
183
+ export { scaffoldWorkspaceRoot as _scaffoldWorkspaceRoot, ensureGuardedScaffold as _ensureGuardedScaffold, scaffoldAppTemplate as _scaffoldAppTemplate, scaffoldRequiredPackages as _scaffoldRequiredPackages, postProcessStandalone as _postProcessStandalone, loadCatalog as _loadCatalog, fixPackageJsonName as _fixPackageJsonName, renameGitignore as _renameGitignore, discoverEnclosingRepo as _discoverEnclosingRepo, rewriteNetlifyToml as _rewriteNetlifyToml, getCoreDependencyVersion as _getCoreDependencyVersion, getDispatchDependencyVersion as _getDispatchDependencyVersion, getToolkitDependencyVersion as _getToolkitDependencyVersion, getCorePackageVersion as _getCorePackageVersion, getGitHubTemplateRef as _getGitHubTemplateRef, getGitHubTemplateRefCandidates as _getGitHubTemplateRefCandidates, githubTarballUrl as _githubTarballUrl, findLocalTemplateFrom as _findLocalTemplateFrom, workspaceAppNameForTemplateSelection as _workspaceAppNameForTemplateSelection, startShapePromptOptions as _startShapePromptOptions, standaloneTemplatePromptOptions as _standaloneTemplatePromptOptions, parseCommunityTemplateSelection as _parseCommunityTemplateSelection, communityTemplateTrustMessage as _communityTemplateTrustMessage, communityTemplateTarballUrl as _communityTemplateTarballUrl, assertCommunityTemplateRoot as _assertCommunityTemplateRoot, assertSafeCommunityArchiveListing as _assertSafeCommunityArchiveListing, validateCommunityArchive as _validateCommunityArchive, resolveCommunityTemplateSource as _resolveCommunityTemplateSource, discoverCommunityWorkspaceApps as _discoverCommunityWorkspaceApps, normalizeCommunityWorkspaceAppDependencies as _normalizeCommunityWorkspaceAppDependencies, shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry, tarExtractArgs as _tarExtractArgs, extractTarball as _extractTarball, materializeArchiveSymlinks as _materializeArchiveSymlinks, downloadGitHubSubdir as _downloadGitHubSubdir, findLocalTemplate as _findLocalTemplate, templateSourceName as _templateSourceName, normalizeTemplateName as _normalizeTemplateName, appTitleForScaffold as _appTitleForScaffold, replacePlaceholders as _replacePlaceholders, rewriteTrackingAppId as _rewriteTrackingAppId, rewriteAgentChatAppId as _rewriteAgentChatAppId, applyScaffoldIdentity as _applyScaffoldIdentity, fixWebManifestName as _fixWebManifestName, copyDir as _copyDir, localTemplateSourceKind as _localTemplateSourceKind, REPO as _REPO, TEMPLATES_DIR as _TEMPLATES_DIR, };
160
184
  declare function tarExtractArgs(tarPath: string, destDir: string, options?: {
161
185
  skipAgentSymlinks?: boolean;
162
186
  untrustedCommunityArchive?: boolean;
@@ -1,4 +1,4 @@
1
- import { execFile, execFileSync } from "child_process";
1
+ import { execFile, execFileSync, spawnSync } from "child_process";
2
2
  import fs from "fs";
3
3
  import os from "os";
4
4
  import path from "path";
@@ -829,9 +829,8 @@ function cleanupOnFailure(targetDir) {
829
829
  * (`create .`) was built in `scaffoldDir` (a staging dir); copy only the files
830
830
  * that don't already exist into the current directory so pre-existing files
831
831
  * (`.git`, `README.md`, `.gitignore`, editor configs) are preserved, then drop
832
- * the staging dir. Git init/commit is skipped when the current directory is
833
- * already a repo so we never write an unexpected commit into the user's
834
- * history.
832
+ * the staging dir. Git init/commit is skipped when the scaffold lands inside a
833
+ * repo so we never write an unexpected commit into the user's history.
835
834
  */
836
835
  function finalizeScaffold(scaffoldDir, inPlace) {
837
836
  if (!inPlace) {
@@ -848,10 +847,88 @@ function finalizeScaffold(scaffoldDir, inPlace) {
848
847
  tryGitInitUnlessRepo(dest);
849
848
  }
850
849
  function tryGitInitUnlessRepo(dir) {
851
- if (fs.existsSync(path.join(dir, ".git")))
850
+ // Only "git says there is no repository here" earns an init. A discovery
851
+ // failure has to fall through to doing nothing.
852
+ if (discoverEnclosingRepo(dir).state !== "outside")
852
853
  return;
853
854
  tryGitInit(dir);
854
855
  }
856
+ /**
857
+ * The variables that bind git to a particular repository.
858
+ *
859
+ * Deliberately narrower than git's `local_repo_env`: that list also clears
860
+ * `GIT_CONFIG*`, because git is entering a different repository and the
861
+ * caller's `-c` overrides were scoped to the old one. Here the caller is
862
+ * configuring the scaffold that is about to exist, so `init.defaultBranch`,
863
+ * `core.hooksPath` and `commit.gpgsign` have to survive.
864
+ */
865
+ const GIT_REPO_LOCATION_ENV = [
866
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES",
867
+ "GIT_COMMON_DIR",
868
+ "GIT_DIR",
869
+ "GIT_GRAFT_FILE",
870
+ "GIT_IMPLICIT_WORK_TREE",
871
+ "GIT_INDEX_FILE",
872
+ "GIT_INTERNAL_SUPER_PREFIX",
873
+ "GIT_NAMESPACE",
874
+ "GIT_NO_REPLACE_OBJECTS",
875
+ "GIT_OBJECT_DIRECTORY",
876
+ "GIT_PREFIX",
877
+ "GIT_QUARANTINE_PATH",
878
+ "GIT_REPLACE_REF_BASE",
879
+ "GIT_SHALLOW_FILE",
880
+ "GIT_WORK_TREE",
881
+ ];
882
+ /**
883
+ * Env with any inherited repository context dropped.
884
+ *
885
+ * Whatever launched the process — a hook, a `rebase --exec`, a `receive-pack`
886
+ * quarantine — may have pinned git to its own repository. Inheriting that makes
887
+ * discovery answer about that repository rather than the directory being
888
+ * scaffolded, and makes an init write into it. Picking the variables off one at
889
+ * a time invites the next gap, so mirror the list git clears for exactly this
890
+ * reason. The discovery controls are deliberately not in it: where the search
891
+ * stops really is the caller's to configure.
892
+ */
893
+ function envWithoutRepoOverrides() {
894
+ const env = { ...process.env };
895
+ for (const key of GIT_REPO_LOCATION_ENV)
896
+ delete env[key];
897
+ return env;
898
+ }
899
+ /**
900
+ * Whether `dir` sits inside a repository, as git itself resolves it.
901
+ *
902
+ * Matching a `.git` entry by hand looks equivalent and is not: discovery also
903
+ * turns on symlinked paths, filesystem boundaries, `GIT_CEILING_DIRECTORIES`
904
+ * and `GIT_DISCOVERY_ACROSS_FILESYSTEM`. Running git is free here, since the
905
+ * only alternative to finding a repo is shelling out to `git init` anyway.
906
+ *
907
+ * "No repository" and "could not tell" are separate answers on purpose. Git
908
+ * exits 128 for a checkout it refuses — dubious ownership, a corrupt gitfile —
909
+ * as readily as for a genuinely repo-less directory, and reading the first as
910
+ * the second is how a guard against nested repositories comes to create one.
911
+ * `LC_ALL` is pinned so the message they are told apart by is not translated.
912
+ */
913
+ function discoverEnclosingRepo(dir) {
914
+ const result = spawnSync("git", ["rev-parse", "--show-toplevel"], {
915
+ cwd: dir,
916
+ encoding: "utf8",
917
+ env: { ...envWithoutRepoOverrides(), LC_ALL: "C" },
918
+ });
919
+ if (result.error)
920
+ return { state: "unknown", reason: result.error.message };
921
+ if (result.status === 0) {
922
+ const root = result.stdout.trim();
923
+ return root
924
+ ? { state: "inside", root }
925
+ : { state: "unknown", reason: "git reported no toplevel" };
926
+ }
927
+ const stderr = (result.stderr ?? "").trim();
928
+ if (/not a git repository/i.test(stderr))
929
+ return { state: "outside" };
930
+ return { state: "unknown", reason: stderr || `git exited ${result.status}` };
931
+ }
855
932
  /**
856
933
  * Scaffold a single app template into `targetDir`. Resolves:
857
934
  * - "headless" / legacy "blank" → bundled action-first template
@@ -1701,7 +1778,7 @@ export function detectWorkspace(startDir) {
1701
1778
  }
1702
1779
  export { parseWorkspaceScope };
1703
1780
  /** @internal — exported for E2E tests */
1704
- export { scaffoldWorkspaceRoot as _scaffoldWorkspaceRoot, ensureGuardedScaffold as _ensureGuardedScaffold, scaffoldAppTemplate as _scaffoldAppTemplate, scaffoldRequiredPackages as _scaffoldRequiredPackages, postProcessStandalone as _postProcessStandalone, loadCatalog as _loadCatalog, fixPackageJsonName as _fixPackageJsonName, renameGitignore as _renameGitignore, rewriteNetlifyToml as _rewriteNetlifyToml, getCoreDependencyVersion as _getCoreDependencyVersion, getDispatchDependencyVersion as _getDispatchDependencyVersion, getToolkitDependencyVersion as _getToolkitDependencyVersion, getCorePackageVersion as _getCorePackageVersion, getGitHubTemplateRef as _getGitHubTemplateRef, getGitHubTemplateRefCandidates as _getGitHubTemplateRefCandidates, githubTarballUrl as _githubTarballUrl, findLocalTemplateFrom as _findLocalTemplateFrom, workspaceAppNameForTemplateSelection as _workspaceAppNameForTemplateSelection, startShapePromptOptions as _startShapePromptOptions, standaloneTemplatePromptOptions as _standaloneTemplatePromptOptions, parseCommunityTemplateSelection as _parseCommunityTemplateSelection, communityTemplateTrustMessage as _communityTemplateTrustMessage, communityTemplateTarballUrl as _communityTemplateTarballUrl, assertCommunityTemplateRoot as _assertCommunityTemplateRoot, assertSafeCommunityArchiveListing as _assertSafeCommunityArchiveListing, validateCommunityArchive as _validateCommunityArchive, resolveCommunityTemplateSource as _resolveCommunityTemplateSource, discoverCommunityWorkspaceApps as _discoverCommunityWorkspaceApps, normalizeCommunityWorkspaceAppDependencies as _normalizeCommunityWorkspaceAppDependencies, shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry, tarExtractArgs as _tarExtractArgs, extractTarball as _extractTarball, materializeArchiveSymlinks as _materializeArchiveSymlinks, downloadGitHubSubdir as _downloadGitHubSubdir, findLocalTemplate as _findLocalTemplate, templateSourceName as _templateSourceName, normalizeTemplateName as _normalizeTemplateName, appTitleForScaffold as _appTitleForScaffold, replacePlaceholders as _replacePlaceholders, rewriteTrackingAppId as _rewriteTrackingAppId, rewriteAgentChatAppId as _rewriteAgentChatAppId, applyScaffoldIdentity as _applyScaffoldIdentity, fixWebManifestName as _fixWebManifestName, copyDir as _copyDir, localTemplateSourceKind as _localTemplateSourceKind, REPO as _REPO, TEMPLATES_DIR as _TEMPLATES_DIR, };
1781
+ export { scaffoldWorkspaceRoot as _scaffoldWorkspaceRoot, ensureGuardedScaffold as _ensureGuardedScaffold, scaffoldAppTemplate as _scaffoldAppTemplate, scaffoldRequiredPackages as _scaffoldRequiredPackages, postProcessStandalone as _postProcessStandalone, loadCatalog as _loadCatalog, fixPackageJsonName as _fixPackageJsonName, renameGitignore as _renameGitignore, discoverEnclosingRepo as _discoverEnclosingRepo, rewriteNetlifyToml as _rewriteNetlifyToml, getCoreDependencyVersion as _getCoreDependencyVersion, getDispatchDependencyVersion as _getDispatchDependencyVersion, getToolkitDependencyVersion as _getToolkitDependencyVersion, getCorePackageVersion as _getCorePackageVersion, getGitHubTemplateRef as _getGitHubTemplateRef, getGitHubTemplateRefCandidates as _getGitHubTemplateRefCandidates, githubTarballUrl as _githubTarballUrl, findLocalTemplateFrom as _findLocalTemplateFrom, workspaceAppNameForTemplateSelection as _workspaceAppNameForTemplateSelection, startShapePromptOptions as _startShapePromptOptions, standaloneTemplatePromptOptions as _standaloneTemplatePromptOptions, parseCommunityTemplateSelection as _parseCommunityTemplateSelection, communityTemplateTrustMessage as _communityTemplateTrustMessage, communityTemplateTarballUrl as _communityTemplateTarballUrl, assertCommunityTemplateRoot as _assertCommunityTemplateRoot, assertSafeCommunityArchiveListing as _assertSafeCommunityArchiveListing, validateCommunityArchive as _validateCommunityArchive, resolveCommunityTemplateSource as _resolveCommunityTemplateSource, discoverCommunityWorkspaceApps as _discoverCommunityWorkspaceApps, normalizeCommunityWorkspaceAppDependencies as _normalizeCommunityWorkspaceAppDependencies, shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry, tarExtractArgs as _tarExtractArgs, extractTarball as _extractTarball, materializeArchiveSymlinks as _materializeArchiveSymlinks, downloadGitHubSubdir as _downloadGitHubSubdir, findLocalTemplate as _findLocalTemplate, templateSourceName as _templateSourceName, normalizeTemplateName as _normalizeTemplateName, appTitleForScaffold as _appTitleForScaffold, replacePlaceholders as _replacePlaceholders, rewriteTrackingAppId as _rewriteTrackingAppId, rewriteAgentChatAppId as _rewriteAgentChatAppId, applyScaffoldIdentity as _applyScaffoldIdentity, fixWebManifestName as _fixWebManifestName, copyDir as _copyDir, localTemplateSourceKind as _localTemplateSourceKind, REPO as _REPO, TEMPLATES_DIR as _TEMPLATES_DIR, };
1705
1782
  /* ─────────────────────────────────────────────────────────────────────────
1706
1783
  * Download / copy helpers
1707
1784
  * ───────────────────────────────────────────────────────────────────────── */
@@ -2868,14 +2945,15 @@ function hasTrackingTemplate(content) {
2868
2945
  return !!match && /^\s*template\s*:/m.test(match[0]);
2869
2946
  }
2870
2947
  function tryGitInit(dir) {
2948
+ const env = envWithoutRepoOverrides();
2871
2949
  try {
2872
- execFileSync("git", ["init"], { cwd: dir, stdio: "pipe" });
2873
- execFileSync("git", ["add", "-A"], { cwd: dir, stdio: "pipe" });
2950
+ execFileSync("git", ["init"], { cwd: dir, stdio: "pipe", env });
2951
+ execFileSync("git", ["add", "-A"], { cwd: dir, stdio: "pipe", env });
2874
2952
  execFileSync("git", ["commit", "-m", "Initial commit from agent-native create"], {
2875
2953
  cwd: dir,
2876
2954
  stdio: "pipe",
2877
2955
  env: {
2878
- ...process.env,
2956
+ ...env,
2879
2957
  GIT_AUTHOR_NAME: "agent-native",
2880
2958
  GIT_AUTHOR_EMAIL: "noreply@agent-native.com",
2881
2959
  GIT_COMMITTER_NAME: "agent-native",
@@ -26,8 +26,8 @@ export declare const getCollabState: import("h3").EventHandlerWithFetch<import("
26
26
  * Body: { update: string (base64), requestSource?: string }
27
27
  */
28
28
  export declare const postCollabUpdate: import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<{
29
- ok?: undefined;
30
29
  error: string;
30
+ ok?: undefined;
31
31
  } | {
32
32
  error?: undefined;
33
33
  ok: boolean;
@@ -41,14 +41,14 @@ export declare function createObservabilityHandler(): import("h3").EventHandlerW
41
41
  thumbsUpRate: number;
42
42
  avgEvalScore: number;
43
43
  } | {
44
- error?: undefined;
45
44
  ok?: undefined;
45
+ error?: undefined;
46
46
  summary: import("./types.js").TraceSummary;
47
47
  spans: import("./types.js").TraceSpan[];
48
48
  id?: undefined;
49
49
  } | {
50
- error?: undefined;
51
50
  ok?: undefined;
51
+ error?: undefined;
52
52
  summary?: undefined;
53
53
  spans?: undefined;
54
54
  id: string;
@@ -37,17 +37,17 @@ export declare function createWriteSecretHandler(): import("h3").EventHandlerWit
37
37
  ok?: undefined;
38
38
  status?: undefined;
39
39
  } | {
40
- error?: undefined;
41
40
  ok: boolean;
42
41
  status: string;
42
+ error?: undefined;
43
43
  } | {
44
44
  ok?: undefined;
45
45
  error: string;
46
46
  removed?: undefined;
47
47
  } | {
48
- error?: undefined;
49
48
  ok: boolean;
50
49
  removed: boolean;
50
+ error?: undefined;
51
51
  }>>;
52
52
  /**
53
53
  * POST /_agent-native/secrets/:key/test — validate an optional candidate value
@@ -58,13 +58,13 @@ export declare function createTestSecretHandler(): import("h3").EventHandlerWith
58
58
  error: string;
59
59
  note?: undefined;
60
60
  } | {
61
- error?: undefined;
62
61
  ok: boolean;
63
62
  note?: undefined;
64
- } | {
65
63
  error?: undefined;
64
+ } | {
66
65
  ok: boolean;
67
66
  note: string;
67
+ error?: undefined;
68
68
  } | {
69
69
  note?: undefined;
70
70
  ok: boolean;
@@ -95,11 +95,11 @@ export interface AdHocSecretPayload {
95
95
  export declare function createAdHocSecretHandler(): import("h3").EventHandlerWithFetch<import("h3").EventHandlerRequest, Promise<AdHocSecretPayload[] | {
96
96
  error: string;
97
97
  } | {
98
- error?: undefined;
99
98
  ok: boolean;
100
99
  key: string;
101
- } | {
102
100
  error?: undefined;
101
+ } | {
103
102
  ok: boolean;
104
103
  removed: boolean;
104
+ error?: undefined;
105
105
  }>>;
@@ -26,8 +26,8 @@ export declare function createRealtimeTokenHandler(): import("h3").EventHandlerW
26
26
  expiresAt?: undefined;
27
27
  ttlSeconds?: undefined;
28
28
  } | {
29
+ error?: undefined;
29
30
  token: string;
30
31
  expiresAt: string;
31
32
  ttlSeconds: number;
32
- error?: undefined;
33
33
  }>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-native/core",
3
- "version": "0.174.2-nightly-20260825214843",
3
+ "version": "0.174.2",
4
4
  "description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
5
5
  "homepage": "https://github.com/BuilderIO/agent-native#readme",
6
6
  "bugs": {
@@ -429,8 +429,8 @@
429
429
  "y-protocols": "^1.0.7",
430
430
  "yjs": "^13.6.32",
431
431
  "zod": "^4.3.6",
432
- "@agent-native/recap-cli": "0.5.12",
433
- "@agent-native/toolkit": "^0.16.15"
432
+ "@agent-native/recap-cli": "0.5.13",
433
+ "@agent-native/toolkit": "^0.16.16"
434
434
  },
435
435
  "devDependencies": {
436
436
  "@ai-sdk/anthropic": "^3.0.71",