Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*//*---------------------------------------------------------------------------------------------
* Merge CG-generated and extension-scanned NOTICE files into a single output.
*
* - Keys by lowercased name@version so multiple shipped versions are preserved
* - CG entries win on collision; scanner cargo entries override CG on stub
* collisions (SPDX-as-body replaced with real fetched license text)
* - Logs every package with its source
* - Produces ThirdPartyNotices.new.txt
*
* Usage:
* node merge-notices.js --cg <path> --extensions <path> --output <path>
*--------------------------------------------------------------------------------------------*/import fs from'fs';import{ applyOverrides, readCglicenses }from'./apply-overrides.js';import{ isPackageHeader }from'./parse-notices.js';import{ parseArgs }from'./utils.js';interfaceNoticeEntry{
name:string;
version:string;
license:string;
url
licenseText
filePath NoticeEntry
fsfilePath
content fsfilePath
entries NoticeEntry
blocks content
i i blockslength i
block blocksi
block
lines block
headerLine
headerIdx
j j lineslength j
linesj
headerLine linesj
headerIdx j
headerLine headerLine
headerLine headerLine
headerLine
match headerLine
name version license
url
match
name match
version match
license match
match2 headerLine
match2
name match2
version
license match2
name headerLine
version
license
remainingLines linesheaderIdx
licenseStartIdx
j j remainingLineslength j
line remainingLinesj
line
line line
url line
licenseStartIdx j
licenseStartIdx j
licenseText remainingLineslicenseStartIdx
entries name version license url licenseText
entries
merged Map NoticeEntry
unresolved name version reason
name version reason
presentNamesLower mergede ename
out name version reason
item unresolved
presentNamesLoweritemname
out name itemname version itemversion reason itemreason
entry merged
entrylicenseText entrylicenseText
out name entryname version entryversion reason
seen
deduped name version reason
u out
key
seenkey
seenkey
dedupedu
dedupeda b
an aname
bn bname
an bn
anbn
aversion bversion
deduped
args processargv
cgPath args
extPath args
outputPath args
cglicensesPath args
strict processargv
provenance args
outputPath
process
cgEntries cgPath cgPath
extEntries extPath extPath
merged
e NoticeEntry
entry cgEntries
key entry
mergedkey
mergedkey entry source
cgCount mergedsize
stubOverrideKeys
stubOverridePath args extPath extPath
stubOverridePath fsstubOverridePath
raw fsstubOverridePath
raw
k raw
k
stubOverrideKeysk
err
extAdded
extSkipped
extStubOverridden
extAddedNames
extSkippedNames
collidedOverrideKeys
entry extEntries
key entry
mergedkey
stubOverrideKeyskey
mergedkey entry source
extStubOverridden
collidedOverrideKeyskey
extAddedNames
extSkipped
extSkippedNames
mergedkey entry source
extAdded
extAddedNames
uncollidedOverrideKeys stubOverrideKeysk collidedOverrideKeysk
uncollidedOverrideKeyslength
k uncollidedOverrideKeys
extAddedNameslength
n extAddedNames
extSkippedNameslength
n extSkippedNames
overridesApplied
overridesInjected
overrideEntryCount
unmatchedOverrides
staleOverrides
cglicensesPath
fscglicensesPath
overrides cglicensesPath
presencePath args extPath extPath
presentNames
presencePath fspresencePath
raw fspresencePath
raw
item raw name
item itemname
presentNamesitemname
err
result merged overrides fetchUris presentNames
overridesApplied resultappliedNameslength
overridesInjected resultinjectedNameslength
overrideEntryCount resultappliedEntryCount
unmatchedOverridesresultunmatchedNames
staleOverridesresultstaleNames
name resultappliedNames
name resultinjectedNames
err resulterrors
resultstaleNameslength
platformToken
name resultstaleNames
hint platformTokenname
resultunmatchedNameslength
name resultunmatchedNames
strict resulterrorslength resultunmatchedNameslength
process
err
strict
process
sorted mergeda b
anamebname
header
output header
entry sorted
output
output entryname
entryversion
output entryversion
entrylicense
output entrylicense
output
entryurl
output entryurl
provenance
entrysource
output
entrysource
output
entrysource
output
output
entrylicenseText
output entrylicenseText
output
fsoutputPath output
err
process
sizeMB outputlength
extScannerFound extAdded extStubOverridden extSkipped
totalFound cgCount extScannerFound overridesInjected
totalFolded extSkipped extStubOverridden
totalIncluded sortedlength
unresolvedPath args extPath extPath
unresolvedList name version reason
unresolvedPath fsunresolvedPath
raw fsunresolvedPath
raw
unresolvedList raw name version reason
item item itemname
item
name itemname
version itemversion itemversion
reason itemreason itemreason
err
cglicensesPath
cglicensesPath
unaccounted merged unresolvedList
unaccountedlength
u unaccounted
totalFound totalFolded totalIncluded
processargv
err err process
// Validate this looks like a real package header, not license prose
// following a decorative dash line inside a LICENSE body.
if
(
!
isPackageHeader
(
)
)
{
continue
;
}
const
=
.
match
(
/^(.+?)\s+([\d][^\s]*)\s+-\s+(.+)$/
)
;
let
:
string
,
:
string
,
:
string
;
let
=
''
;
if
(
)
{
=
[
1
]
;
=
[
2
]
;
=
[
3
]
;
}
else
{
const
=
.
match
(
/^(.+?)\s+-\s+(.+)$/
)
;
if
(
)
{
=
[
1
]
;
=
''
;
=
[
2
]
;
}
else
{
=
;
=
''
;
=
''
;
}
}
const
=
.
slice
(
+
1
)
;
let
=
0
;
for
(
let
=
0
;
<
.
;
++
)
{
const
=
[
]
.
trim
(
)
;
if
(
!
)
{
continue
;
}
if
(
.
startsWith
(
'http://'
)
||
.
startsWith
(
'https://'
)
)
{
=
;
=
+
1
;
}
else
{
=
;
}
break
;
}
const
=
.
slice
(
)
.
join
(
'\n'
)
.
trim
(
)
;
.
push
(
{
,
,
,
,
}
)
;
}
return
;
}
/**
* Compute the packages NOT accounted for in the final merged NOTICE. A package
* is "unaccounted" if EITHER:
* (a) the scanner tried to resolve it but created no row (it appears in the
* `unresolved` sibling) AND its name is absent from the final merged map
* (name-only match avoids version-drift false positives, and correctly
* excludes packages rescued downstream via a cglicenses.json override), OR
* (b) it IS a row in the final notice but its license body is empty/whitespace.
*
* Pure and exported for unit testing. Informational only — never affects exit code.
*/
export
function
computeUnaccounted
(
:
<
string
,
>
,
:
Array
<
{
:
string
;
:
string
;
:
string
}
>
)
:
Array
<
{
:
string
;
:
string
;
:
string
}
>
{
const
=
new
Set
(
[
...
.
values
(
)
]
.
map
(
=>
.
.
toLowerCase
(
)
)
)
;
const
:
Array
<
{
:
string
;
:
string
;
:
string
}
>
=
[
]
;
// (a) Genuinely absent: scanner failed AND the name never landed in the notice.
for
(
const
of
)
{
if
(
!
.
has
(
.
.
toLowerCase
(
)
)
)
{
.
push
(
{
:
.
,
:
.
,
:
.
}
)
;
}
}
// (b) Present but with an empty license body.
for
(
const
of
.
values
(
)
)
{
if
(
!
.
||
.
.
trim
(
)
===
''
)
{
.
push
(
{
:
.
,
:
.
,
:
'no-license-text'
}
)
;
}
}
// Dedupe by `<name>@<version>` (a pkg may appear from both sources).
// Stub-override only flips priority on a `name@version` collision. If CG
// recorded a crate at a DIFFERENT version than Cargo.lock resolved, there is
// no collision: the scanner entry is added as a separate record and CG's stub
// SURVIVES -- a silent divergence (the scanner's cargoStubOverride counter
// still claimed success). Warn loudly for any override key that never
// collided so the mismatch is visible to the operator.
const
=
[
...
]
.
filter
(
=>
!
.
has
(
)
)
.
sort
(
)
;
if
(
.
>
0
)
{
console
.
warn
(
` WARN: ${uncollidedOverrideKeys.length} stub-override key(s) never collided with a CG entry -- CG's stub may survive at a different version. Verify these crates' notice text:`
` WARN: could not read presence index ${presencePath}: ${(err as Error).message}`
)
;
}
}
else
{
console
.
warn
(
` WARN: no presence index found (${presencePath ||'none'}); stale overrides cannot be detected, so unmatched overrides with usable text will be injected.`
)
;
}
const
=
await
applyOverrides
(
,
,
{
:
true
,
}
)
;
=
.
.
;
=
.
.
;
=
.
;
.
push
(
...
.
)
;
.
push
(
...
.
)
;
for
(
const
of
.
.
sort
(
)
)
{
console
.
log
(
` * edited: ${name}`
)
;
}
for
(
const
of
.
.
sort
(
)
)
{
console
.
log
(
` + injected: ${name}`
)
;
}
for
(
const
of
.
)
{
console
.
error
(
` ! ${err}`
)
;
}
if
(
.
.
>
0
)
{
console
.
warn
(
`${result.staleNames.length} override(s) reference a package not present in THIS build. A package can be absent because it is platform-specific (it only ships on other OS/arch builds) OR because the override is genuinely stale. Verify across platforms before removing anything from cglicenses.json:`
)
;
// Heuristic: flag names that contain a platform/arch token so a
// single-platform build doesn't lead someone to delete an override
' (likely platform-specific -- do NOT delete based on a single-platform build)'
:
''
;
console
.
warn
(
` ? stale: ${name}${hint}`
)
;
}
}
if
(
.
.
>
0
)
{
console
.
warn
(
`${result.unmatchedNames.length} override(s) have no matching package and no usable license text:`
)
;
for
(
const
of
.
.
sort
(
)
)
{
console
.
warn
(
` ? unmatched: ${name}`
)
;
}
}
// Stale overrides are warn-only and NEVER fail the build (the PR-time
// check is the real gate). --strict still fails on genuine errors and on
// unmatched (no-usable-text) overrides.
if
(
&&
(
.
.
>
0
||
.
.
>
0
)
)
{
console
.
error
(
'--strict: failing build due to override errors or unmatched entries'
)
;
.
exit
(
2
)
;
}
console
.
log
(
''
)
;
}
catch
(
)
{
console
.
error
(
`ERROR reading cglicenses overrides from ${cglicensesPath}: ${(err as Error).message}`
)
;
if
(
)
{
.
exit
(
2
)
;
}
}
}
}
// Sort and render
const
=
[
...
.
values
(
)
]
.
sort
(
(
,
)
=>
.
.
toLowerCase
(
)
.
localeCompare
(
.
.
toLowerCase
(
)
)
)
;
const
=
`NOTICES AND INFORMATION
Do Not Translate or Localize
This software incorporates material from third parties.
Microsoft makes certain open source code available at https://3rdpartysource.microsoft.com,
or you may send a check or money order for US $5.00, including the product name,
the open source component name, platform, and version number, to:
Source Code Compliance Team
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052
USA
Notwithstanding any other terms, you may reverse engineer this software to the extent
required to debug changes to any libraries licensed under the GNU Lesser General Public License.`
;
let
=
+
'\n\n'
;
for
(
const
of
)
{
+=
'\n'
+
SEPARATOR
+
'\n\n'
;
+=
.
;
if
(
.
)
{
+=
' '
+
.
;
}
if
(
.
)
{
+=
' - '
+
.
;
}
+=
'\n'
;
if
(
.
)
{
+=
.
+
'\n'
;
}
// Provenance annotations help reviewers trace where each license text
// came from. Gated behind --provenance so they can be stripped from the
// final shipped NOTICE when we cut over from the shadow copy.
if
(
)
{
if
(
.
===
'extension-scanner'
)
{
+=
'(license text obtained directly from package LICENSE file)\n'
;
}
else
if
(
.
===
'cargo-stub-override'
)
{
+=
'(license text fetched from the crate repository -- replaces CG SPDX-expression stub)\n'
;
}
else
if
(
.
===
'cglicenses-override'
)
{
+=
'(license text supplied by cglicenses.json manual override)\n'
;
}
}
+=
'\n'
;
if
(
.
)
{
+=
.
+
'\n'
;
}
}
+=
'\n'
+
SEPARATOR
+
'\n'
;
try
{
.
writeFileSync
(
,
,
'utf8'
)
;
}
catch
(
)
{
console
.
error
(
`ERROR: Failed to write output file ${outputPath}: ${(err as Error).message}`
)
;
.
exit
(
1
)
;
}
const
=
(
.
/
1024
/
1024
)
.
toFixed
(
2
)
;
// Reconcile the numbers so the summary is self-explaining. Only three inputs
// ADD a row to the final NOTICE: CG packages, brand-new extension-scanner
// packages, and injected overrides. Everything else either lands on a package
// CG already covers (folded -> no new row) or edits an existing row in place
// (count-neutral). "Found" is the gross discovery count across all sources;
// "included" is what actually ships after folding the overlaps.
const
=
+
+
;
const
=
+
+
;
const
=
+
;
const
=
.
;
// Load the scanner's unresolved index (packages it tried to resolve but
// produced no row for). Cross-checked against the final merged notice below so
// packages rescued downstream (e.g. a cglicenses.json override) are excluded.
// Never throws — a missing/garbled sibling just yields an empty list.
const
=
[
'unresolved'
]
||
(
?
+
'.unresolved.json'
:
''
)
;
let
:
Array
<
{
:
string
;
:
string
;
:
string
}
>
=
[
]
;
if
(
&&
.
existsSync
(
)
)
{
try
{
const
:
unknown
=
JSON
.
parse
(
.
readFileSync
(
,
'utf8'
)
)
;
if
(
Array
.
isArray
(
)
)
{
=
(
as
Array
<
{
?
:
unknown
;
?
:
unknown
;
?
:
unknown
}
>
)
.
filter
(
=>
&&
typeof
.
===
'string'
)
.
map
(
=>
(
{
:
.
as
string
,
:
typeof
.
===
'string'
?
.
:
''
,
:
typeof
.
===
'string'
?
.
:
'unresolved'
,
}
)
)
;
}
}
catch
(
)
{
console
.
warn
(
` WARN: could not read unresolved index ${unresolvedPath}: ${(err as Error).message}`
` Packages NOT accounted for in the final NOTICE: ${unaccounted.length}`
)
;
}
// Defensive: if a future code path mutates the merged map without updating a
// counter, this catches the drift instead of silently shipping a wrong total.
if
(
-
!==
)
{
console
.
warn
(
` WARN: merge accounting mismatch -- found(${totalFound}) - folded(${totalFolded}) = ${totalFound - totalFolded}, but the final NOTICE has ${totalIncluded} packages. A source or override path is uncounted.`
)
;
}
console
.
log
(
''
)
;
console
.
log
(
` Output: ${outputPath} (${sizeMB} MB)`
)
;
}
// Only run mainAsync() when merge-notices is the entry point -- not when a test
// or another module imports the exported helpers (mirrors scan-licenses.ts).