Commit Graph

303 Commits

Author SHA1 Message Date
starmen1265 a102a75b28 feat(08-01): create crawler data models and test scaffolding
- Add Pydantic models: AnswerData, ArticleData, ContentMetadata, AuthorInfo, CrawlResult
- Create test fixtures in conftest.py with mock browser and sample API responses
- Set up crawler module with __init__.py exports

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 21:06:33 +08:00
starmen1265 334aac87c7 fix(08): resolve Wave 1 file conflict - move 08-02 to Wave 2 2026-03-17 21:02:17 +08:00
starmen1265 6d2d6b26e9 docs(08): create phase 8 plans for crawler implementation 2026-03-17 20:56:51 +08:00
starmen1265 c93237abde docs(08): add validation strategy 2026-03-17 20:49:01 +08:00
starmen1265 1464c9b707 docs(08): research crawler implementation domain 2026-03-17 20:47:12 +08:00
starmen1265 ba33e0e518 docs(state): record phase 08 context session 2026-03-17 18:57:06 +08:00
starmen1265 87adf8aca6 docs(08): capture phase context for crawler implementation 2026-03-17 18:56:56 +08:00
starmen1265 e8eaca519f docs(07-03): complete Login CLI Subcommand plan
- Cookie validation via /api/v4/me endpoint
- login CLI subcommand with 3 modes: scan, import, status
- AUTH-04 requirement complete: Cookie expiry detection
- Phase 7 Login Auth complete, ready for Phase 8 Crawler

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 18:24:32 +08:00
starmen1265 d9861aa6c3 feat(07-03): implement login CLI subcommand
- Add login_command function with QR code login, cookie import, and status check
- Add login subcommand with --import-cookie and --status options
- Update CLI help text with login examples
- Fix mock paths in tests to match actual import locations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 18:10:43 +08:00
starmen1265 94c85baac9 test(07-03): add failing tests for login CLI subcommand
- Test login_default_mode - default QR code login flow
- Test login_import_cookie - --import-cookie JSON import
- Test login_status - --status cookie validation
- Test login_integration - successful login saves cookie
- Test login_error_handling - exception handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 18:01:53 +08:00
starmen1265 919a4673e6 feat(07-03): implement cookie validation functionality
- Add CookieValidationResult Pydantic model with valid, username, user_id, reason fields
- Add validate_cookie async method to ZhihuLogin class
- Validate cookie via Zhihu /api/v4/me endpoint
- Handle 200, 401, and other status codes appropriately
- Handle network errors gracefully

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 18:00:37 +08:00
starmen1265 32bb22008b test(07-03): add failing tests for cookie validation
- Test validate_cookie_valid - valid cookie returns user info
- Test validate_cookie_expired - expired cookie returns False
- Test validate_cookie_empty - empty cookie returns False
- Test validate_cookie_malformed - network error handling
- Test validate_cookie_other_status_code - non-200/401 handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:59:28 +08:00
starmen1265 4228b1e3a1 docs(07-01): complete QR Code Login Core plan 2026-03-17 17:57:28 +08:00
starmen1265 799bf09acc docs(07-02): add self-check verification to summary
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:54:12 +08:00
starmen1265 072d83da35 feat(07-01): implement ZhihuLogin QR code login class
TDD GREEN phase - implementation passes all 8 tests:

- ZhihuLoginResult: Pydantic model for login results
- ZhihuLogin: Main class with QR code login flow
  - LOGIN_URL: https://www.zhihu.com/signin
  - CANVAS_SELECTORS: Multiple fallback selectors for QR canvas
  - _find_qrcode_canvas(): Find canvas with fallback selectors
  - _save_qrcode_image(): Save QR code to intermediate directory
  - check_login_cookie(): Detect z_c0 cookie for login state
  - get_cookies_str(): Extract cookie string from context
  - _wait_for_login(): Poll with configurable timeout (tenacity)
  - login_by_qrcode(): Main entry point for login flow

Key design decisions:
- Uses tenacity Retrying for configurable timeout
- QR code saved to intermediate_path with timestamp
- Multiple canvas selectors for robustness
- Proper browser lifecycle management

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:54:06 +08:00
starmen1265 771ca554b3 docs(07-02): complete cookie import & persistence plan 2026-03-17 17:53:38 +08:00
starmen1265 00245c58cc feat(07-02): implement CookieManager class
- CookieManager saves cookies to ~/.kb_env file
- Updates existing ZHIHU_COOKIE line or appends new
- Preserves other configuration lines
- Sets file permissions to 600 for security
- Loads cookies from env file
- Clears get_settings cache after saving

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:50:39 +08:00
starmen1265 fb9bc2d1ed test(07-01): add failing tests for ZhihuLogin QR code login
TDD RED phase - tests expect ZhihuLogin class that doesn't exist yet:

