Canto 1 - Boyhood
Bāla-kāṇḍa
Chapter 3: Vālmīki Composes the Rāmāyaṇa
Text 1.3.5-6

स्त्रीतृतीयेन च तथा यत्प्राप्तं चरता वने सत्यसन्धेन रामेण तत्सर्वं चान्ववेक्षितम्।
ततः पश्यति धर्मात्मा तत्सर्वं योगमास्थितः पुरा यत्तत्र निर्वृत्तं पाणावामलकं यथा॥

strī-tṛtīyena ca tathā yat prāptaṁ caratā vane
satya-sandhena rāmeṇa tat sarvaṁ cānvavekṣitam
tataḥ paśyati dharmātmā tat sarvaṁ yogam āsthitaḥ
purā yat tatra nirvṛttaṁ pāṇāv āmalakaṁ yathā

strī-tṛtīyena ca = with his brother and wife; ca = and; tathā yat prāptam = that had happened; caratā = while He was wandering; vane = in the forest; satya-sandhena = the upholder of his promise; rāmeṇa = to Lord Rāma; tat sarvam ca = all that anvavekṣitam = directly saw; tatah = then; paśyati = saw; dharma-ātmā = [Vālmīki] of a dhārmika nature; tat sarvam = and others; yogam = yoga; āsthitaḥ = situated in; purā = had previously; yat tatra = all that; nirvṛttam = transpired; pāṇau = in his hand āmalakam yathā = as if it were an āmalaka fruit.

He directly saw all that had happened to Lord Rāma, the upholder of his promise, while He was wandering in the forest with His brother and wife. Then, Vālmīki of a dhārmika nature, situated in yoga, saw all that had previously transpired to Rāma and others, as if it were an āmalaka fruit in his hand.

Having stated that he had observed all the events that took place when Lord Rāma resided in the city of Ayodhyā, he then states that he saw all of the events that had transpired when Lord Rāma resided in the Daṇḍakāraṇya forest. He saw those details with extreme clarity for he had taken up yoga, that is, the means to satisfy Lord Brahmā. Yoga here refers to “[an appropriate] means” [2].

NOTE. In Bhagavad-gītā 7.1, the Supreme Personality of Godhead tells Arjuna that by practicing yoga in full consciousness of Him, with the mind attached to Him, one can know Him in full without any doubt. Śrī Vālmīki did this and therefore saw in samādhi all of Lord Rāma’s pastimes.

[2] yogaḥ sannahanopāya-dhyāna-saṅgati-yuktiṣu.