Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
87c3091b
Commit
87c3091b
authored
Jun 25, 2025
by
Lin Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add the ai command line
parent
168acbd5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
8 deletions
+25
-8
package.json
package.json
+8
-2
diffWithDeepDiff.ts
src/detect_section_selector_masters/diffWithDeepDiff.ts
+10
-4
index.ts
src/detect_section_selector_masters/index.ts
+7
-2
No files found.
package.json
View file @
87c3091b
...
...
@@ -14,11 +14,16 @@
},
"scripts"
:
{
"extract"
:
"DETECTION_MODE=extract bun run src/detect_section_selector_masters/index.ts"
,
"extract:ai"
:
"USE_AI_SELECTORS=true bun run extract"
,
"detect"
:
"DETECTION_MODE=detect bun run src/detect_section_selector_masters/index.ts"
,
"detect:ai"
:
"USE_AI_SELECTORS=true bun run detect"
,
"fix"
:
"DETECTION_MODE=fix bun run src/detect_section_selector_masters/index.ts"
,
"fix:ai"
:
"USE_AI_SELECTORS=true bun run fix"
,
"nav"
:
"DETECTION_MODE=extractNav bun run src/detect_section_selector_masters/index.ts"
,
"nav:ai"
:
"USE_AI_SELECTORS=true bun run nav"
,
"diff"
:
"bun run src/detect_section_selector_masters/diffWithDeepDiff.ts"
,
"diff:ai"
:
"BASELINE_ID=29279960 npm run diff"
,
"task"
:
"bun run extract && bun run diff"
"diff:ai"
:
"USE_AI_SELECTORS=true bun run diff"
,
"task"
:
"bun run extract && bun run diff"
,
"task:ai"
:
"bun run extract:ai && bun run diff:ai"
}
}
\ No newline at end of file
src/detect_section_selector_masters/diffWithDeepDiff.ts
View file @
87c3091b
...
...
@@ -2,7 +2,7 @@
import
{
diff
}
from
'deep-diff'
;
import
{
readFileSync
,
writeFileSync
,
mkdirSync
,
rmSync
}
from
'fs'
;
import
{
join
}
from
'path'
;
import
{
section_selectors
}
from
'../constant/section_selectors'
;
import
{
section_selectors
,
ai_section_selectors
}
from
'../constant/section_selectors'
;
// Directory containing JSON outputs to compare
const
srcDir
=
'src/detect_section_selector_masters/extractOutput'
;
...
...
@@ -15,9 +15,14 @@ rmSync(outDir, { recursive: true, force: true });
// Ensure output directory exists
mkdirSync
(
outDir
,
{
recursive
:
true
});
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
// 根据环境变量选择使用哪个 selector 数组
const
selectedSelectors
=
useAiSelectors
?
ai_section_selectors
:
section_selectors
;
// Baseline section ID (override via BASELINE_ID env variable)
const
EN_SITE_ID
=
27328697
;
const
baselineId
=
process
.
env
.
BASELINE_ID
?
Number
(
process
.
env
.
BASELINE_ID
)
:
EN_SITE_ID
;
const
AI_EN_SITE_ID
=
29279960
;
const
baselineId
=
useAiSelectors
?
AI_EN_SITE_ID
:
EN_SITE_ID
;
const
baselineFile
=
`
${
baselineId
}
_extract.json`
;
// Read baseline data
...
...
@@ -27,7 +32,7 @@ const baselineData = JSON.parse(readFileSync(baselinePath, 'utf-8'));
// Fields to ignore during diff
const
ignoreFields
=
[
'pageUid'
,
'pageTitle'
,
'id'
];
se
ction_s
electors
se
lectedS
electors
.
filter
(
id
=>
Number
(
id
)
!==
baselineId
)
.
forEach
(
otherId
=>
{
const
otherFile
=
`
${
otherId
}
_extract.json`
;
...
...
@@ -73,5 +78,5 @@ section_selectors
const
outFile
=
`
${
baselineId
}
_vs_
${
otherId
}
_diff.json`
;
const
outPath
=
join
(
outDir
,
outFile
);
writeFileSync
(
outPath
,
JSON
.
stringify
(
semantic
,
null
,
2
),
'utf-8'
);
console
.
log
(
`✅ Diff between
${
baselineId
}
and
${
otherId
}
written to
${
join
(
outDir
,
outFile
)}
`
);
console
.
log
(
`✅ Diff between
${
baselineId
}
and
${
otherId
}
written to
${
join
(
outDir
,
outFile
)}
${
useAiSelectors
?
'(AI selectors)'
:
''
}
`
);
});
\ No newline at end of file
src/detect_section_selector_masters/index.ts
View file @
87c3091b
...
...
@@ -16,6 +16,10 @@ import { mainParse } from './handlePageContent'
type
CommandMode
=
'detect'
|
'extract'
|
'fix'
|
'extractNav'
;
const
commandMode
=
(
process
.
env
.
DETECTION_MODE
as
CommandMode
)
||
'extract'
;
const
useAiSelectors
=
process
.
env
.
USE_AI_SELECTORS
===
'true'
;
// 根据环境变量选择使用哪个 selector 数组
const
selectedSelectors
=
useAiSelectors
?
ai_section_selectors
:
section_selectors
;
// 确保输出目录存在
let
outDir
=
''
...
...
@@ -36,7 +40,7 @@ rmSync(outDir, { recursive: true, force: true })
mkdirSync
(
outDir
,
{
recursive
:
true
})
await
Promise
.
all
(
se
ction_s
electors
.
map
(
async
(
siteId
,
index
)
=>
{
se
lectedS
electors
.
map
(
async
(
siteId
,
index
)
=>
{
const
{
content
}
=
await
fetchSiteData
(
siteId
)
const
{
jsonData
:
pageContent
,
result
,
navigationInfo
}
=
mainParse
(
content
)
||
{}
const
file
=
`
${
outDir
}
/
${
siteId
}
_
${
commandMode
}
.json`
...
...
@@ -50,6 +54,6 @@ await Promise.all(
data
=
navigationInfo
}
writeFileSync
(
file
,
JSON
.
stringify
(
data
,
null
,
2
),
'utf-8'
)
console
.
log
(
`✅
${
siteId
}
output written to
${
file
}
`
)
console
.
log
(
`✅
${
siteId
}
output written to
${
file
}
${
useAiSelectors
?
'(AI selectors)'
:
''
}
`
)
})
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment