@frontera-sdk/cli 1.46.6 → 1.46.7

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.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * What the composer typed, as the harness should read it.
3
+ *
4
+ * The shared composer inserts references as platform markdown —
5
+ * `[/compact](platform://skill/compact)` for a slash pick,
6
+ * `[@Ads Explorer](platform://skill/ads-explorer)` for an `@` one. That
7
+ * grammar means something to the platform's own runtime and nothing to Claude
8
+ * Code, which would receive the literal brackets and URI: picking `/compact`
9
+ * from the menu would send prose about a link instead of running the command.
10
+ *
11
+ * So a token is reduced to what a person typing into the harness would have
12
+ * written — `/compact`, or the plain label for an `@` reference. The id is
13
+ * what the host addresses, so a slash token resolves to the id rather than the
14
+ * display label (they differ once a plugin namespaces its skills).
15
+ */
16
+
17
+ const TOKEN = /\[([/@])((?:\\.|[^\]\\])*)\]\(platform:\/\/([a-zA-Z]+)\/([^)?\s]+)(?:\?[^)]*)?\)/g
18
+
19
+ function unescapeLabel(label: string): string {
20
+ return label.replace(/\\([[\]\\])/g, '$1')
21
+ }
22
+
23
+ /** Rewrite platform mention tokens into what the harness understands. */
24
+ export function normalizeTurnText(text: string): string {
25
+ return text.replace(TOKEN, (_match, prefix: string, label: string, _kind: string, id: string) => {
26
+ if (prefix === '/') {
27
+ try {
28
+ return `/${decodeURIComponent(id)}`
29
+ } catch {
30
+ return `/${id}`
31
+ }
32
+ }
33
+ return unescapeLabel(label)
34
+ })
35
+ }
package/src/kit.ts CHANGED
@@ -55,20 +55,38 @@ export function digest(content: string): string {
55
55
  * add five lines is not a trade they agreed to. Only what sits between the
56
56
  * markers is ours.
57
57
  */
58
- export function managedBlock(body: string): string {
59
- return `${MANAGED_BEGIN}\n${body.trim()}\n${MANAGED_END}\n`
58
+ export function managedBlock(body: string, markers: BlockMarkers = KIT_MARKERS): string {
59
+ return `${markers.begin}\n${body.trim()}\n${markers.end}\n`
60
60
  }
61
61
 
62
+ /**
63
+ * Which managed block a call means.
64
+ *
65
+ * More than one thing writes into a project's `AGENTS.md` now — `frontera kit`
66
+ * vendors the skills, and Forge states the folder's situation — and two writers
67
+ * sharing one pair of markers means each silently deletes the other's block.
68
+ */
69
+ export interface BlockMarkers {
70
+ begin: string
71
+ end: string
72
+ }
73
+
74
+ export const KIT_MARKERS: BlockMarkers = { begin: MANAGED_BEGIN, end: MANAGED_END }
75
+
62
76
  /** Insert or replace the managed block, leaving every other line where it is. */
63
- export function applyManagedBlock(existing: string | null, body: string): string {
64
- const block = managedBlock(body)
77
+ export function applyManagedBlock(
78
+ existing: string | null,
79
+ body: string,
80
+ markers: BlockMarkers = KIT_MARKERS,
81
+ ): string {
82
+ const block = managedBlock(body, markers)
65
83
  if (existing === null || existing.trim() === '') return block
66
84
 
67
- const begin = existing.indexOf(MANAGED_BEGIN)
68
- const end = existing.indexOf(MANAGED_END)
85
+ const begin = existing.indexOf(markers.begin)
86
+ const end = existing.indexOf(markers.end)
69
87
  if (begin !== -1 && end > begin) {
70
88
  const before = existing.slice(0, begin)
71
- const after = existing.slice(end + MANAGED_END.length).replace(/^\n/, '')
89
+ const after = existing.slice(end + markers.end.length).replace(/^\n/, '')
72
90
  return `${before}${block}${after}`
73
91
  }
74
92