- test_login_page_access: verify correct login URL
- test_qrcode_screenshot: verify QR code capture and save
- test_cookie_detection_with_z_c0: verify login detection
- test_cookie_detection_without_z_c0: verify no login when missing z_c0
- test_cookie_extraction: verify cookie string format
- test_login_timeout: verify timeout after 60s polling
- test_result_model_success: verify success result model
- test_result_model_failure: verify failure result model

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:50:26 +08:00
starmen1265 19c377ef65 test(07-02): add failing tests for Cookie persistence
- Test save_cookie creates env file
- Test save_cookie updates existing line
- Test save_cookie appends new line
- Test save_cookie preserves other lines
- Test save_cookie sets file permissions to 600
- Test load_cookie returns saved value
- Test load_cookie returns empty if file not exists

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:49:47 +08:00
starmen1265 f90de6b8a6 test(07-01): add auth test fixtures
- Create tests/test_auth/conftest.py with pytest fixtures
- mock_browser: Mock PlaywrightBrowser for unit testing
- mock_canvas: Mock canvas element for QR code screenshot
- sample_cookies: Test cookie data with z_c0 login cookie
- sample_cookies_no_login: Test cookies without login state
- mock_env_file: Temporary .kb_env file fixture
- intermediate_path: Temporary intermediate directory fixture

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:49:22 +08:00
starmen1265 2360fcc99e feat(07-02): implement parse_json_cookies function
- Parse Chrome Cookie Editor JSON format
- Filter cookies by zhihu.com domain
- Handle malformed JSON with ValueError
- Handle file not found with ValueError
- Return cookie string in "name=value; name2=value2" format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:48:51 +08:00
starmen1265 af3536aa92 test(07-02): add failing tests for Cookie JSON parsing
- Test parse_json_cookies for Chrome Cookie Editor format
- Test domain filtering for zhihu.com
- Test empty array handling
- Test malformed JSON error handling
- Test file not found error handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 17:48:23 +08:00
starmen1265 d6a8690bc7 docs(07): add phase plans (3 plans, 2 waves) 2026-03-17 17:18:12 +08:00
starmen1265 14434df4eb docs(07): create phase 7 login auth plans 2026-03-17 17:15:30 +08:00
starmen1265 1d1f3309b2 docs(07): research phase domain - login auth system 2026-03-17 17:08:30 +08:00
starmen1265 58487b0fa3 docs(state): record phase 7 context session 2026-03-17 16:57:14 +08:00
starmen1265 87c7e50c4f docs(07): capture phase context 2026-03-17 16:57:02 +08:00
starmen1265 367b2816c4 docs: create milestone v1.2 roadmap (3 phases) 2026-03-17 16:31:17 +08:00
starmen1265 dcba34b643 docs: define milestone v1.2 requirements 2026-03-17 16:27:05 +08:00
starmen1265 9077a783e8 docs: start milestone v1.2 Zhihu Crawler 2026-03-17 16:16:38 +08:00
starmen1265 c77a45ab0b chore: remove old kb-deep-analyzer directory
PR Test / lint (pull_request) Successful in 1s
Code has been integrated into kb_workflow/deep_analyzer package.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 15:31:18 +08:00
starmen1265 9fc52ffbdd refactor: integrate kb-deep-analyzer as kb_workflow.deep_analyzer package
- Move kb-deep-analyzer/deep_analyzer.py to kb_workflow/deep_analyzer/__init__.py
- Update analyze.py to import from kb_workflow.deep_analyzer directly
- Remove sys.path manipulation for external package
- DeepAnalyzer, SimpleAIClient, generate_frontmatter now available as:
  from kb_workflow.deep_analyzer import DeepAnalyzer, SimpleAIClient, generate_frontmatter

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 15:28:58 +08:00
starmen1265 14b3a3c4c1 fix(analyze): correct kb-deep-analyzer path calculation
- Add one more .parent to reach correct directory level
- Fixed path: /home/.../kb-skills/kb-deep-analyzer (was /home/.../kb-skills/kb_workflow/kb-deep-analyzer)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 15:14:22 +08:00
starmen1265 244dea9371 feat(kb_workflow): add archive_file to process_command return value
PR Test / lint (pull_request) Successful in 2s
- Extract archive_file from pipeline results and include in response
- Allows callers to get the final archive path instead of only content_dir
- Fixes report display issue where content directory showed working dir instead of archive location

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 13:53:55 +08:00
starmen1265 ee0fc74378 fix(download): return author name instead of mid in _extract_author
PR Test / lint (pull_request) Successful in 1s
- Fix download processor to return actual author name (e.g. "HOLA小测佬")
  instead of B站用户ID (mid, e.g. "406636263")
