> For the complete documentation index, see [llms.txt](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase38-session02-platform-foundation/tasks.md).

# Task Checklist

**Session ID**: `phase38-session02-platform-foundation` **Total Tasks**: 18 **Estimated Duration**: 3-4 hours **Created**: 2026-06-29

***

Legend: `[x]` completed; `[ ]` pending; `[P]` parallelizable; `[SNNMM]` session ref; `TNNN` task ID.

***

## Progress Summary

| Metric          | Value   |
| --------------- | ------- |
| Tasks Completed | 18 / 18 |
| Current Task    | none    |
| Blockers        | 0       |

***

## Setup (3 tasks)

* [x] T001 \[S3802] Verify upstream platform helper concepts, current AI OS scan/tool detection owners, and existing test owners before edits (`.spec_system/PRD/phase_38/session_02_platform_foundation.md`)
* [x] T002 \[S3802] Record baseline targeted test and typecheck commands for scan helpers and tool detection (`.spec_system/specs/phase38-session02-platform-foundation/implementation-notes.md`)
* [x] T003 \[S3802] Confirm no root-level `scripts/platform.ts` importer exists and record whether a compatibility re-export is unnecessary (`scripts/platform.ts`)

***

## Foundation (4 tasks)

* [x] T004 \[S3802] Create shared platform option types and OS flag helpers with injectable `platform`, `home`, and environment inputs for deterministic branch tests (`scripts/lib/platform.ts`)
* [x] T005 \[S3802] \[P] Implement `toPosix`, home expansion, home redaction, app-data, local-app-data, and app-support helpers with explicit Windows, macOS, and Linux fallback behavior (`scripts/lib/platform.ts`)
* [x] T006 \[S3802] \[P] Implement venv binary helpers and Windows/POSIX executable-name expansion with exhaustive extension handling (`scripts/lib/platform.ts`)
* [x] T007 \[S3802] Implement bounded CLI candidate-directory helpers with PATH-first ordering, duplicate removal, package-manager fallbacks, Windows app-data/npm locations, and deterministic ordering (`scripts/lib/platform.ts`)

***

## Implementation (4 tasks)

* [x] T008 \[S3802] Refactor scan helpers to import shared `HOME`, `IS_MACOS`, home expansion, redaction, and app-support primitives without changing scanner outputs (`scripts/lib/scan-helpers.ts`)
* [x] T009 \[S3802] Refactor tool detection to use shared executable-name and CLI candidate-directory helpers while preserving current `resolveCliPath` behavior (`scripts/lib/tool-detection.ts`)
* [x] T010 \[S3802] Remove duplicate local platform helper functions from tool detection after shared helper integration (`scripts/lib/tool-detection.ts`)
* [x] T011 \[S3802] Verify public script exports still match existing consumers and update imports only where required (`scripts/lib/scan-helpers.ts`)

***

## Testing (7 tasks)

* [x] T012 \[S3802] \[P] Add direct platform tests for OS flags, `toPosix`, app-data, app-support, and venv bin paths across `win32`, `darwin`, and `linux` (`scripts/lib/__tests__/platform.test.ts`)
* [x] T013 \[S3802] \[P] Add direct platform tests for CLI executable names, candidate-directory priority, Windows `%APPDATA%\npm`, `%LOCALAPPDATA%\Programs`, and duplicate removal (`scripts/lib/__tests__/platform.test.ts`)
* [x] T014 \[S3802] \[P] Update scan helper tests for any moved home expansion or redaction assertions (`scripts/lib/__tests__/scan-helpers.test.ts`)
* [x] T015 \[S3802] \[P] Extend tool detection tests for Windows extension candidates and shared fallback directories after refactor (`scripts/lib/__tests__/tool-detection.test.ts`)
* [x] T016 \[S3802] Run targeted platform, scan-helper, and tool-detection tests (`bun run test -- scripts/lib/__tests__/platform.test.ts scripts/lib/__tests__/scan-helpers.test.ts scripts/lib/__tests__/tool-detection.test.ts`)
* [x] T017 \[S3802] Run script typecheck and confirm no downstream script import regressions (`bun run typecheck:scripts`)
* [x] T018 \[S3802] Validate ASCII, LF, no dependency changes, and implementation evidence before handing off to code review (`.spec_system/specs/phase38-session02-platform-foundation/implementation-notes.md`)

***

## Completion Checklist

* [x] All tasks marked `[x]`
* [x] All tests and checks passing
* [x] All files ASCII-encoded with LF line endings
* [x] `implementation-notes.md` updated
* [x] Ready for `creview` to review and repair the completed implementation

***

## Next Steps

Run the `creview` workflow step.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://ai-os-and-trend-finder.gitbook.io/ai-os-and-trend-finder-docs/.spec_system/archive/sessions/phase38-session02-platform-foundation/tasks.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
