agentface 0.11.0 → 0.11.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.
Files changed (2) hide show
  1. package/dist/agentface.mjs +617 -157
  2. package/package.json +1 -1
@@ -3128,14 +3128,14 @@ var require_lib = __commonJS({
3128
3128
  super.checkParams(node2, false, true);
3129
3129
  this.scope.exit();
3130
3130
  }
3131
- forwardNoArrowParamsConversionAt(node2, parse5) {
3131
+ forwardNoArrowParamsConversionAt(node2, parse6) {
3132
3132
  let result2;
3133
3133
  if (this.state.noArrowParamsConversionAt.includes(this.offsetToSourcePos(node2.start))) {
3134
3134
  this.state.noArrowParamsConversionAt.push(this.state.start);
3135
- result2 = parse5();
3135
+ result2 = parse6();
3136
3136
  this.state.noArrowParamsConversionAt.pop();
3137
3137
  } else {
3138
- result2 = parse5();
3138
+ result2 = parse6();
3139
3139
  }
3140
3140
  return result2;
3141
3141
  }
@@ -13053,8 +13053,8 @@ var require_lib = __commonJS({
13053
13053
  this.state.maybeInArrowParameters = oldMaybeInArrowParameters;
13054
13054
  if (!res) return;
13055
13055
  const startPos = this.offsetToSourcePos(startLoc.index);
13056
- const parse5 = () => res.returnType && this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithDeferredArrowErrors(() => super.parseArrowExpression(res, null, true)) : super.parseArrowExpression(res, null, true);
13057
- return this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithRestrictedArrowReturnType(parse5, this.hasPlugin("jsx") || this.state.tsArrowReturnTypeAllowed) : parse5();
13056
+ const parse6 = () => res.returnType && this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithDeferredArrowErrors(() => super.parseArrowExpression(res, null, true)) : super.parseArrowExpression(res, null, true);
13057
+ return this.tsIsArrowReturnTypeRestrictedAt(startPos) ? this.tsParseWithRestrictedArrowReturnType(parse6, this.hasPlugin("jsx") || this.state.tsArrowReturnTypeAllowed) : parse6();
13058
13058
  }
13059
13059
  tsParseTypeArgumentsInExpression() {
13060
13060
  if (this.reScan_lt() !== 47) return;
@@ -13598,12 +13598,12 @@ var require_lib = __commonJS({
13598
13598
  this.state.tsArrowReturnTypeAllowed = allowsReturnType;
13599
13599
  this.state.tsGenericArrowParams = genericParams;
13600
13600
  }
13601
- tsParseWithRestrictedArrowReturnType(parse5, allowsReturnType = false, genericParams = false) {
13601
+ tsParseWithRestrictedArrowReturnType(parse6, allowsReturnType = false, genericParams = false) {
13602
13602
  const oldAllowed = this.state.tsArrowReturnTypeAllowed;
13603
13603
  const oldGeneric = this.state.tsGenericArrowParams;
13604
13604
  const oldStart = this.state.tsArrowReturnTypeRestrictionAt;
13605
13605
  this.tsRestrictArrowReturnTypeAt(this.state.start, allowsReturnType, genericParams);
13606
- const result2 = parse5();
13606
+ const result2 = parse6();
13607
13607
  this.state.tsArrowReturnTypeRestrictionAt = oldStart;
13608
13608
  this.state.tsArrowReturnTypeAllowed = oldAllowed;
13609
13609
  this.state.tsGenericArrowParams = oldGeneric;
@@ -13780,11 +13780,11 @@ var require_lib = __commonJS({
13780
13780
  this.state.tsGenericArrowParams = oldGeneric;
13781
13781
  return node2;
13782
13782
  }
13783
- tsParseWithDeferredArrowErrors(parse5) {
13784
- if (this.optionFlags & 2048) return parse5();
13783
+ tsParseWithDeferredArrowErrors(parse6) {
13784
+ if (this.optionFlags & 2048) return parse6();
13785
13785
  this.optionFlags |= 2048;
13786
13786
  try {
13787
- return parse5();
13787
+ return parse6();
13788
13788
  } finally {
13789
13789
  this.optionFlags &= ~2048;
13790
13790
  }
@@ -13797,19 +13797,19 @@ var require_lib = __commonJS({
13797
13797
  tsParseMaybeArrowWithRestrictedReturnType(startPos, refExpressionErrors, afterLeftParse) {
13798
13798
  if (!this.noArrowAt.has(startPos)) {
13799
13799
  const allowsReturnType = this.state.tsArrowReturnTypeAllowed;
13800
- const parse5 = () => this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13800
+ const parse6 = () => this.tsParseMaybeAssign(refExpressionErrors, afterLeftParse);
13801
13801
  let state = this.state.clone();
13802
13802
  const {
13803
13803
  tokensLength
13804
13804
  } = state;
13805
13805
  this.tsArrowReturnTypeAt.delete(startPos);
13806
- let result2 = this.tryParse(parse5, state);
13806
+ let result2 = this.tryParse(parse6, state);
13807
13807
  const returnTypeStart = this.tsArrowReturnTypeAt.get(startPos);
13808
13808
  if (result2.thrown && returnTypeStart !== void 0 && !tsIsInvalidArrowParamsError(result2.error, returnTypeStart) && !(this.optionFlags & 2048)) {
13809
13809
  state = this.state.clone();
13810
13810
  this.optionFlags |= 2048;
13811
13811
  try {
13812
- result2 = this.tryParse(parse5, state);
13812
+ result2 = this.tryParse(parse6, state);
13813
13813
  } finally {
13814
13814
  this.optionFlags &= ~2048;
13815
13815
  }
@@ -14159,8 +14159,8 @@ var require_lib = __commonJS({
14159
14159
  const startPos = this.offsetToSourcePos(node2.start);
14160
14160
  if (this.tsIsArrowReturnTypeRestrictedAt(startPos)) {
14161
14161
  const genericParams = this.state.tsGenericArrowParams;
14162
- const parse5 = () => super.parseArrowExpression(node2, params, isAsync, trailingCommaLoc);
14163
- return this.tsParseWithRestrictedArrowReturnType(genericParams && node2.returnType ? () => this.tsParseWithDeferredArrowErrors(parse5) : parse5, this.state.tsArrowReturnTypeAllowed || !genericParams && tsHasUnambiguousArrowParams(params));
14162
+ const parse6 = () => super.parseArrowExpression(node2, params, isAsync, trailingCommaLoc);
14163
+ return this.tsParseWithRestrictedArrowReturnType(genericParams && node2.returnType ? () => this.tsParseWithDeferredArrowErrors(parse6) : parse6, this.state.tsArrowReturnTypeAllowed || !genericParams && tsHasUnambiguousArrowParams(params));
14164
14164
  }
14165
14165
  return super.parseArrowExpression(node2, params, isAsync, trailingCommaLoc);
14166
14166
  }
@@ -14940,7 +14940,7 @@ var require_lib = __commonJS({
14940
14940
  return result2;
14941
14941
  }
14942
14942
  };
14943
- function parse4(input, options) {
14943
+ function parse5(input, options) {
14944
14944
  var _options;
14945
14945
  if (((_options = options) == null ? void 0 : _options.sourceType) === "unambiguous") {
14946
14946
  options = Object.assign({}, options);
@@ -15027,7 +15027,7 @@ var require_lib = __commonJS({
15027
15027
  }
15028
15028
  return cls;
15029
15029
  }
15030
- exports.parse = parse4;
15030
+ exports.parse = parse5;
15031
15031
  exports.parseExpression = parseExpression;
15032
15032
  exports.tokTypes = tokTypes;
15033
15033
  }
@@ -15075,7 +15075,7 @@ var require_ms = __commonJS({
15075
15075
  options = options || {};
15076
15076
  var type = typeof val;
15077
15077
  if (type === "string" && val.length > 0) {
15078
- return parse4(val);
15078
+ return parse5(val);
15079
15079
  } else if (type === "number" && isFinite(val)) {
15080
15080
  return options.long ? fmtLong(val) : fmtShort(val);
15081
15081
  }
@@ -15083,7 +15083,7 @@ var require_ms = __commonJS({
15083
15083
  "val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
15084
15084
  );
15085
15085
  };
15086
- function parse4(str) {
15086
+ function parse5(str) {
15087
15087
  str = String(str);
15088
15088
  if (str.length > 100) {
15089
15089
  return;
@@ -32701,18 +32701,18 @@ var require_trace_mapping_umd = __commonJS({
32701
32701
  state.lastNeedle = needle;
32702
32702
  return state.lastIndex = binarySearch(haystack, needle, low, high);
32703
32703
  }
32704
- function parse4(map) {
32704
+ function parse5(map) {
32705
32705
  return typeof map === "string" ? JSON.parse(map) : map;
32706
32706
  }
32707
32707
  var FlattenMap = function(map, mapUrl) {
32708
- const parsed = parse4(map);
32708
+ const parsed = parse5(map);
32709
32709
  if (!("sections" in parsed)) {
32710
32710
  return new TraceMap(parsed, mapUrl);
32711
32711
  }
32712
32712
  const mappings = [];
32713
32713
  const sources = [];
32714
32714
  const sourcesContent = [];
32715
- const names = [];
32715
+ const names2 = [];
32716
32716
  const ignoreList = [];
32717
32717
  recurse(
32718
32718
  parsed,
@@ -32720,7 +32720,7 @@ var require_trace_mapping_umd = __commonJS({
32720
32720
  mappings,
32721
32721
  sources,
32722
32722
  sourcesContent,
32723
- names,
32723
+ names2,
32724
32724
  ignoreList,
32725
32725
  0,
32726
32726
  0,
@@ -32730,7 +32730,7 @@ var require_trace_mapping_umd = __commonJS({
32730
32730
  const joined = {
32731
32731
  version: 3,
32732
32732
  file: parsed.file,
32733
- names,
32733
+ names: names2,
32734
32734
  sources,
32735
32735
  sourcesContent,
32736
32736
  mappings,
@@ -32738,7 +32738,7 @@ var require_trace_mapping_umd = __commonJS({
32738
32738
  };
32739
32739
  return presortedDecodedMap(joined);
32740
32740
  };
32741
- function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
32741
+ function recurse(input, mapUrl, mappings, sources, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
32742
32742
  const { sections } = input;
32743
32743
  for (let i = 0; i < sections.length; i++) {
32744
32744
  const { map, offset } = sections[i];
@@ -32759,7 +32759,7 @@ var require_trace_mapping_umd = __commonJS({
32759
32759
  mappings,
32760
32760
  sources,
32761
32761
  sourcesContent,
32762
- names,
32762
+ names2,
32763
32763
  ignoreList,
32764
32764
  lineOffset + offset.line,
32765
32765
  columnOffset + offset.column,
@@ -32768,16 +32768,16 @@ var require_trace_mapping_umd = __commonJS({
32768
32768
  );
32769
32769
  }
32770
32770
  }
32771
- function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
32772
- const parsed = parse4(input);
32771
+ function addSection(input, mapUrl, mappings, sources, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
32772
+ const parsed = parse5(input);
32773
32773
  if ("sections" in parsed) return recurse(...arguments);
32774
32774
  const map = new TraceMap(parsed, mapUrl);
32775
32775
  const sourcesOffset = sources.length;
32776
- const namesOffset = names.length;
32776
+ const namesOffset = names2.length;
32777
32777
  const decoded = decodedMappings(map);
32778
32778
  const { resolvedSources, sourcesContent: contents2, ignoreList: ignores } = map;
32779
32779
  append(sources, resolvedSources);
32780
- append(names, map.names);
32780
+ append(names2, map.names);
32781
32781
  if (contents2) append(sourcesContent, contents2);
32782
32782
  else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);
32783
32783
  if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset);
@@ -32819,11 +32819,11 @@ var require_trace_mapping_umd = __commonJS({
32819
32819
  constructor(map, mapUrl) {
32820
32820
  const isString = typeof map === "string";
32821
32821
  if (!isString && map._decodedMemo) return map;
32822
- const parsed = parse4(map);
32823
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
32822
+ const parsed = parse5(map);
32823
+ const { version, file, names: names2, sourceRoot, sources, sourcesContent } = parsed;
32824
32824
  this.version = version;
32825
32825
  this.file = file;
32826
- this.names = names || [];
32826
+ this.names = names2 || [];
32827
32827
  this.sourceRoot = sourceRoot;
32828
32828
  this.sources = sources;
32829
32829
  this.sourcesContent = sourcesContent;
@@ -32889,12 +32889,12 @@ var require_trace_mapping_umd = __commonJS({
32889
32889
  if (index === -1) return OMapping(null, null, null, null);
32890
32890
  const segment = segments[index];
32891
32891
  if (segment.length === 1) return OMapping(null, null, null, null);
32892
- const { names, resolvedSources } = map;
32892
+ const { names: names2, resolvedSources } = map;
32893
32893
  return OMapping(
32894
32894
  resolvedSources[segment[SOURCES_INDEX]],
32895
32895
  segment[SOURCE_LINE] + 1,
32896
32896
  segment[SOURCE_COLUMN],
32897
- segment.length === 5 ? names[segment[NAMES_INDEX]] : null
32897
+ segment.length === 5 ? names2[segment[NAMES_INDEX]] : null
32898
32898
  );
32899
32899
  }
32900
32900
  function generatedPositionFor(map, needle) {
@@ -32907,7 +32907,7 @@ var require_trace_mapping_umd = __commonJS({
32907
32907
  }
32908
32908
  function eachMapping(map, cb) {
32909
32909
  const decoded = decodedMappings(map);
32910
- const { names, resolvedSources } = map;
32910
+ const { names: names2, resolvedSources } = map;
32911
32911
  for (let i = 0; i < decoded.length; i++) {
32912
32912
  const line = decoded[i];
32913
32913
  for (let j = 0; j < line.length; j++) {
@@ -32923,7 +32923,7 @@ var require_trace_mapping_umd = __commonJS({
32923
32923
  originalLine = seg[2] + 1;
32924
32924
  originalColumn = seg[3];
32925
32925
  }
32926
- if (seg.length === 5) name = names[seg[4]];
32926
+ if (seg.length === 5) name = names2[seg[4]];
32927
32927
  cb({
32928
32928
  generatedLine,
32929
32929
  generatedColumn,
@@ -33217,7 +33217,7 @@ var require_gen_mapping_umd = __commonJS({
33217
33217
  _mappings: mappings,
33218
33218
  _sources: sources,
33219
33219
  _sourcesContent: sourcesContent,
33220
- _names: names,
33220
+ _names: names2,
33221
33221
  _ignoreList: ignoreList
33222
33222
  // _originalScopes: originalScopes,
33223
33223
  // _generatedRanges: generatedRanges,
@@ -33226,7 +33226,7 @@ var require_gen_mapping_umd = __commonJS({
33226
33226
  return {
33227
33227
  version: 3,
33228
33228
  file: map.file || void 0,
33229
- names: names.array,
33229
+ names: names2.array,
33230
33230
  sourceRoot: map.sourceRoot || void 0,
33231
33231
  sources: sources.array,
33232
33232
  sourcesContent,
@@ -33256,7 +33256,7 @@ var require_gen_mapping_umd = __commonJS({
33256
33256
  }
33257
33257
  function allMappings(map) {
33258
33258
  const out = [];
33259
- const { _mappings: mappings, _sources: sources, _names: names } = cast2(map);
33259
+ const { _mappings: mappings, _sources: sources, _names: names2 } = cast2(map);
33260
33260
  for (let i = 0; i < mappings.length; i++) {
33261
33261
  const line = mappings[i];
33262
33262
  for (let j = 0; j < line.length; j++) {
@@ -33268,7 +33268,7 @@ var require_gen_mapping_umd = __commonJS({
33268
33268
  if (seg.length !== 1) {
33269
33269
  source = sources.array[seg[SOURCES_INDEX]];
33270
33270
  original = { line: seg[SOURCE_LINE] + 1, column: seg[SOURCE_COLUMN] };
33271
- if (seg.length === 5) name = names.array[seg[NAMES_INDEX]];
33271
+ if (seg.length === 5) name = names2.array[seg[NAMES_INDEX]];
33272
33272
  }
33273
33273
  out.push({ generated, source, original, name });
33274
33274
  }
@@ -33280,7 +33280,7 @@ var require_gen_mapping_umd = __commonJS({
33280
33280
  _mappings: mappings,
33281
33281
  _sources: sources,
33282
33282
  _sourcesContent: sourcesContent,
33283
- _names: names
33283
+ _names: names2
33284
33284
  // _originalScopes: originalScopes,
33285
33285
  } = cast2(map);
33286
33286
  const line = getIndex(mappings, genLine);
@@ -33292,7 +33292,7 @@ var require_gen_mapping_umd = __commonJS({
33292
33292
  assert(sourceLine);
33293
33293
  assert(sourceColumn);
33294
33294
  const sourcesIndex = put(sources, source);
33295
- const namesIndex = name ? put(names, name) : NO_NAME;
33295
+ const namesIndex = name ? put(names2, name) : NO_NAME;
33296
33296
  if (sourcesIndex === sourcesContent.length) sourcesContent[sourcesIndex] = content != null ? content : null;
33297
33297
  if (skipable && skipSource(line, index, sourcesIndex, sourceLine, sourceColumn, namesIndex)) {
33298
33298
  return;
@@ -33592,18 +33592,18 @@ var require_trace_mapping_umd2 = __commonJS({
33592
33592
  state.lastNeedle = needle;
33593
33593
  return state.lastIndex = binarySearch(haystack, needle, low, high);
33594
33594
  }
33595
- function parse4(map) {
33595
+ function parse5(map) {
33596
33596
  return typeof map === "string" ? JSON.parse(map) : map;
33597
33597
  }
33598
33598
  var FlattenMap = function(map, mapUrl) {
33599
- const parsed = parse4(map);
33599
+ const parsed = parse5(map);
33600
33600
  if (!("sections" in parsed)) {
33601
33601
  return new TraceMap(parsed, mapUrl);
33602
33602
  }
33603
33603
  const mappings = [];
33604
33604
  const sources = [];
33605
33605
  const sourcesContent = [];
33606
- const names = [];
33606
+ const names2 = [];
33607
33607
  const ignoreList = [];
33608
33608
  recurse(
33609
33609
  parsed,
@@ -33611,7 +33611,7 @@ var require_trace_mapping_umd2 = __commonJS({
33611
33611
  mappings,
33612
33612
  sources,
33613
33613
  sourcesContent,
33614
- names,
33614
+ names2,
33615
33615
  ignoreList,
33616
33616
  0,
33617
33617
  0,
@@ -33621,7 +33621,7 @@ var require_trace_mapping_umd2 = __commonJS({
33621
33621
  const joined = {
33622
33622
  version: 3,
33623
33623
  file: parsed.file,
33624
- names,
33624
+ names: names2,
33625
33625
  sources,
33626
33626
  sourcesContent,
33627
33627
  mappings,
@@ -33629,7 +33629,7 @@ var require_trace_mapping_umd2 = __commonJS({
33629
33629
  };
33630
33630
  return presortedDecodedMap(joined);
33631
33631
  };
33632
- function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
33632
+ function recurse(input, mapUrl, mappings, sources, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
33633
33633
  const { sections } = input;
33634
33634
  for (let i = 0; i < sections.length; i++) {
33635
33635
  const { map, offset } = sections[i];
@@ -33650,7 +33650,7 @@ var require_trace_mapping_umd2 = __commonJS({
33650
33650
  mappings,
33651
33651
  sources,
33652
33652
  sourcesContent,
33653
- names,
33653
+ names2,
33654
33654
  ignoreList,
33655
33655
  lineOffset + offset.line,
33656
33656
  columnOffset + offset.column,
@@ -33659,16 +33659,16 @@ var require_trace_mapping_umd2 = __commonJS({
33659
33659
  );
33660
33660
  }
33661
33661
  }
33662
- function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
33663
- const parsed = parse4(input);
33662
+ function addSection(input, mapUrl, mappings, sources, sourcesContent, names2, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
33663
+ const parsed = parse5(input);
33664
33664
  if ("sections" in parsed) return recurse(...arguments);
33665
33665
  const map = new TraceMap(parsed, mapUrl);
33666
33666
  const sourcesOffset = sources.length;
33667
- const namesOffset = names.length;
33667
+ const namesOffset = names2.length;
33668
33668
  const decoded = decodedMappings(map);
33669
33669
  const { resolvedSources, sourcesContent: contents2, ignoreList: ignores } = map;
33670
33670
  append(sources, resolvedSources);
33671
- append(names, map.names);
33671
+ append(names2, map.names);
33672
33672
  if (contents2) append(sourcesContent, contents2);
33673
33673
  else for (let i = 0; i < resolvedSources.length; i++) sourcesContent.push(null);
33674
33674
  if (ignores) for (let i = 0; i < ignores.length; i++) ignoreList.push(ignores[i] + sourcesOffset);
@@ -33710,11 +33710,11 @@ var require_trace_mapping_umd2 = __commonJS({
33710
33710
  constructor(map, mapUrl) {
33711
33711
  const isString = typeof map === "string";
33712
33712
  if (!isString && map._decodedMemo) return map;
33713
- const parsed = parse4(map);
33714
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
33713
+ const parsed = parse5(map);
33714
+ const { version, file, names: names2, sourceRoot, sources, sourcesContent } = parsed;
33715
33715
  this.version = version;
33716
33716
  this.file = file;
33717
- this.names = names || [];
33717
+ this.names = names2 || [];
33718
33718
  this.sourceRoot = sourceRoot;
33719
33719
  this.sources = sources;
33720
33720
  this.sourcesContent = sourcesContent;
@@ -33780,12 +33780,12 @@ var require_trace_mapping_umd2 = __commonJS({
33780
33780
  if (index === -1) return OMapping(null, null, null, null);
33781
33781
  const segment = segments[index];
33782
33782
  if (segment.length === 1) return OMapping(null, null, null, null);
33783
- const { names, resolvedSources } = map;
33783
+ const { names: names2, resolvedSources } = map;
33784
33784
  return OMapping(
33785
33785
  resolvedSources[segment[SOURCES_INDEX]],
33786
33786
  segment[SOURCE_LINE] + 1,
33787
33787
  segment[SOURCE_COLUMN],
33788
- segment.length === 5 ? names[segment[NAMES_INDEX]] : null
33788
+ segment.length === 5 ? names2[segment[NAMES_INDEX]] : null
33789
33789
  );
33790
33790
  }
33791
33791
  function generatedPositionFor(map, needle) {
@@ -33798,7 +33798,7 @@ var require_trace_mapping_umd2 = __commonJS({
33798
33798
  }
33799
33799
  function eachMapping(map, cb) {
33800
33800
  const decoded = decodedMappings(map);
33801
- const { names, resolvedSources } = map;
33801
+ const { names: names2, resolvedSources } = map;
33802
33802
  for (let i = 0; i < decoded.length; i++) {
33803
33803
  const line = decoded[i];
33804
33804
  for (let j = 0; j < line.length; j++) {
@@ -33814,7 +33814,7 @@ var require_trace_mapping_umd2 = __commonJS({
33814
33814
  originalLine = seg[2] + 1;
33815
33815
  originalColumn = seg[3];
33816
33816
  }
33817
- if (seg.length === 5) name = names[seg[4]];
33817
+ if (seg.length === 5) name = names2[seg[4]];
33818
33818
  cb({
33819
33819
  generatedLine,
33820
33820
  generatedColumn,
@@ -42273,12 +42273,12 @@ var require_literal = __commonJS({
42273
42273
  function literalTemplate(formatter, tpl, opts) {
42274
42274
  const {
42275
42275
  metadata,
42276
- names
42276
+ names: names2
42277
42277
  } = buildLiteralData(formatter, tpl, opts);
42278
42278
  return (arg) => {
42279
42279
  const defaultReplacements = {};
42280
42280
  arg.forEach((replacement, i) => {
42281
- defaultReplacements[names[i]] = replacement;
42281
+ defaultReplacements[names2[i]] = replacement;
42282
42282
  });
42283
42283
  return (arg2) => {
42284
42284
  const replacements = (0, _options.normalizeReplacements)(arg2);
@@ -42300,31 +42300,31 @@ var require_literal = __commonJS({
42300
42300
  prefix = "$$" + prefix;
42301
42301
  } while (raw.includes(prefix));
42302
42302
  const {
42303
- names,
42303
+ names: names2,
42304
42304
  code
42305
42305
  } = buildTemplateCode(tpl, prefix);
42306
42306
  const metadata = (0, _parse.default)(formatter, formatter.code(code), {
42307
42307
  parser: opts.parser,
42308
- placeholderWhitelist: new Set(names.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])),
42308
+ placeholderWhitelist: new Set(names2.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])),
42309
42309
  placeholderPattern: opts.placeholderPattern,
42310
42310
  preserveComments: opts.preserveComments,
42311
42311
  syntacticPlaceholders: opts.syntacticPlaceholders
42312
42312
  });
42313
42313
  return {
42314
42314
  metadata,
42315
- names
42315
+ names: names2
42316
42316
  };
42317
42317
  }
42318
42318
  function buildTemplateCode(tpl, prefix) {
42319
- const names = [];
42319
+ const names2 = [];
42320
42320
  let code = tpl[0];
42321
42321
  for (let i = 1; i < tpl.length; i++) {
42322
42322
  const value = `${prefix}${i - 1}`;
42323
- names.push(value);
42323
+ names2.push(value);
42324
42324
  code += value + tpl[i];
42325
42325
  }
42326
42326
  return {
42327
- names,
42327
+ names: names2,
42328
42328
  code
42329
42329
  };
42330
42330
  }
@@ -45176,7 +45176,7 @@ function headEnd(html) {
45176
45176
  // cli/package.json
45177
45177
  var package_default = {
45178
45178
  name: "agentface",
45179
- version: "0.11.0",
45179
+ version: "0.11.1",
45180
45180
  description: "Add the Agentface tag to a website's pages, so AI agents get tools made for it, and use your agentface account from a shell.",
45181
45181
  repository: {
45182
45182
  type: "git",
@@ -45862,6 +45862,46 @@ var LAYOUTS = [
45862
45862
  /(?:^|\/)routes\/__root\.[cm]?[jt]sx?$/,
45863
45863
  /(?:^|\/)src\/html\.[cm]?[jt]sx?$/
45864
45864
  ];
45865
+ var PAGES = {
45866
+ "Next.js": [/^public\//, "the templates in public/"],
45867
+ "TanStack Start": [/^public\//, "the templates in public/"],
45868
+ "React Router": [/^public\//, "the templates in public/"],
45869
+ Remix: [/^public\//, "the templates in public/"],
45870
+ Gatsby: [/^static\//, "the templates in static/"],
45871
+ SvelteKit: [
45872
+ /^(?:src\/(?:app|error)\.html$|static\/)/,
45873
+ "src/app.html, src/error.html and the templates in static/"
45874
+ ],
45875
+ Astro: [/\.astro$|^(?:public|src\/pages)\//, ".astro files and the templates in public/ and src/pages/"],
45876
+ "Create React App": [/^public\//, "the templates in public/"],
45877
+ "Vue CLI": [/^public\//, "the templates in public/"],
45878
+ Angular: [
45879
+ /(?:^|\/)src\/(?:index\.html$|assets\/)|^public\//,
45880
+ "src/index.html and the templates in src/assets/ and public/"
45881
+ ]
45882
+ };
45883
+ var NAMED = {
45884
+ "Vue CLI": [
45885
+ ["vue.config.js", "vue.config.cjs", "vue.config.mjs", "package.json"],
45886
+ /\btemplate['"]?\s*:\s*(['"`])([^'"`\n]+)\1/g
45887
+ ],
45888
+ Angular: [["angular.json"], /"(?:index|input)"\s*:\s*(")([^"\n]+)\1/g],
45889
+ SvelteKit: [
45890
+ ["svelte.config.js", "svelte.config.mjs", "svelte.config.cjs", "svelte.config.ts"],
45891
+ /\b(?:app|error)Template\s*:\s*(['"`])([^'"`\n]+)\1/g
45892
+ ]
45893
+ };
45894
+ var COMMENT = /(['"`])(?:\\[\s\S]|(?!\1)[^\\])*\1|\/\/[^\n]*|\/\*[\s\S]*?\*\//g;
45895
+ var uncommented = (text2) => text2.replace(COMMENT, (match, quote) => quote ? match : "");
45896
+ async function namedTemplates(dir, framework) {
45897
+ const named = /* @__PURE__ */ new Set();
45898
+ if (!NAMED[framework]) return named;
45899
+ const [files2, name] = NAMED[framework];
45900
+ for (const file of files2)
45901
+ for (const [, , template] of uncommented(await read(path2.join(dir, file)) ?? "").matchAll(name))
45902
+ named.add(path2.posix.normalize(template));
45903
+ return named;
45904
+ }
45865
45905
  var SKIP = /* @__PURE__ */ new Set([
45866
45906
  "node_modules",
45867
45907
  "bower_components",
@@ -46026,8 +46066,8 @@ function updatedTag(old, tag) {
46026
46066
  return kept.length ? tag.replace(/^<script\b/, () => `<script ${kept.join(" ")}`) : tag;
46027
46067
  }
46028
46068
  function initsOwn(was, now) {
46029
- const names = /* @__PURE__ */ new Set(["src", "async", "defer", "data-init", ...now.map(({ name }) => name)]);
46030
- return was.filter(({ name, value }) => name !== null && (names.has(name) || LIST.test(value ?? "")));
46069
+ const names2 = /* @__PURE__ */ new Set(["src", "async", "defer", "data-init", ...now.map(({ name }) => name)]);
46070
+ return was.filter(({ name, value }) => name !== null && (names2.has(name) || LIST.test(value ?? "")));
46031
46071
  }
46032
46072
  function ownersAttributes(old) {
46033
46073
  const was = attributesOf(old);
@@ -46065,6 +46105,7 @@ function indentUnit(source) {
46065
46105
  return source.match(/^(\t| {2,4})\S/m)?.[1] ?? " ";
46066
46106
  }
46067
46107
  var indentOf = (line) => line.match(/^[ \t]*/)[0];
46108
+ var updatedTags = (source, tag) => source.replace(TAG, (old) => old.startsWith("<script") ? updatedTag(old, tag) : old);
46068
46109
  function addTag(source, tag) {
46069
46110
  let first = true;
46070
46111
  const replaced = source.replace(onItsLine(TAG), (match, line) => {
@@ -46175,14 +46216,59 @@ ${notice ? ` ${notice}
46175
46216
  `;
46176
46217
  var LINE_NAME = "AgentfaceApi";
46177
46218
  var LINE_USE = new RegExp(`<${LINE_NAME}\\s*/>`);
46178
- var LINE_IMPORT = new RegExp(
46179
- `^import\\s+${LINE_NAME}\\s+from\\s*(['"])\\.\\.?\\/(?:[^'"\\n]*\\/)?agentface\\1;?[ \\t]*$`,
46180
- "m"
46181
- );
46182
- var usesLine = (source) => LINE_USE.test(source) && LINE_IMPORT.test(source);
46219
+ function importsComponents(file, from) {
46220
+ if (from === null) return false;
46221
+ const at = /^\.\.?\//.test(from) ? path2.posix.join(path2.posix.dirname(file), from) : from.replace(/^[@~#]*\//, "");
46222
+ return /^(?:src\/)?components\/agentface(?:\.[cm]?[jt]sx?)?$/.test(at);
46223
+ }
46224
+ var LINE_IMPORT = new RegExp(`^import\\s+${LINE_NAME}\\s+from\\s*(['"])([^'"\\n]+)\\1;?[ \\t]*$`, "gm");
46225
+ var usesLine = (source, file) => LINE_USE.test(source) && [...source.matchAll(LINE_IMPORT)].some(([, , from]) => importsComponents(file, from));
46183
46226
  var JSX_CODE = /\.(?:jsx|tsx|js|mjs|cjs)$/i;
46184
- function withoutLine(source) {
46185
- if (!usesLine(source)) return source;
46227
+ var TAG_USED = new RegExp(`${TAG.source}|<AgentfaceTag\\b`, "i");
46228
+ var hasTag = (source) => TAG_USED.test(source);
46229
+ var NOT_LOADING = /\.(?:test|spec|stories)\.[cm]?[jt]sx?$|\.mdx?$/i;
46230
+ var loadsTag = (file, source) => !NOT_LOADING.test(file) && !source.includes(OURS) && hasTag(source);
46231
+ function topNames(source) {
46232
+ const names2 = /* @__PURE__ */ new Map();
46233
+ const add = (name, from) => names2.set(name, [...names2.get(name) ?? [], from]);
46234
+ let program;
46235
+ try {
46236
+ program = (0, import_parser.parse)(source, {
46237
+ sourceType: "unambiguous",
46238
+ plugins: ["typescript", "jsx"],
46239
+ errorRecovery: true
46240
+ }).program;
46241
+ } catch {
46242
+ for (const [, clause, , from] of source.matchAll(
46243
+ /^[ \t]*import\s+(?:type\s+)?([^'";]*?)\s*from\s*(['"])([^'"\n]+)\2/gm
46244
+ ))
46245
+ for (const [name] of clause.matchAll(/[A-Za-z_$][\w$]*/g)) if (name !== "as") add(name, from);
46246
+ for (const [, name] of source.matchAll(/\b(?:function\*?|class|const|let|var)\s+([A-Za-z_$][\w$]*)/g))
46247
+ add(name, null);
46248
+ return names2;
46249
+ }
46250
+ const declared = (node2) => {
46251
+ if (!node2) return;
46252
+ if (node2.type === "Identifier") add(node2.name, null);
46253
+ else if (node2.type === "ObjectPattern")
46254
+ for (const property of node2.properties)
46255
+ declared(property.type === "RestElement" ? property : property.value);
46256
+ else if (node2.type === "ArrayPattern") node2.elements.forEach(declared);
46257
+ else if (node2.type === "AssignmentPattern") declared(node2.left);
46258
+ else if (node2.type === "RestElement") declared(node2.argument);
46259
+ };
46260
+ for (const statement of program.body) {
46261
+ const node2 = statement.type === "ExportNamedDeclaration" || statement.type === "ExportDefaultDeclaration" ? statement.declaration : statement;
46262
+ if (!node2) continue;
46263
+ if (node2.type === "ImportDeclaration")
46264
+ for (const specifier of node2.specifiers) add(specifier.local.name, node2.source.value);
46265
+ else if (node2.type === "VariableDeclaration") for (const { id } of node2.declarations) declared(id);
46266
+ else if ("id" in node2 && node2.id?.type === "Identifier") add(node2.id.name, null);
46267
+ }
46268
+ return names2;
46269
+ }
46270
+ function withoutLine(source, file) {
46271
+ if (!usesLine(source, file)) return source;
46186
46272
  return source.replace(new RegExp(`\\r?\\n[ \\t]*<${LINE_NAME}\\s*\\/>(?=[ \\t]*\\r?\\n)`, "g"), "").replace(new RegExp(`<${LINE_NAME}\\s*\\/>`, "g"), "").replace(
46187
46273
  new RegExp(`^import\\s+${LINE_NAME}\\s+from\\s*(['"])[^'"\\n]+\\1;?[ \\t]*\\r?\\n(\\r?\\n)?`, "m"),
46188
46274
  (match, quote, blank, offset) => blank && offset ? blank : ""
@@ -46219,6 +46305,10 @@ async function project(dir) {
46219
46305
  const { files: list2, git } = await files(dir, skip);
46220
46306
  return { deps, framework, list: list2, git };
46221
46307
  }
46308
+ function otherPackages(list2) {
46309
+ const folders = list2.filter((file) => file.endsWith("/package.json")).map((file) => file.slice(0, -"package.json".length));
46310
+ return folders.filter((folder) => !folders.some((outer) => outer !== folder && folder.startsWith(outer)));
46311
+ }
46222
46312
  async function findTags(dir) {
46223
46313
  const { list: list2 } = await project(dir);
46224
46314
  const plugin = await isWordPress(dir) && await wordPressFile(dir) || await prestaShopFile(dir);
@@ -46228,7 +46318,7 @@ async function findTags(dir) {
46228
46318
  const source = await contents(dir, file);
46229
46319
  if (source === null) continue;
46230
46320
  const key = tagKey(source) ?? noticeKey(source);
46231
- if (key || JSX_CODE.test(file) && usesLine(source)) tagged.push({ file, source, key });
46321
+ if (key || JSX_CODE.test(file) && usesLine(source, file)) tagged.push({ file, source, key });
46232
46322
  }
46233
46323
  return tagged;
46234
46324
  }
@@ -46290,9 +46380,9 @@ function madeByInit(source) {
46290
46380
  ];
46291
46381
  return made.some(([write, tag, notice]) => tag && sameFile(source, write(tag, notice ?? null)));
46292
46382
  }
46293
- function removeTag(source) {
46383
+ function removeTag(source, keep = {}) {
46294
46384
  if (source.includes(OURS) && madeByInit(source)) return null;
46295
- return [TAG, NOTICE].reduce(
46385
+ return [keep.tag ? null : TAG, keep.notice ? null : NOTICE].filter((pattern) => pattern !== null).reduce(
46296
46386
  (text2, pattern) => text2.replace(onItsLine(pattern), (match, line, ...rest) => {
46297
46387
  const after = rest.at(-1).slice(rest.at(-2) + match.length);
46298
46388
  return line && !/^[ \t]*(?:\r?\n|$)/.test(after) ? line : "";
@@ -46366,26 +46456,61 @@ async function findHeads(dir) {
46366
46456
  const noticed = [];
46367
46457
  const amp = [];
46368
46458
  const code = [];
46459
+ const packages = otherPackages(list2);
46460
+ const apart = /* @__PURE__ */ new Set();
46461
+ const served = PAGES[framework]?.[0];
46462
+ const named = await namedTemplates(dir, framework);
46463
+ const tagged = [];
46464
+ const elsewhere = [];
46465
+ const placed = [];
46369
46466
  for (const file of list2) {
46370
46467
  const markup = MARKUP.test(file);
46468
+ const other = packages.find((folder) => file.startsWith(folder));
46469
+ if (markup && !other && served && !served.test(file) && !named.has(file)) continue;
46371
46470
  const page2 = (markup || LAYOUTS.some((layout) => layout.test(file))) && notMail(path2.posix.basename(file));
46372
46471
  if (!page2 && !markup && !COMPONENT.test(file)) continue;
46472
+ if (other && !page2) continue;
46373
46473
  const text2 = await contents(dir, file);
46374
46474
  if (text2 === null) continue;
46375
46475
  let head = page2 && (markup ? /<\/head\s*>/i.test(text2) : /<\/head\s*>|<html\b/i.test(text2));
46476
+ if (other) {
46477
+ if (head) apart.add(other);
46478
+ continue;
46479
+ }
46376
46480
  let body = page2 && BODY.test(text2);
46481
+ let left = false;
46377
46482
  if (head && markup && AMP.test(text2)) {
46378
46483
  amp.push(file);
46379
46484
  head = body = false;
46485
+ left = true;
46380
46486
  } else if (head && markup && inCode(text2, headEnd(text2))) {
46381
46487
  code.push(file);
46382
46488
  head = body = false;
46489
+ left = true;
46383
46490
  }
46384
46491
  if (head) heads.push({ file, source: text2 });
46492
+ else if (!amp.includes(file) && !code.includes(file) && loadsTag(file, text2))
46493
+ placed.push({ file, source: text2 });
46385
46494
  if (body) bodies.push({ file, source: text2 });
46386
46495
  const notice = body ? null : noticeKey(text2);
46387
46496
  if (notice) noticed.push({ file, key: notice, source: text2 });
46497
+ const key = head ? null : tagKey(text2);
46498
+ if (key) elsewhere.push(key);
46499
+ if (key && !left && !text2.includes(OURS)) tagged.push({ file, key, source: text2 });
46388
46500
  }
46501
+ const skipped = leftOut(amp, code, [...apart]);
46502
+ if (placed.length && !heads.some(({ source }) => hasTag(source)))
46503
+ return {
46504
+ framework,
46505
+ heads: [],
46506
+ bodies: bodies.filter(({ source }) => noticeKey(source)),
46507
+ creates: [],
46508
+ noticed,
46509
+ scoped: { files: placed, left: heads.map(({ file }) => file) },
46510
+ key: placed.map(({ source }) => tagKey(source)).find(Boolean) ?? elsewhere[0] ?? null,
46511
+ ...skipped && { skipped },
46512
+ ...apart.size && { apart: [...apart] }
46513
+ };
46389
46514
  const creates = [];
46390
46515
  if (deps.next && !heads.some(({ file }) => /(?:^|\/)app\//.test(file))) {
46391
46516
  if (!heads.some(({ file }) => /pages\/_document\./.test(file))) {
@@ -46407,10 +46532,10 @@ async function findHeads(dir) {
46407
46532
  });
46408
46533
  creates.push({ file: "gatsby-ssr.js", content: GATSBY_SSR, source: text2 });
46409
46534
  }
46410
- const skipped = leftOut(amp, code);
46535
+ const only = PAGES[framework] ? ` For ${framework}, it reads only ${PAGES[framework][1]}, as ${framework} makes no page of any other HTML file.` : "";
46411
46536
  if (!heads.length && !creates.length)
46412
46537
  return byHand(dir, list2, framework, {
46413
- reason: skipped ? `init found no <head> it can put the tag in. ${skipped}` : `init found no <head> to put the tag in. It looks in this folder${git ? ", leaving out what git ignores," : ""} for templates that close a </head> (${EXTENSIONS.map((ext) => "." + ext).join(", ")}) and for the root layouts of Next.js, Remix, React Router, TanStack Start and Gatsby. A head that comes from a theme or a package needs its template copied into the project first.`,
46538
+ reason: skipped ? `init found no <head> it can put the tag in. ${skipped}` : `init found no <head> to put the tag in. It looks in this folder${git ? ", leaving out what git ignores," : ""} for templates that close a </head> (${EXTENSIONS.map((ext) => "." + ext).join(", ")}) and for the root layouts of Next.js, Remix, React Router, TanStack Start and Gatsby.${only} A head that comes from a theme or a package needs its template copied into the project first.`,
46414
46539
  how: "Add this line by hand, last in the <head> of the layout or template every page uses",
46415
46540
  none: true
46416
46541
  });
@@ -46421,12 +46546,18 @@ async function findHeads(dir) {
46421
46546
  bodies,
46422
46547
  creates,
46423
46548
  noticed,
46424
- key: sources.map(tagKey).find(Boolean) ?? null,
46425
- ...skipped && { skipped }
46549
+ tagged,
46550
+ key: sources.map(tagKey).find(Boolean) ?? elsewhere[0] ?? null,
46551
+ ...skipped && { skipped },
46552
+ ...apart.size && { apart: [...apart] }
46426
46553
  };
46427
46554
  }
46428
- function leftOut(amp, code) {
46429
- const names = (files2) => files2.slice(0, 5).join(", ") + (files2.length > 5 ? " and others" : "");
46555
+ var names = (files2) => files2.slice(0, 5).join(", ") + (files2.length > 5 ? " and others" : "");
46556
+ function otherApps(folders) {
46557
+ if (!folders.length) return null;
46558
+ return folders.length === 1 ? `init left out ${folders[0]}, which has a package.json of its own, as another app. If its pages are this site's too, run init in that folder.` : `init left out ${names(folders)}, which have a package.json of their own, as other apps. If the pages of one are this site's too, run init in its folder.`;
46559
+ }
46560
+ function leftOut(amp, code, packages) {
46430
46561
  const said3 = [];
46431
46562
  if (amp.length)
46432
46563
  said3.push(`init left out ${names(amp)}: AMP pages allow no script of ours, so they get no tag.`);
@@ -46434,10 +46565,13 @@ function leftOut(amp, code) {
46434
46565
  said3.push(
46435
46566
  `init left out ${names(code)}, whose head is printed by server code, such as PHP's echo, where the tag's quotes would end a string. Add the tag there by hand, outside the string, or written so that the code prints its quotes as they are.`
46436
46567
  );
46568
+ const apart = otherApps(packages);
46569
+ if (apart) said3.push(apart);
46437
46570
  return said3.length ? said3.join(" ") : null;
46438
46571
  }
46439
46572
 
46440
46573
  // cli/frameworks.mts
46574
+ var import_parser5 = __toESM(require_lib(), 1);
46441
46575
  import { readFile as readFile3, stat as stat3 } from "node:fs/promises";
46442
46576
  import path3 from "node:path";
46443
46577
 
@@ -56887,10 +57021,10 @@ function addImport(source, line) {
56887
57021
  const end = last.index + last[0].length;
56888
57022
  return source.slice(0, end) + eolOf(source) + line + source.slice(end);
56889
57023
  }
56890
- function importLine(source, names, from) {
57024
+ function importLine(source, names2, from) {
56891
57025
  const last = lastMatch(source, IMPORT)?.[0] ?? `import x from '';`;
56892
57026
  const quote = last.match(/['"]/)?.[0] ?? "'";
56893
- return `import ${names} from ${quote}${from}${quote}${last.trimEnd().endsWith(";") ? ";" : ""}`;
57027
+ return `import ${names2} from ${quote}${from}${quote}${last.trimEnd().endsWith(";") ? ";" : ""}`;
56894
57028
  }
56895
57029
  var MARKUP2 = /\.(?:html?|tmpl|tpl|gohtml|ejs|hbs|handlebars|mustache|njk|liquid|twig|jinja2?|j2|eta|pug)$/i;
56896
57030
  function cleaned(found, markup = MARKUP2) {
@@ -56906,7 +57040,18 @@ async function own(p, file, content) {
56906
57040
  return { file, content, source };
56907
57041
  }
56908
57042
  var keyOf = (sources) => sources.map((source) => source ? tagKey(source) : null).find(Boolean) ?? null;
56909
- function result(p, framework, { creates, edits, heads = [], bodies = [], note, line }) {
57043
+ function result(p, framework, {
57044
+ creates,
57045
+ edits,
57046
+ heads = [],
57047
+ bodies = [],
57048
+ note,
57049
+ line,
57050
+ tagged = p.found.tagged ?? [],
57051
+ key = null,
57052
+ scoped
57053
+ }) {
57054
+ const writes = (file) => [...creates, ...edits ?? []].some((made) => made.file === file);
56910
57055
  return {
56911
57056
  framework,
56912
57057
  heads,
@@ -56914,14 +57059,23 @@ function result(p, framework, { creates, edits, heads = [], bodies = [], note, l
56914
57059
  creates,
56915
57060
  edits,
56916
57061
  line,
57062
+ ...scoped && { scoped },
56917
57063
  // Not the file init writes, which holds a copy of the notice.
56918
- noticed: (p.found.noticed ?? []).filter(({ file }) => !creates.some((create) => create.file === file)),
57064
+ noticed: (p.found.noticed ?? []).filter(({ file }) => !writes(file)),
57065
+ tagged: tagged.filter(({ file }) => !writes(file)),
56919
57066
  note,
56920
- key: keyOf([
57067
+ // Of what findHeads left out, only the other apps, which a run of init
57068
+ // in their own folder would set up. The framework's own pages are the
57069
+ // file's, which puts the lines in them as they go out.
57070
+ skipped: otherApps(p.found.apart ?? []) ?? void 0,
57071
+ // `key` when the framework names one, else the site init's files or the
57072
+ // pages name, else the one a tag elsewhere in the site's code names
57073
+ // (findHeads).
57074
+ key: key ?? keyOf([
56921
57075
  ...creates.map(({ source }) => source),
56922
57076
  ...(edits ?? []).map(({ source }) => source),
56923
57077
  ...heads.map(({ source }) => source)
56924
- ])
57078
+ ]) ?? p.found.key
56925
57079
  };
56926
57080
  }
56927
57081
  var NOTE = {
@@ -57089,13 +57243,99 @@ function fastifyEntry(source, cjs, from) {
57089
57243
  if (call === void 0) return null;
57090
57244
  return chained(source, call, ".addHook('onSend', agentface)", cjs, from, required?.index);
57091
57245
  }
57246
+ var FASTIFY_STATIC = /^(?:@fastify\/static|fastify-static)$/;
57247
+ var STATIC_NAMED = /(['"])(?:@fastify\/static|fastify-static)\1/;
57248
+ function* nodesOf(node2) {
57249
+ if (Array.isArray(node2)) for (const item of node2) yield* nodesOf(item);
57250
+ else if (node2 && typeof node2 === "object" && typeof node2.type === "string") {
57251
+ yield node2;
57252
+ for (const [key, value] of Object.entries(node2))
57253
+ if (key !== "loc" && !key.endsWith("Comments")) yield* nodesOf(value);
57254
+ }
57255
+ }
57256
+ function loadsStatic(node2) {
57257
+ if (node2?.type === "AwaitExpression") return loadsStatic(node2.argument);
57258
+ if (node2?.type !== "CallExpression") return false;
57259
+ const [name] = node2.arguments;
57260
+ const loads = node2.callee.type === "Import" || node2.callee.type === "Identifier" && node2.callee.name === "require";
57261
+ return loads && name?.type === "StringLiteral" && FASTIFY_STATIC.test(name.value);
57262
+ }
57263
+ function rootFolder(node2, file) {
57264
+ const here = posix.dirname(file) === "." ? "" : posix.dirname(file);
57265
+ const meta = (n, name2) => n.type === "MemberExpression" && n.object.type === "MetaProperty" && n.property.type === "Identifier" && n.property.name === name2;
57266
+ const start = (n) => n.type === "Identifier" && n.name === "__dirname" || meta(n, "dirname") ? here : n.type === "CallExpression" && n.callee.type === "MemberExpression" && n.callee.object.type === "Identifier" && n.callee.object.name === "process" && n.callee.property.type === "Identifier" && n.callee.property.name === "cwd" ? "" : null;
57267
+ const inside = (folder) => {
57268
+ const normal2 = posix.normalize(folder || ".");
57269
+ return normal2 === "." ? "" : /^(?:\.\.(?:\/|$)|\/)/.test(normal2) ? null : normal2.replace(/\/$/, "");
57270
+ };
57271
+ if (node2.type === "StringLiteral") return node2.value.startsWith("/") ? null : inside(node2.value);
57272
+ if (node2.type !== "CallExpression") return null;
57273
+ const { callee } = node2;
57274
+ const name = callee.type === "Identifier" ? callee.name : callee.type === "MemberExpression" && callee.property.type === "Identifier" ? callee.property.name : null;
57275
+ const args = node2.arguments;
57276
+ if (name === "join" || name === "resolve") {
57277
+ const from = args[0] ? start(args[0]) : null;
57278
+ const parts = from === null ? args : args.slice(1);
57279
+ const words = parts.map((part) => part.type === "StringLiteral" ? part.value : null);
57280
+ if (words.some((word) => word === null || name === "resolve" && word.startsWith("/"))) return null;
57281
+ return inside(posix.join(from ?? "", ...words));
57282
+ }
57283
+ const [url] = args;
57284
+ if (name === "fileURLToPath" && url?.type === "NewExpression") {
57285
+ const [where, base] = url.arguments;
57286
+ if (where?.type === "StringLiteral" && base && meta(base, "url"))
57287
+ return inside(posix.join(here, where.value));
57288
+ }
57289
+ return null;
57290
+ }
57291
+ async function staticRoots(p, code) {
57292
+ const roots = /* @__PURE__ */ new Set();
57293
+ const unknown = /* @__PURE__ */ new Set();
57294
+ for (const file of code) {
57295
+ const source = await p.read(file);
57296
+ if (!source || !STATIC_NAMED.test(source)) continue;
57297
+ let tree;
57298
+ try {
57299
+ tree = (0, import_parser5.parse)(source, { sourceType: "unambiguous", plugins: ["typescript", "jsx"] });
57300
+ } catch {
57301
+ unknown.add(file);
57302
+ continue;
57303
+ }
57304
+ const names2 = /* @__PURE__ */ new Set();
57305
+ for (const node2 of nodesOf(tree)) {
57306
+ if (node2.type === "ImportDeclaration" && FASTIFY_STATIC.test(node2.source.value))
57307
+ for (const specifier of node2.specifiers) names2.add(specifier.local.name);
57308
+ if (node2.type === "VariableDeclarator" && node2.id.type === "Identifier" && loadsStatic(node2.init))
57309
+ names2.add(node2.id.name);
57310
+ }
57311
+ for (const node2 of nodesOf(tree)) {
57312
+ if (node2.type !== "CallExpression" || node2.callee.type !== "MemberExpression" || node2.callee.property.type !== "Identifier" || node2.callee.property.name !== "register")
57313
+ continue;
57314
+ const [plugin, options] = node2.arguments;
57315
+ if (!(plugin?.type === "Identifier" ? names2.has(plugin.name) : loadsStatic(plugin))) continue;
57316
+ const root = options?.type === "ObjectExpression" ? options.properties.find(
57317
+ (property) => property.type === "ObjectProperty" && !property.computed && (property.key.type === "Identifier" && property.key.name === "root" || property.key.type === "StringLiteral" && property.key.value === "root")
57318
+ ) : void 0;
57319
+ const value = root?.type === "ObjectProperty" ? root.value : null;
57320
+ for (const folder of value?.type === "ArrayExpression" ? value.elements : [value]) {
57321
+ const at = folder && folder.type !== "SpreadElement" ? rootFolder(folder, file) : null;
57322
+ if (at === null) unknown.add(file);
57323
+ else roots.add(at);
57324
+ }
57325
+ }
57326
+ }
57327
+ return { roots: [...roots], unknown: [...unknown] };
57328
+ }
57092
57329
  async function fastify(p) {
57093
57330
  if (!p.deps.fastify) return null;
57094
57331
  const found = await entry(p, (source) => fastifyEntry(source, false, "") !== null);
57095
57332
  if (!found) return null;
57096
57333
  const made = await jsHelper(p, found.file, found.source, "fastify");
57097
57334
  if (!made || fastifyEntry(found.source, made.cjs, made.from) === null) return null;
57098
- const plain = ({ file }) => /\.html?$/i.test(file);
57335
+ const code = p.list.filter((file) => /\.(?:[cm]?[jt]sx?)$/.test(file) && !/\.d\.[cm]?ts$/.test(file));
57336
+ const { roots, unknown } = await staticRoots(p, code);
57337
+ const plain = ({ file }) => /\.html?$/i.test(file) && roots.some((folder) => !folder || file.startsWith(folder + "/"));
57338
+ const unsure = unknown.length ? ` init can't tell which folder ${unknown.join(", ")} ${unknown.length === 1 ? "serves" : "serve"} files from with @fastify/static, so it put the lines in no HTML file there: a page Fastify sends from that folder as it is needs the tag and the notice ${made.helper.file} holds, last in its <head> and first in its <body>.` : "";
57099
57339
  return result(p, "Fastify", {
57100
57340
  heads: p.found.heads.filter(plain),
57101
57341
  bodies: p.found.bodies.filter(plain),
@@ -57108,7 +57348,7 @@ async function fastify(p) {
57108
57348
  edit: (text2) => fastifyEntry(text2, made.cjs, made.from) ?? text2
57109
57349
  }
57110
57350
  ],
57111
- note: `${made.helper.file} asks Agentface for the tag and its notice as the app starts, and again once its copy is an hour old: when what they say changes, the pages change by themselves, with nothing to run or deploy. While Agentface can't be reached, the pages keep the lines they had. Plain HTML files, which Fastify sends as they are, keep the lines in them.`
57351
+ note: `${made.helper.file} asks Agentface for the tag and its notice as the app starts, and again once its copy is an hour old: when what they say changes, the pages change by themselves, with nothing to run or deploy. While Agentface can't be reached, the pages keep the lines they had. Plain HTML files, which Fastify sends as they are, keep the lines in them.${unsure}`
57112
57352
  });
57113
57353
  }
57114
57354
  var escaped = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
@@ -57293,6 +57533,7 @@ async function django(p) {
57293
57533
  if (!helper) return null;
57294
57534
  const { file, source } = settings;
57295
57535
  const templates = (template) => /(?:^|\/)templates\//.test(template);
57536
+ const raw = (page2) => /(?:^|\/)static\//.test(page2);
57296
57537
  return result(p, "Django", {
57297
57538
  creates: [helper],
57298
57539
  edits: [
@@ -57303,8 +57544,8 @@ async function django(p) {
57303
57544
  }),
57304
57545
  { file, source, edit: (text2) => middlewareList(text2) ?? text2 }
57305
57546
  ],
57306
- heads: p.found.heads.filter(({ file: file2 }) => !templates(file2)),
57307
- bodies: p.found.bodies.filter(({ file: file2 }) => !templates(file2)),
57547
+ heads: p.found.heads.filter(({ file: file2 }) => raw(file2)),
57548
+ bodies: p.found.bodies.filter(({ file: file2 }) => raw(file2)),
57308
57549
  note: `${NOTE.request(helper.file)} It's a middleware, first in ${file}'s MIDDLEWARE, which puts them in every HTML page Django sends whole.`
57309
57550
  });
57310
57551
  }
@@ -57341,6 +57582,7 @@ async function fastapi(p) {
57341
57582
  const helper = await own(p, folder + "agentface.py", ASGI);
57342
57583
  if (!helper) return null;
57343
57584
  const templates = (template) => /(?:^|\/)templates\//.test(template);
57585
+ const raw = (page2) => /(?:^|\/)static\//.test(page2);
57344
57586
  return result(p, "FastAPI", {
57345
57587
  creates: [helper],
57346
57588
  edits: [
@@ -57351,8 +57593,8 @@ async function fastapi(p) {
57351
57593
  }),
57352
57594
  { file, source, edit: (text2) => fastapiModule(text2, imported) ?? text2 }
57353
57595
  ],
57354
- heads: p.found.heads.filter(({ file: file2 }) => !templates(file2)),
57355
- bodies: p.found.bodies.filter(({ file: file2 }) => !templates(file2)),
57596
+ heads: p.found.heads.filter(({ file: file2 }) => raw(file2)),
57597
+ bodies: p.found.bodies.filter(({ file: file2 }) => raw(file2)),
57356
57598
  note: `${NOTE.request(helper.file)} ${file} adds it as the app's middleware, which puts them in every HTML page the app sends whole.`
57357
57599
  });
57358
57600
  }
@@ -57360,6 +57602,7 @@ async function rails(p) {
57360
57602
  if (!/^\s*gem\s+['"]rails['"]/m.test(await p.read("Gemfile") ?? "")) return null;
57361
57603
  const views = ({ file }) => file.startsWith("app/views/");
57362
57604
  if (!p.found.heads.some(views)) return null;
57605
+ const raw = ({ file }) => file.startsWith("public/");
57363
57606
  const helper = await own(p, "config/initializers/agentface.rb", RAILS);
57364
57607
  if (!helper) return null;
57365
57608
  return result(p, "Rails", {
@@ -57368,8 +57611,8 @@ async function rails(p) {
57368
57611
  { ...p.found, heads: p.found.heads.filter(views), bodies: p.found.bodies.filter(views) },
57369
57612
  /\.erb$/
57370
57613
  ),
57371
- heads: p.found.heads.filter((head) => !views(head)),
57372
- bodies: p.found.bodies.filter((body) => !views(body)),
57614
+ heads: p.found.heads.filter(raw),
57615
+ bodies: p.found.bodies.filter(raw),
57373
57616
  note: `${NOTE.request(helper.file)} It adds a Rack middleware that puts them in every HTML page Rails sends whole; the pages in public/ keep the lines in them. With a nonce in the site's Content Security Policy, the tag carries the page's.`
57374
57617
  });
57375
57618
  }
@@ -57393,6 +57636,7 @@ async function phoenix(p) {
57393
57636
  if (!mix || !/\{:phoenix,/.test(mix) || mixApplications(mix) === null) return null;
57394
57637
  const heex = ({ file: file2 }) => file2.endsWith(".heex");
57395
57638
  if (!p.found.heads.some(heex)) return null;
57639
+ const raw = ({ file: file2 }) => file2.startsWith("priv/static/");
57396
57640
  let endpoint = null;
57397
57641
  for (const file2 of p.list.filter((file3) => file3.startsWith("lib/") && file3.endsWith(".ex"))) {
57398
57642
  const source2 = await p.read(file2);
@@ -57415,8 +57659,8 @@ async function phoenix(p) {
57415
57659
  { file, source, edit: (text2) => endpointPlug(text2) ?? text2 },
57416
57660
  { file: "mix.exs", source: mix, edit: (text2) => mixApplications(text2) ?? text2 }
57417
57661
  ],
57418
- heads: p.found.heads.filter((head) => !heex(head)),
57419
- bodies: p.found.bodies.filter((body) => !heex(body)),
57662
+ heads: p.found.heads.filter(raw),
57663
+ bodies: p.found.bodies.filter(raw),
57420
57664
  note: `${NOTE.request(helper.file)} ${file} plugs it in before the router, which puts them in every HTML page it sends whole, and mix.exs starts :inets and :ssl for it, which it asks with.`
57421
57665
  });
57422
57666
  }
@@ -57503,6 +57747,85 @@ async function go(p) {
57503
57747
  var NEXT_TAG = "<AgentfaceTag />";
57504
57748
  var NEXT_TAG_USED = new RegExp(`<AgentfaceTag\\b${ATTRIBUTES2}\\/>`);
57505
57749
  var NEXT_NOTICE = "<AgentfaceNotice />";
57750
+ var NEXT_USES = {
57751
+ AgentfaceNotice: (text2) => text2.includes(NEXT_NOTICE),
57752
+ AgentfaceTag: (text2) => NEXT_TAG_USED.test(text2)
57753
+ };
57754
+ var NEXT_NAMES = Object.keys(NEXT_USES);
57755
+ function nextComponentsFile(list2) {
57756
+ const src = list2.some((file) => /^src\/(?:app|pages)\//.test(file));
57757
+ return `${src ? "src/" : ""}components/agentface.${list2.includes("tsconfig.json") ? "tsx" : "jsx"}`;
57758
+ }
57759
+ function looseJson(text2) {
57760
+ let json2 = "";
57761
+ for (let at = 0; at < text2.length; at++) {
57762
+ if (text2[at] === '"') {
57763
+ const string = /"(?:[^"\\\n]|\\.)*"/y;
57764
+ string.lastIndex = at;
57765
+ const quoted = string.exec(text2)?.[0];
57766
+ if (!quoted) return null;
57767
+ json2 += quoted;
57768
+ at += quoted.length - 1;
57769
+ } else if (text2.startsWith("//", at)) {
57770
+ const end = text2.indexOf("\n", at);
57771
+ if (end === -1) break;
57772
+ at = end - 1;
57773
+ } else if (text2.startsWith("/*", at)) {
57774
+ const end = text2.indexOf("*/", at + 2);
57775
+ if (end === -1) return null;
57776
+ at = end + 1;
57777
+ } else json2 += text2[at];
57778
+ }
57779
+ try {
57780
+ return JSON.parse(json2.replace(/,(\s*[}\]])/g, "$1"));
57781
+ } catch {
57782
+ return null;
57783
+ }
57784
+ }
57785
+ async function aliasesOf(dir, list2) {
57786
+ const config2 = ["tsconfig.json", "jsconfig.json"].find((name) => list2.includes(name));
57787
+ if (!config2) return null;
57788
+ const read2 = looseJson(await readFile3(path3.join(dir, config2), "utf8").catch(() => null) ?? "");
57789
+ const options = read2?.compilerOptions;
57790
+ if (!options?.paths) return null;
57791
+ const paths = Object.entries(options.paths).map(([name, to]) => [
57792
+ name,
57793
+ Array.isArray(to) ? to.filter((at) => typeof at === "string") : []
57794
+ ]).sort(([a], [b]) => b.length - a.length);
57795
+ return { base: typeof options.baseUrl === "string" ? options.baseUrl : ".", paths };
57796
+ }
57797
+ function importBases(aliases, file, from) {
57798
+ if (/^\.\.?\//.test(from)) return [posix.join(posix.dirname(file), from)];
57799
+ for (const [name, to] of aliases?.paths ?? []) {
57800
+ const star = name.endsWith("*");
57801
+ const start = star ? name.slice(0, -1) : name;
57802
+ if (star ? from.startsWith(start) : from === name)
57803
+ return to.map((at) => posix.join(aliases.base, star ? at.replace("*", from.slice(start.length)) : at));
57804
+ }
57805
+ const bare2 = from.replace(/^[@~#]*\//, "");
57806
+ return bare2 !== from ? [`src/${bare2}`, bare2] : [];
57807
+ }
57808
+ var EXTENSIONS2 = ["tsx", "ts", "jsx", "js", "mjs", "cjs"];
57809
+ function importedFile(list2, aliases, file, from) {
57810
+ for (const base of importBases(aliases, file, from))
57811
+ for (const name of [base, ...EXTENSIONS2.flatMap((ext) => [`${base}.${ext}`, `${base}/index.${ext}`])])
57812
+ if (list2.includes(name)) return name;
57813
+ return null;
57814
+ }
57815
+ async function oursIn(dir, list2) {
57816
+ const aliases = await aliasesOf(dir, list2);
57817
+ const ours = nextComponentsFile(list2).replace(/\.[jt]sx$/, "");
57818
+ const bare2 = (name) => name.replace(/\.[cm]?[jt]sx?$/, "");
57819
+ return (file, from) => {
57820
+ if (from === null) return false;
57821
+ const found = importedFile(list2, aliases, file, from);
57822
+ return found ? bare2(found) === ours : importBases(aliases, file, from).includes(ours);
57823
+ };
57824
+ }
57825
+ function sitesOwn(source, file, ours) {
57826
+ const names2 = topNames(source);
57827
+ return new Set(NEXT_NAMES.filter((name) => (names2.get(name) ?? []).some((from) => !ours(file, from))));
57828
+ }
57506
57829
  function nextTag(old) {
57507
57830
  const kept = old ? ownersAttributes(old) : [];
57508
57831
  return kept.length ? `<AgentfaceTag ${kept.join(" ")} />` : NEXT_TAG;
@@ -57662,11 +57985,29 @@ export default function Document() {
57662
57985
  );
57663
57986
  }
57664
57987
  `;
57665
- var NEXT_IMPORTED = /^import\s*\{\s*AgentfaceNotice,\s*AgentfaceTag,?\s*\}\s*from ['"][^'"]*agentface['"];?/;
57666
- function nextImport(source, from) {
57667
- if (new RegExp(NEXT_IMPORTED.source, "m").test(source)) return source;
57668
- const line = importLine(source, NEXT_IMPORT, from);
57669
- if (source.includes(line) || lastMatch(source, IMPORT)) return addImport(source, line);
57988
+ var NEXT_IMPORTED = /^import\s*\{\s*(Agentface(?:Notice|Tag))\s*(?:,\s*(Agentface(?:Notice|Tag))\s*)?,?\s*\}\s*from\s*(['"])([^'"\n]+)\3(;?)/gm;
57989
+ var nextImported = (source, file, ours) => [...source.matchAll(NEXT_IMPORTED)].find((match) => ours(file, match[4])) ?? null;
57990
+ function withoutImport(source, imported) {
57991
+ const rest = source.slice(imported.index + imported[0].length).replace(/^[ \t]*\r?\n/, "");
57992
+ return source.slice(0, imported.index) + (imported.index === 0 ? rest.replace(/^\r?\n/, "") : rest);
57993
+ }
57994
+ function nextImport(source, from, file, ours) {
57995
+ const names2 = topNames(source);
57996
+ const own2 = sitesOwn(source, file, ours);
57997
+ const imported = nextImported(source, file, ours);
57998
+ const had = imported ? [imported[1], imported[2]].filter(Boolean) : [];
57999
+ const wanted = NEXT_NAMES.filter(
58000
+ (name) => !own2.has(name) && (had.includes(name) || NEXT_USES[name](source) && !names2.has(name))
58001
+ );
58002
+ if (imported) {
58003
+ if (wanted.length === had.length && wanted.every((name) => had.includes(name))) return source;
58004
+ if (!wanted.length) return withoutImport(source, imported);
58005
+ const [written, , , quote, where, semicolon] = imported;
58006
+ return source.slice(0, imported.index) + `import { ${wanted.join(", ")} } from ${quote}${where}${quote}${semicolon}` + source.slice(imported.index + written.length);
58007
+ }
58008
+ if (!wanted.length) return source;
58009
+ const line = importLine(source, `{ ${wanted.join(", ")} }`, from);
58010
+ if (lastMatch(source, IMPORT)) return addImport(source, line);
57670
58011
  return line + eolOf(source) + eolOf(source) + source;
57671
58012
  }
57672
58013
  var REQUIRE = /^(?:const|let|var)\s[^\n]*=\s*require\([^\n]*\)[^\n]*$/gm;
@@ -57716,11 +58057,15 @@ function relative(from, to) {
57716
58057
  const rel = posix.relative(posix.dirname(from), to);
57717
58058
  return rel.startsWith(".") ? rel : "./" + rel;
57718
58059
  }
57719
- var nextCalls = (head, body, from) => (source, withNotice) => {
57720
- let text2 = removeTag(source) ?? source;
57721
- if (head && !NEXT_TAG_USED.test(text2)) text2 = addTag(text2, nextTag(linesIn(source).tag)) ?? text2;
57722
- if (body && withNotice && !text2.includes(NEXT_NOTICE)) text2 = addNotice(text2, NEXT_NOTICE) ?? text2;
57723
- return NEXT_TAG_USED.test(text2) || text2.includes(NEXT_NOTICE) ? nextImport(text2, from) : text2;
58060
+ var nextCalls = (head, body, from, file, ours) => (source, withNotice) => {
58061
+ const own2 = sitesOwn(source, file, ours);
58062
+ const tag = own2.has("AgentfaceTag");
58063
+ const notice = own2.has("AgentfaceNotice");
58064
+ let text2 = removeTag(source, { tag, notice }) ?? source;
58065
+ if (head && !tag && !NEXT_TAG_USED.test(text2)) text2 = addTag(text2, nextTag(linesIn(source).tag)) ?? text2;
58066
+ if (body && withNotice && !notice && !text2.includes(NEXT_NOTICE))
58067
+ text2 = addNotice(text2, NEXT_NOTICE) ?? text2;
58068
+ return nextImport(text2, from, file, ours);
57724
58069
  };
57725
58070
  function layouts(p, mine, edit) {
57726
58071
  const files2 = /* @__PURE__ */ new Map();
@@ -57743,12 +58088,12 @@ function layouts(p, mine, edit) {
57743
58088
  }
57744
58089
  async function next(p) {
57745
58090
  if (!p.deps.next) return null;
57746
- const src = p.list.some((file2) => /^src\/(?:app|pages)\//.test(file2));
57747
- const ts = p.list.includes("tsconfig.json");
57748
- const file = `${src ? "src/" : ""}components/agentface.${ts ? "tsx" : "jsx"}`;
57749
- const components = await own(p, file, ts ? NEXT_COMPONENTS_TS : NEXT_COMPONENTS);
58091
+ const file = nextComponentsFile(p.list);
58092
+ const components = await own(p, file, file.endsWith(".tsx") ? NEXT_COMPONENTS_TS : NEXT_COMPONENTS);
57750
58093
  if (!components) return null;
57751
58094
  const from = (at) => relative(at, file.replace(/\.[jt]sx$/, ""));
58095
+ const ours = await oursIn(p.dir, p.list);
58096
+ const aliases = await aliasesOf(p.dir, p.list);
57752
58097
  const document2 = /(?:^|\/)pages\/_document\.js$/;
57753
58098
  const written = p.found.heads.filter((head) => document2.test(head.file) && removeTag(head.source) === null);
57754
58099
  const documents = [...p.found.creates.filter((create) => document2.test(create.file)), ...written].map(
@@ -57758,27 +58103,76 @@ async function next(p) {
57758
58103
  source
57759
58104
  })
57760
58105
  );
58106
+ const isLayout = (name) => NEXT_LAYOUT.test(name) && !written.some((head) => head.file === name);
58107
+ const sources = new Map([...p.found.heads, ...p.found.bodies].map(({ file: file2, source }) => [file2, source]));
58108
+ const all = [...sources.keys()].filter(isLayout);
58109
+ const withTag = all.filter((file2) => hasTag(sources.get(file2)));
58110
+ const placed = p.found.scoped?.files ?? [];
58111
+ const scoped = placed.length > 0 || (withTag.length > 0 || written.length > 0) && withTag.length < all.length;
58112
+ const left = scoped ? [.../* @__PURE__ */ new Set([...p.found.scoped?.left ?? [], ...all.filter((file2) => !withTag.includes(file2))])] : [];
57761
58113
  const {
57762
- edits,
58114
+ edits: every,
57763
58115
  heads: rest,
57764
58116
  bodies
57765
58117
  } = layouts(
57766
58118
  p,
57767
- (name) => NEXT_LAYOUT.test(name) && !written.some((head) => head.file === name),
57768
- (layout) => nextCalls(layout.head, layout.body, from(layout.file))
58119
+ isLayout,
58120
+ (layout) => nextCalls(layout.head, layout.body, from(layout.file), layout.file, ours)
58121
+ );
58122
+ const edits = every.filter(({ file: file2 }) => !left.includes(file2));
58123
+ const rendersOurs = placed.some(
58124
+ ({ file: at, source }) => NEXT_TAG_USED.test(source) && (topNames(source).get("AgentfaceTag") ?? []).some((name) => ours(at, name))
57769
58125
  );
57770
- if (!edits.length && !documents.length) return null;
57771
- const line = { file, code: p.list.filter((name) => JSX_CODE.test(name)) };
58126
+ if (!edits.length && !documents.length && !rendersOurs) return null;
57772
58127
  const config2 = NEXT_CONFIGS.find((name) => p.list.includes(name));
57773
58128
  const settings = config2 ? await p.read(config2) : null;
57774
- const ask = await own(p, NEXT_HELPER, (tag) => {
57775
- const { service, site } = siteOf(tag);
58129
+ const ask = await own(p, NEXT_HELPER, (tag2) => {
58130
+ const { service, site } = siteOf(tag2);
57776
58131
  return NEXT_ASK(service, site);
57777
58132
  });
57778
58133
  const types = config2?.endsWith("ts") ? await own(p, NEXT_TYPES, () => NEXT_ASK_TYPES) : null;
57779
58134
  const made = !config2 ? await own(p, NEXT_NEW_CONFIG, () => NEXT_CONFIG) : null;
57780
58135
  const asks = ask && (config2 ? settings !== null && nextConfig(settings) !== null && types !== void 0 : made !== void 0);
57781
- const what = `${file} renders the tag, its notice and the same notice at the end of each page's first paragraph, for agents that read pages through Exa`;
58136
+ const owned = edits.map(({ file: at, source }) => ({ at, source, own: sitesOwn(source, at, ours) }));
58137
+ const is = (list2, at) => list2.some((found) => found.file === at);
58138
+ const tag = documents.length > 0 || owned.some(({ at, own: own2 }) => is(p.found.heads, at) && !own2.has("AgentfaceTag"));
58139
+ const notice = documents.length > 0 || owned.some(({ at, own: own2 }) => is(p.found.bodies, at) && !own2.has("AgentfaceNotice"));
58140
+ const renders = tag ? notice ? "the tag, its notice and the same notice" : "the tag, and its notice" : notice ? "the tag's notice, and the same notice" : "the tag's notice";
58141
+ const only = scoped || owned.some(({ own: own2 }) => own2.has("AgentfaceTag"));
58142
+ const line = { file, code: p.list.filter((name) => JSX_CODE.test(name)), ...only && { scoped: true } };
58143
+ const where = only ? "the first paragraph of each page that loads the tag" : "each page's first paragraph";
58144
+ const what = scoped ? `${file} renders the tag and its notice where the site's code uses them, and the same notice at the end of ${where}, for agents that read pages through Exa` : `${file} renders ${renders} at the end of ${where}, for agents that read pages through Exa`;
58145
+ const theirs = owned.map(({ at, own: own2 }) => {
58146
+ const names2 = ["AgentfaceTag", "AgentfaceNotice"].filter((name) => own2.has(name));
58147
+ if (!names2.length) return "";
58148
+ const one = names2.length === 1;
58149
+ const lines = names2.map((name) => name === "AgentfaceTag" ? "tag" : "notice").join(" and the ");
58150
+ return ` ${at} renders ${names2.map((name) => `an ${name}`).join(" and ")} of the site's own, not ${one ? "the one" : "those"} in ${file}, so init left ${one ? "it as it is" : "them as they are"}: the ${lines} ${one ? "it renders keeps" : "they render keep"} saying what ${one ? "it says" : "they say"} now, whatever Agentface says later. To have ${one ? `that ${lines}` : "them"} change with the next deploy too, render the ${names2.join(" and ")} of ${file} in ${one ? "its" : "their"} place.`;
58151
+ }).join("");
58152
+ const fileOf = (at, from2) => importedFile(p.list, aliases, at, from2);
58153
+ const theirTags = owned.map(
58154
+ ({ at, source, own: own2 }) => own2.has("AgentfaceTag") ? (topNames(source).get("AgentfaceTag") ?? []).filter((from2) => !ours(at, from2)).flatMap((from2) => {
58155
+ if (from2 !== null) return [fileOf(at, from2)];
58156
+ const loads = [...source.matchAll(/\bimport\(\s*(['"])([^'"\n]+)\1\s*\)/g)];
58157
+ if (loads.length) return loads.map(([, , name]) => fileOf(at, name));
58158
+ return tagKey(source) ? [] : [null];
58159
+ }) : []
58160
+ );
58161
+ const needed = theirTags.flat();
58162
+ const near = new Set(
58163
+ owned.filter(({ at, own: own2 }) => is(p.found.heads, at) && !own2.has("AgentfaceTag")).flatMap(
58164
+ ({ at, source }) => [...topNames(source).values()].flat().map((from2) => from2 === null ? null : fileOf(at, from2))
58165
+ )
58166
+ );
58167
+ const tagged = tag && !scoped ? (p.found.tagged ?? []).filter(
58168
+ ({ file: name }) => !needed.includes(name) && (!needed.includes(null) || near.has(name))
58169
+ ) : [];
58170
+ const key = owned.flatMap(
58171
+ ({ source, own: own2 }, at) => own2.has("AgentfaceTag") ? [
58172
+ tagKey(source),
58173
+ ...theirTags[at].map((name) => p.found.tagged?.find((found) => found.file === name)?.key)
58174
+ ] : []
58175
+ ).find(Boolean) ?? null;
57782
58176
  return result(p, "Next.js", {
57783
58177
  creates: [
57784
58178
  components,
@@ -57792,7 +58186,12 @@ async function next(p) {
57792
58186
  heads: rest,
57793
58187
  bodies,
57794
58188
  line,
57795
- note: asks ? `${what}. ${config2 ?? NEXT_NEW_CONFIG} asks Agentface what they say each time the site is built (${NEXT_HELPER}): when that changes, the next deploy brings the change, with nothing to edit. While Agentface can't be reached, they say what init wrote.` : `${what}, in the words init wrote: init can't tell where ${config2}'s settings are, so it can't have the site ask Agentface for them as it is built. Run init again to bring them up to date.`
58189
+ tagged,
58190
+ key,
58191
+ ...scoped && {
58192
+ scoped: { files: [...placed, ...withTag.map((at) => ({ file: at, source: sources.get(at) }))], left }
58193
+ },
58194
+ note: (asks ? `${what}. ${config2 ?? NEXT_NEW_CONFIG} asks Agentface what they say each time the site is built (${NEXT_HELPER}): when that changes, the next deploy brings the change, with nothing to edit. While Agentface can't be reached, they say what init wrote.` : `${what}, in the words init wrote: init can't tell where ${config2}'s settings are, so it can't have the site ask Agentface for them as it is built. Run init again to bring them up to date.`) + theirs
57796
58195
  });
57797
58196
  }
57798
58197
  var WRITERS = [
@@ -57826,11 +58225,13 @@ var FRAMEWORKS2 = [rails, phoenix, django, fastapi, go, next, astro, hono, fasti
57826
58225
  async function withFramework(dir, found) {
57827
58226
  if (found.manual && !found.manual.none) return found;
57828
58227
  if (["WordPress", "PrestaShop", "PrestaShop theme"].includes(found.framework)) return found;
57829
- const { deps, list: list2 } = await project(dir);
58228
+ const { deps, list: all } = await project(dir);
58229
+ const packages = otherPackages(all);
58230
+ const list2 = all.filter((file) => !packages.some((folder) => file.startsWith(folder)));
57830
58231
  const read2 = (file) => readFile3(path3.join(dir, file), "utf8").catch(() => null);
57831
58232
  const p = { dir, deps, list: list2, found, read: read2 };
57832
58233
  let selected = found;
57833
- for (const framework of FRAMEWORKS2) {
58234
+ for (const framework of found.scoped ? [next] : FRAMEWORKS2) {
57834
58235
  const made = await framework(p);
57835
58236
  if (made) {
57836
58237
  selected = made;
@@ -57850,10 +58251,7 @@ var UNDO = [
57850
58251
  ".use(agentface())",
57851
58252
  ".addHook('onSend', agentface)",
57852
58253
  /^[ \t]*\w+\.add_middleware\(agentface\.Middleware\)/,
57853
- /(?:^\r?\n)?^(?:from \. import agentface|import agentface)$/,
57854
- NEXT_TAG_USED,
57855
- NEXT_NOTICE,
57856
- new RegExp(NEXT_IMPORTED.source.slice(1), "m")
58254
+ /(?:^\r?\n)?^(?:from \. import agentface|import agentface)$/
57857
58255
  ];
57858
58256
  function unwrapped(text2) {
57859
58257
  for (let at; (at = text2.search(/(?<![\w$.])agentface\((?!\s*\))/)) !== -1; ) {
@@ -57866,6 +58264,7 @@ function unwrapped(text2) {
57866
58264
  }
57867
58265
  async function undoFrameworks(dir) {
57868
58266
  const { list: list2 } = await project(dir);
58267
+ const ours = await oursIn(dir, list2);
57869
58268
  const edits = [];
57870
58269
  const deletes = [];
57871
58270
  const keep = /* @__PURE__ */ new Set();
@@ -57887,8 +58286,12 @@ async function undoFrameworks(dir) {
57887
58286
  }
57888
58287
  continue;
57889
58288
  }
57890
- let text2 = source.replace(new RegExp(`${NEXT_IMPORTED.source}\\r?\\n\\r?\\n`), "");
58289
+ const imported = nextImported(source, file, ours);
58290
+ let text2 = imported ? withoutImport(source, imported) : source;
57891
58291
  text2 = UNDO.reduce((done, piece) => without(done, piece), text2);
58292
+ const own2 = /<Agentface(?:Tag|Notice)\b/.test(source) ? sitesOwn(source, file, ours) : /* @__PURE__ */ new Set();
58293
+ if (!own2.has("AgentfaceTag")) text2 = without(text2, NEXT_TAG_USED);
58294
+ if (!own2.has("AgentfaceNotice")) text2 = without(text2, NEXT_NOTICE);
57892
58295
  text2 = text2.replace(/^[ \t]*['"]agentface\.Middleware['"],[ \t]*\r?\n/m, "").replace(/['"]agentface\.Middleware['"],\s*/, "").replace(/,\s*['"]agentface\.Middleware['"]/, "");
57893
58296
  if (NEXT_CONFIGS.includes(file)) text2 = withoutNextConfig(text2);
57894
58297
  if (IMPORTED.test(source) || REQUIRED.test(source)) text2 = unwrapped(text2);
@@ -58037,7 +58440,7 @@ function sourceMatches(source, url, page2) {
58037
58440
  }
58038
58441
  var keyword = (sources, word) => sources.some((source) => source.toLowerCase() === word);
58039
58442
  var hasNonce = (sources, nonce) => sources.some((source) => /^'nonce-/i.test(source) && source.slice(7, -1) === nonce && source.endsWith("'"));
58040
- var governing = (policy, names) => names.find((name) => policy.directives.has(name));
58443
+ var governing = (policy, names2) => names2.find((name) => policy.directives.has(name));
58041
58444
  function fix(policy, decides, name, origin) {
58042
58445
  const sources = policy.directives.get(decides).filter((source) => source.toLowerCase() !== "'none'");
58043
58446
  return { name, line: [name, ...sources, origin].join(" "), created: decides !== name };
@@ -58076,8 +58479,8 @@ var WHERE = {
58076
58479
  header: "In the Content-Security-Policy header the site sends with its pages",
58077
58480
  meta: "In the Content-Security-Policy <meta> tag in the head of its pages"
58078
58481
  };
58079
- var and = (names) => names.join(" and ");
58080
- var or = (names) => names.join(" or ");
58482
+ var and = (names2) => names2.join(" and ");
58483
+ var or = (names2) => names2.join(" or ");
58081
58484
  function advice(blocked, host) {
58082
58485
  const script2 = blocked.some((b) => b.script);
58083
58486
  const connect2 = blocked.some((b) => b.connect);
@@ -58210,7 +58613,7 @@ function readPage(html) {
58210
58613
  })
58211
58614
  };
58212
58615
  }
58213
- function choose(pages) {
58616
+ function choose(pages, outside2 = []) {
58214
58617
  const chosen = [];
58215
58618
  const before = [];
58216
58619
  const results = pages.map(({ path: path6, page: page2 }) => {
@@ -58219,7 +58622,7 @@ function choose(pages) {
58219
58622
  if (page2.lines) return { path: path6, mark: null, has: "already" };
58220
58623
  if (shared.length) return { path: path6, mark: shared[0], has: "shared", times: shared.length };
58221
58624
  const pick = page2.paragraphs.find(
58222
- ({ mark: mark2 }) => mark2 !== null && page2.marks.get(mark2) === 1 && !before.some((marks) => marks.has(mark2)) && // Nor one that a page read after it shows beside one chosen already,
58625
+ ({ mark: mark2 }) => mark2 !== null && page2.marks.get(mark2) === 1 && !before.some((marks) => marks.has(mark2)) && !outside2.some((other) => other.marks.has(mark2)) && // Nor one that a page read after it shows beside one chosen already,
58223
58626
  // as a page that compares two products would.
58224
58627
  !pages.some(
58225
58628
  ({ page: other }) => other.marks.has(mark2) && chosen.some((done) => other.marks.has(done))
@@ -58254,8 +58657,9 @@ function endParagraph(source, offset) {
58254
58657
  return source.slice(0, at) + `
58255
58658
  ${indent}<${LINE_NAME} />` + source.slice(at);
58256
58659
  }
58660
+ var ownLine = (source, file) => (topNames(source).get(LINE_NAME) ?? []).some((from) => !importsComponents(file, from));
58257
58661
  function withImport(source, from) {
58258
- if (new RegExp(`\\bimport\\s+${LINE_NAME}\\b`).test(source)) return source;
58662
+ if (topNames(source).has(LINE_NAME)) return source;
58259
58663
  const imports = [...source.matchAll(/^import\b[^'"]*?(['"])[^'"\n]+\1(;?)[ \t]*$/gm)];
58260
58664
  const last = imports.at(-1);
58261
58665
  if (last) {
@@ -58509,7 +58913,8 @@ async function placeLine({
58509
58913
  component,
58510
58914
  log,
58511
58915
  policies = [],
58512
- start = nextDev
58916
+ start = nextDev,
58917
+ only
58513
58918
  }) {
58514
58919
  const blocked = () => log(
58515
58920
  "The site's Content Security Policy blocks inline styles, so people would see the line agents read through Exa: it is in no page."
@@ -58525,7 +58930,7 @@ async function placeLine({
58525
58930
  for (const file of code) {
58526
58931
  if (file === component || !JSX_CODE.test(file)) continue;
58527
58932
  const source = await readFile4(path4.join(dir, file), "utf8").catch(() => null);
58528
- if (source === null || !new RegExp(OPEN.source).test(source)) continue;
58933
+ if (source === null || !new RegExp(OPEN.source).test(source) || ownLine(source, file)) continue;
58529
58934
  const { text: text2, offsets } = mark(source, next2);
58530
58935
  offsets.forEach((offset, i) => where.set(next2 + i, { file, offset }));
58531
58936
  next2 += offsets.length;
@@ -58592,8 +58997,17 @@ async function placeLine({
58592
58997
  blocked();
58593
58998
  return { files: [] };
58594
58999
  }
58595
- const read2 = pages.map(({ path: at2, html }) => ({ path: at2, page: readPage(html) }));
58596
- const { chosen, results } = choose(read2);
59000
+ const loads = (html) => !only || html.includes(`/s/${only}.js`);
59001
+ const read2 = pages.filter(({ html }) => loads(html)).map(({ path: at2, html }) => ({ path: at2, page: readPage(html) }));
59002
+ const outside2 = pages.filter(({ html }) => !loads(html));
59003
+ if (outside2.length)
59004
+ log(
59005
+ `Left the line agents read through Exa out of ${outside2.map(({ path: at2 }) => at2).join(", ")}, which ${outside2.length === 1 ? "doesn't" : "don't"} load the Agentface tag.`
59006
+ );
59007
+ const { chosen, results } = choose(
59008
+ read2,
59009
+ outside2.map(({ html }) => readPage(html))
59010
+ );
58597
59011
  const edit = (marks) => {
58598
59012
  const edits2 = /* @__PURE__ */ new Map();
58599
59013
  const byFile = /* @__PURE__ */ new Map();
@@ -58708,8 +59122,8 @@ async function confirm(service, id, fetcher = fetch) {
58708
59122
  return { ok: response.ok, status: response.status, message: body?.message ?? `HTTP ${response.status}` };
58709
59123
  }
58710
59124
  var option = (source, name) => source?.match(new RegExp(`^\\s*${name}["']?\\s*[:=]\\s*["'\`]?([^"'\`\\s]+)`, "m"))?.[1] ?? null;
58711
- var config = async (dir, names) => {
58712
- for (const name of names) {
59125
+ var config = async (dir, names2) => {
59126
+ for (const name of names2) {
58713
59127
  const source = await readFile5(path5.join(dir, name), "utf8").catch(() => null);
58714
59128
  if (source !== null) return { source, name };
58715
59129
  }
@@ -58720,12 +59134,12 @@ async function siteUrl(dir, exec = run) {
58720
59134
  const host = (await readFile5(path5.join(dir, file), "utf8").catch(() => "")).trim().split(/\s+/)[0];
58721
59135
  if (host) return { url: `https://${host}/`, from: file };
58722
59136
  }
58723
- for (const [names, key] of [
59137
+ for (const [names2, key] of [
58724
59138
  [["astro.config.mjs", "astro.config.ts", "astro.config.mts", "astro.config.js"], "site"],
58725
59139
  [["hugo.toml", "config.toml"], "baseURL"],
58726
59140
  [["_config.yml"], "url"]
58727
59141
  ]) {
58728
- const { source, name } = await config(dir, names);
59142
+ const { source, name } = await config(dir, names2);
58729
59143
  const url = key === "site" && source ? astroSite(source) : option(source, key);
58730
59144
  if (/^https?:\/\//i.test(url ?? "")) return { url, from: name };
58731
59145
  }
@@ -58822,6 +59236,18 @@ async function siteFor({
58822
59236
  }
58823
59237
  var serviceFlag = (service) => service === DEFAULT_SERVICE ? "" : ` --service ${service}`;
58824
59238
  var list = (files2) => files2.length <= 3 ? files2.join(", ") : `${files2.slice(0, 3).join(", ")} and ${files2.length - 3} more`;
59239
+ function leftWithout(found) {
59240
+ const said3 = [found.skipped];
59241
+ if (found.scoped) {
59242
+ const files2 = found.scoped.files.map(({ file }) => file);
59243
+ const { left } = found.scoped;
59244
+ const without2 = left.length ? `${list(left)} ${left.length === 1 ? "doesn't" : "don't"}` : "no page head does";
59245
+ said3.push(
59246
+ `${list(files2)} ${files2.length === 1 ? "has" : "have"} the Agentface tag and ${without2}: init kept it where it is and added it nowhere else, so pages that didn't load it still don't.`
59247
+ );
59248
+ }
59249
+ return said3.filter(Boolean).join(" ") || null;
59250
+ }
58825
59251
  function nextSteps(site, service, own2) {
58826
59252
  const saved = own2 === "plugin";
58827
59253
  const check2 = `npx agentface check${saved ? ` --site ${site.id}` : ""}${serviceFlag(service)}`;
@@ -59041,6 +59467,7 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59041
59467
  };
59042
59468
  }
59043
59469
  if (found.manual) return byHand2(found, site, service, dryRun, warning, log);
59470
+ const without2 = leftWithout(found);
59044
59471
  const before = /* @__PURE__ */ new Map();
59045
59472
  const after = /* @__PURE__ */ new Map();
59046
59473
  const edited = /* @__PURE__ */ new Map();
@@ -59048,6 +59475,13 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59048
59475
  before.set(file, source);
59049
59476
  edited.set(file, addTag(source, site.tag));
59050
59477
  }
59478
+ for (const { file, source } of found.scoped?.files ?? []) {
59479
+ const updated = updatedTags(source, site.tag);
59480
+ if (updated !== source && !found.edits?.some((edit) => edit.file === file)) {
59481
+ before.set(file, source);
59482
+ edited.set(file, updated);
59483
+ }
59484
+ }
59051
59485
  if (site.notice)
59052
59486
  for (const { file, source } of found.bodies) {
59053
59487
  before.set(file, source);
@@ -59072,21 +59506,34 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59072
59506
  const own2 = found.creates.some(({ file }) => file.endsWith(".zip")) ? "plugin" : found.framework === "WordPress" || found.framework === "PrestaShop" ? "file" : void 0;
59073
59507
  const shop = found.framework === "PrestaShop" ? prestaShopSteps(found.creates[0].file) : found.framework === "WordPress" && own2 === "plugin" ? wordPressSteps(found.creates[0].file) : null;
59074
59508
  const twice = stale.length ? `${list(stale)} ${stale.length === 1 ? "has" : "have"} an Agentface tag already, from an earlier init or added by hand. Take it out, so that no page loads the tag twice: \`npx agentface uninstall\` does it.` : null;
59509
+ const beside = (found.tagged ?? []).map(({ file }) => file);
59510
+ const also = beside.length ? `${list(beside)} ${beside.length === 1 ? "has" : "have"} an Agentface tag too, from an earlier init or added by hand, and ${notAPage(beside)}. Take the tag out there, so that no page loads it twice.` : null;
59075
59511
  const noticed = site.notice && (found.bodies.length || found.creates.length);
59076
59512
  const what = `the Agentface tag${noticed ? " and its notice" : ""}`;
59077
- const had = [...found.heads, ...found.bodies, ...found.creates, ...found.edits ?? []].some(
59513
+ const had = [
59514
+ ...found.heads,
59515
+ ...found.bodies,
59516
+ ...found.creates,
59517
+ ...found.edits ?? [],
59518
+ ...found.scoped?.files ?? []
59519
+ ].some(
59078
59520
  ({ file, source }) => files2.includes(file) && typeof source === "string" && (tagKey(source) === site.id || noticeKey(source) === site.id || source.includes(OURS) && source.includes(`'${site.id}'`))
59079
59521
  );
59080
59522
  const elsewhere = () => noticeToReplace(site, found.noticed ?? [], notAPage, log);
59081
59523
  if (!writes.length && !(line && !dryRun)) {
59082
59524
  const tagged = [
59083
- ...new Set([...found.heads, ...found.creates, ...found.edits ?? []].map(({ file }) => file))
59525
+ ...new Set(
59526
+ [...found.scoped?.files ?? [], ...found.heads, ...found.creates, ...found.edits ?? []].map(
59527
+ ({ file }) => file
59528
+ )
59529
+ )
59084
59530
  ];
59085
59531
  log(`${list(tagged)} already ${tagged.length === 1 ? "has" : "have"} the Agentface tag for ${site.id}.`);
59086
- if (found.skipped) log(found.skipped);
59532
+ if (without2) log(without2);
59087
59533
  elsewhere();
59088
59534
  if (shop) log(shop);
59089
59535
  if (twice) log(twice);
59536
+ if (also) log(also);
59090
59537
  if (warning) log(warning);
59091
59538
  log(nextSteps(site, service, own2));
59092
59539
  return { site, files: files2, written: false };
@@ -59095,12 +59542,13 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59095
59542
  log(
59096
59543
  had ? `Would update ${what} in ${list(files2)} (${found.framework}) for ${site.origin}, to what init writes today.` : `Would add ${what} to ${list(files2)} (${found.framework}) for ${site.origin}.`
59097
59544
  );
59098
- if (found.skipped) log(found.skipped);
59545
+ if (without2) log(without2);
59099
59546
  if (line)
59100
59547
  log(
59101
59548
  "Would then run the site with next dev, to put the line agents read through Exa at the end of each page's first paragraph."
59102
59549
  );
59103
59550
  elsewhere();
59551
+ if (also) log(also);
59104
59552
  if (warning) log(warning);
59105
59553
  return { site, files: files2, written: false };
59106
59554
  }
@@ -59119,15 +59567,26 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59119
59567
  );
59120
59568
  else {
59121
59569
  const tagged = [
59122
- ...new Set([...found.heads, ...found.creates, ...found.edits ?? []].map(({ file }) => file))
59570
+ ...new Set(
59571
+ [...found.scoped?.files ?? [], ...found.heads, ...found.creates, ...found.edits ?? []].map(
59572
+ ({ file }) => file
59573
+ )
59574
+ )
59123
59575
  ];
59124
59576
  log(`${list(tagged)} already ${tagged.length === 1 ? "has" : "have"} the Agentface tag for ${site.id}.`);
59125
59577
  }
59126
- if (found.skipped) log(found.skipped);
59578
+ if (without2) log(without2);
59127
59579
  let lined = [];
59128
59580
  if (line) {
59129
59581
  const policies = "policies" in homepage ? homepage.policies : [];
59130
- lined = (await place({ dir, code: line.code, component: line.file, log, policies })).files;
59582
+ lined = (await place({
59583
+ dir,
59584
+ code: line.code,
59585
+ component: line.file,
59586
+ log,
59587
+ policies,
59588
+ ...line.scoped && { only: site.id }
59589
+ })).files;
59131
59590
  for (const file of lined) if (!files2.includes(file)) files2.push(file);
59132
59591
  }
59133
59592
  if (!files2.length) {
@@ -59141,6 +59600,7 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59141
59600
  if (found.note) log(found.note);
59142
59601
  if (shop) log(shop);
59143
59602
  if (twice) log(twice);
59603
+ if (also) log(also);
59144
59604
  if (found.framework === "PrestaShop theme") log(PRESTASHOP_THEME);
59145
59605
  if (found.framework === "WordPress" && own2 === "file")
59146
59606
  log(
@@ -59181,7 +59641,7 @@ Add a second snippet to All pages, placed in Body \u2013 start:
59181
59641
  service,
59182
59642
  warning,
59183
59643
  had,
59184
- [found.note, found.skipped].filter(Boolean).join(" ") || null,
59644
+ [found.note, without2, also].filter(Boolean).join(" ") || null,
59185
59645
  lined.length ? line.file : null
59186
59646
  )
59187
59647
  ],
@@ -59282,7 +59742,7 @@ async function uninstall({
59282
59742
  continue;
59283
59743
  }
59284
59744
  const removed = ownFile(source) ? null : removeTag(changed.get(file) ?? source);
59285
- const content = removed === null ? null : withoutLine(removed);
59745
+ const content = removed === null ? null : withoutLine(removed, file);
59286
59746
  if (content === null) {
59287
59747
  deleted.push(file);
59288
59748
  changed.delete(file);