- Add 5 test cases for author extraction logic
- Resolves report display issue where UP主名称 showed numeric ID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 13:50:02 +08:00
starmen1265 2dce679cca fix(debug): resolve kb-pipeline import issue in skill directory
PR Test / lint (pull_request) Successful in 2s
Root cause: ~/.openclaw/skills/kb-workflow/kb_workflow.py used old
import paths (kb_pipeline.*) after v1.1 refactor renamed package to
kb_workflow.pipeline

Fix applied to external skill directory:
- Updated imports from kb_pipeline.* to kb_workflow.pipeline.*
- Fixed project_root path calculation
- Updated SKILL.md documentation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 11:01:33 +08:00
starmen1265 8d67f3c953 docs(06): complete phase 6 with verification passed
PR Test / lint (pull_request) Successful in 1s
- All 3 plans executed (06-01, 06-02, 06-03)
- sys.path operations eliminated
- Pipeline exported at package level
- Phase goal achieved: clean Python package structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:40:01 +08:00
starmen1265 2bec25e15c docs(06-03): complete gap closure plan 2026-03-17 00:37:30 +08:00
starmen1265 fae4ff2f28 fix(06-03): update test import to use new package structure
- Remove sys.path manipulation from test file
- Use standard package import from kb_workflow.metadata
- Test file now follows the same import pattern as production code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:35:31 +08:00
starmen1265 72d75e3454 feat(06-03): export Pipeline class from pipeline package
- Add Pipeline import from kb_workflow.pipeline.pipeline
- Add Pipeline to __all__ exports list
- Enables: from kb_workflow.pipeline import Pipeline

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:34:26 +08:00
starmen1265 8b07ef9dcd refactor(06-03): move sys.path manipulation to lazy import in analyze.py
- Remove top-level sys.path.insert for kb-deep-analyzer
- Add module-level flag _deep_analyzer_path_added for single execution
- Move sys.path manipulation inside _run_analysis method
- External dependency import now happens lazily at runtime

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:34:06 +08:00
starmen1265 81d67b7672 fix(06-03): remove sys.path manipulation from zhihu_metadata.py
- Remove unnecessary sys.path.insert for current directory
- Use relative import for zhihu_extractor
- Package imports work correctly without path manipulation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:33:23 +08:00
starmen1265 2b305b0eb9 fix(06-03): remove sys.path manipulation from zhihu_extractor.py
- Remove unnecessary sys.path.insert for current directory
- Use pure relative import for markdown_converter
- Package imports work correctly without path manipulation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:33:02 +08:00
starmen1265 ab8655de3a fix(06-03): remove sys.path manipulation from kb_workflow.py
- Remove unnecessary sys.path.insert for project root
- Update docstring to reference kb_workflow.pipeline
- Package imports work correctly without path manipulation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:32:40 +08:00
starmen1265 fdd6c08211 docs(06): create gap closure plan 06-03 2026-03-17 00:28:35 +08:00
starmen1265 3edbdcc183 docs(06): add phase verification report
PR Test / lint (pull_request) Successful in 2s
9/9 core functions verified, but gaps found:
- 4 remaining sys.path manipulations
- Pipeline not exported at package level

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:24:34 +08:00
starmen1265 190a04068b docs(06-02): complete pipeline module consolidation plan
- Move kb_pipeline/ to kb_workflow.pipeline/
- Update all imports to use absolute paths
- 278 tests pass (14 pre-existing failures unrelated to refactoring)
- CLI works with new module structure

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:18:06 +08:00
starmen1265 2df08c6e26 chore(06-02): remove original kb_pipeline directory
All code has been moved to kb_workflow.pipeline with updated imports.
278 tests pass (14 pre-existing mock-related failures unrelated to refactoring).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:17:19 +08:00
starmen1265 c9ca1b538d refactor(06-02): update CLI and test imports to kb_workflow.pipeline
- Remove sys.path manipulation from kb_workflow.py
- Update CLI imports to use kb_workflow.pipeline prefix
- Update all test file imports and patch paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:17:10 +08:00
starmen1265 fdca690bd6 feat(06-02): move processors and platforms to kb_workflow.pipeline
- Move all processor implementations (parse, download, asr, analyze, archive)
- Move all platform adapters (base, bilibili, zhihu)
- Update all internal imports to use kb_workflow.pipeline prefix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-17 00:17:01 +08:00